Skip to content

Commit

Permalink
Turn adbg.debugger into adbg.process and introduce "high-level" debug…
Browse files Browse the repository at this point in the history
…ger module
  • Loading branch information
dd86k committed Aug 30, 2024
1 parent 38a7c36 commit 55bd935
Show file tree
Hide file tree
Showing 17 changed files with 702 additions and 664 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ changes to the API.

None of the functions are currently thread-safe.

Compiling a static binary on one C runtime may not work on another due to
specific behaviors when using ptrace(2).

# Usage

Usage for `alicedbg` (debugger) and `alicedump` (dumper) can be looked in the
Expand Down
4 changes: 2 additions & 2 deletions common/errormgmt.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
/// License: BSD-3-Clause-Clear
module common.errormgmt;

import adbg.debugger.exception;
import adbg.self;
import adbg.machines : adbg_machine_default;
import adbg.disassembler;
import adbg.debugger.process;
import adbg.process.base;
import adbg.process.exception;
import adbg.error;
import core.stdc.string : strerror;
import core.stdc.errno : errno;
Expand Down
16 changes: 0 additions & 16 deletions debugger/debugger.d

This file was deleted.

2 changes: 1 addition & 1 deletion debugger/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import adbg.self;
import adbg.error;
import core.stdc.stdlib : strtol, EXIT_SUCCESS, EXIT_FAILURE;
import core.stdc.stdio;
import debugger, shell;
import shell;
import common.errormgmt;
import common.cli;
import common.utils : unformat64;
Expand Down
10 changes: 9 additions & 1 deletion debugger/shell.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,29 @@ module shell;

import adbg;
import adbg.machines;
import adbg.process.context;
import adbg.process.exception;
import adbg.process.memory;
import adbg.error;
import adbg.include.c.stdio;
import adbg.include.c.stdlib;
import adbg.include.c.stdarg;
import core.stdc.string;
import common.errormgmt;
import common.cli : opt_syntax;
import common.utils;
import debugger;
import term;

// Enable new process name, although it is currently broken on Windows
//version = UseNewProcessName

extern (C):

///
int opt_pid;
///
const(char) **opt_file_argv;

/// Application error
enum ShellError {
none = 0,
Expand Down
17 changes: 15 additions & 2 deletions dumper/format/elf.d
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ void dump_elf_ehdr(adbg_object_t *o) {
}

void dump_elf_e_flags(ushort e_machine, uint e_flags) {
static immutable const(char) *fname = "e_flags";
switch (e_machine) {
case ELF_EM_ARM:
print_flags32("e_flags", e_flags,
print_flags32(fname, e_flags,
"EF_ARM_RELEXEC".ptr, ELF_EF_ARM_RELEXEC,
"EF_ARM_HASENTRY".ptr, ELF_EF_ARM_HASENTRY,
"EF_ARM_INTERWORK".ptr, ELF_EF_ARM_INTERWORK,
Expand All @@ -134,7 +135,7 @@ void dump_elf_e_flags(ushort e_machine, uint e_flags) {
case ELF_EM_SPARC:
case ELF_EM_SPARC32PLUS:
case ELF_EM_SPARCV9:
print_flags32("e_flags", e_flags,
print_flags32(fname, e_flags,
"EF_SPARC_32PLUS".ptr, ELF_EF_SPARC_32PLUS,
"EF_SPARC_SUN_US1".ptr, ELF_EF_SPARC_SUN_US1,
"EF_SPARC_HAL_R1".ptr, ELF_EF_SPARC_HAL_R1,
Expand All @@ -144,6 +145,18 @@ void dump_elf_e_flags(ushort e_machine, uint e_flags) {
"EF_SPARCV9_RMO".ptr, ELF_EF_SPARCV9_RMO,
null);
break;
case ELF_EM_MIPS:
case ELF_EM_MIPS_RS3_LE:
case ELF_EM_MIPS_X:
print_flags32(fname, e_flags,
"EF_MIPS_NOREORDER".ptr, ELF_EF_MIPS_NOREORDER,
"EF_MIPS_PIC".ptr, ELF_EF_MIPS_PIC,
"EF_MIPS_CPIC".ptr, ELF_EF_MIPS_CPIC,
"EF_MIPS_XGOT".ptr, ELF_EF_MIPS_XGOT,
"EF_MIPS_64BIT_WHIRL".ptr, ELF_EF_MIPS_64BIT_WHIRL,
"EF_MIPS_ABI2".ptr, ELF_EF_MIPS_ABI2,
"EF_MIPS_ABI_ON32".ptr, ELF_EF_MIPS_ABI_ON32,
null);
default:
print_x32("e_flags", e_flags);
}
Expand Down
Loading

0 comments on commit 55bd935

Please sign in to comment.