Skip to content

Commit

Permalink
Linux build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Feb 26, 2024
1 parent dc923fb commit 68c1bdc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/adbg/debugger/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import adbg.utils.strings : adbg_util_argv_flatten;
import adbg.debugger.exception : adbg_exception_t, adbg_exception_translate;
import adbg.debugger.breakpoint : adbg_breakpoint_t;
import adbg.object.machines;
import core.stdc.string : memset;
import core.stdc.string;

version (Windows) {
import adbg.include.windows.wow64;
Expand All @@ -37,17 +37,14 @@ version (Windows) {
} else version (Posix) {
import adbg.include.posix.mann;
import adbg.include.posix.ptrace;
import adbg.include.posix.unistd : clone, CLONE_PTRACE;
import adbg.include.posix.unistd;
import adbg.include.posix.sys.wait;
import adbg.utils.math : MIN;
import core.stdc.ctype : isdigit;
import core.stdc.stdlib : atoi;
import core.stdc.string : strcpy;
import core.sys.posix.sys.stat;
import core.sys.posix.signal;
import core.sys.posix.sys.uio;
import core.sys.posix.fcntl : open, O_RDONLY;
import core.sys.posix.unistd : read, close, execve;
import core.sys.posix.dirent;
import core.sys.posix.libgen : basename;

Expand Down Expand Up @@ -143,7 +140,7 @@ enum AdbgSpawnOpt {
/// Default: Current directory of debugger.
startDir = 3,
// Pass environment table to tracee.
//environment = 4,
environment = 4,
// Continue after spawning process.
//continue_ = 5,
// Tell debugger to use the shell instead of the OS interface.
Expand Down Expand Up @@ -175,6 +172,7 @@ int adbg_debugger_spawn(adbg_process_t *tracee, const(char) *path, ...) {
const(char) *args;
const(char) **argv;
const(char) *dir;
const(char) **envp;
LOPT:
switch (va_arg!int(list)) {
case 0: break;
Expand All @@ -187,6 +185,9 @@ LOPT:
case AdbgSpawnOpt.startDir:
dir = va_arg!(const(char)*)(list);
goto LOPT;
case AdbgSpawnOpt.environment:
envp = va_arg!(const(char)**)(list);
goto LOPT;
default:
return adbg_oops(AdbgError.invalidOption);
}
Expand Down
2 changes: 1 addition & 1 deletion src/adbg/platform.d
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ else private enum NoBoundsCheck = "";
enum D_FEATURES = PIC~PIE~SIMD~AVX~AVX2~NoBoundsCheck;

//
// ANCHOR Functions
// ANCHOR Info functions
//

/// Target information structure
Expand Down
16 changes: 7 additions & 9 deletions src/adbg/self.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ version (Windows) {
PVOID AddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER);
}
} else version (Posix) {
import adbg.include.posix.unistd;
import adbg.include.posix.ptrace;
import core.stdc.string : strstr;
import core.sys.posix.signal;
import core.sys.posix.ucontext;
import core.sys.posix.unistd;
import adbg.include.posix.ptrace;
import core.sys.posix.fcntl;

private enum NO_SIGACTION = cast(sigaction_t*)0;
}
Expand All @@ -63,8 +65,6 @@ bool adbg_self_is_debugged() {
version (Windows) {
return IsDebuggerPresent() == TRUE;
} else version (linux) { // https://stackoverflow.com/a/24969863
import core.stdc.string : strstr;

// Linux 5.10 example status for cat(1) is 1392 Bytes
enum BUFFERSZ = 4096;

Expand Down Expand Up @@ -146,9 +146,6 @@ __gshared int function(adbg_exception_t*) __ufunction;
version (Windows)
extern (Windows)
uint adbg_internal_handler(_EXCEPTION_POINTERS *e) {
import core.sys.windows.winbase :
EXCEPTION_IN_PAGE_ERROR, EXCEPTION_ACCESS_VIOLATION;

adbg_exception_t ex = void;

ex.oscode = e.ExceptionRecord.ExceptionCode;
Expand Down Expand Up @@ -185,11 +182,12 @@ void adbg_internal_handler(int sig, siginfo_t *si, void *p) {
ex.oscode = sig;
ex.type = adbg_exception_from_os(si.si_signo, si.si_code);
ex.pid = getpid();
ex.tid = gettid();
//TODO: gettid() definition
//ex.tid = gettid();

switch (sig) {
case SIGILL, SIGSEGV, SIGFPE, SIGBUS:
ex.fault_address = cast(size_t)sig._sifields._sigfault.si_addr;
ex.fault_address = cast(size_t)si._sifields._sigfault.si_addr;
break;
default:
ex.fault_address = 0;
Expand Down

0 comments on commit 68c1bdc

Please sign in to comment.