Skip to content

Commit

Permalink
Linux fix build attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Feb 26, 2024
1 parent 807a026 commit dc923fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/adbg/debugger/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ version (Windows) {
import adbg.include.posix.ptrace;
import adbg.include.posix.unistd : clone, CLONE_PTRACE;
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;
Expand All @@ -49,7 +50,6 @@ version (Windows) {
import core.sys.posix.unistd : read, close, execve;
import core.sys.posix.dirent;
import core.sys.posix.libgen : basename;
import adbg.utils.math : MIN;

version (linux) {
import adbg.include.linux.user;
Expand Down Expand Up @@ -265,10 +265,10 @@ version (Windows) {
return adbg_oops(AdbgError.os);

// Adjust argv
if (opts.argv) {
if (argv) {
size_t i0, i1 = 1;
while (opts.argv[i0] && i1 < 15)
__argv[i1++] = opts.argv[i0++];
while (argv[i0] && i1 < 15)
__argv[i1++] = argv[i0++];
__argv[i1] = null;
} else {
__argv[1] = null;
Expand All @@ -277,9 +277,9 @@ version (Windows) {

// Adjust envp
//TODO: Is this still valid?
if (opts.envp == null) {
opts.envp = cast(const(char)**)&__envp;
opts.envp[0] = null;
if (envp == null) {
envp = cast(const(char)**)&__envp;
envp[0] = null;
}

// Clone
Expand All @@ -299,20 +299,20 @@ version (Windows) {
return adbg_oops(AdbgError.os);
if (tracee.pid == 0) { // Child process
// Adjust argv
if (opts.argv) {
if (argv) {
size_t i0, i1 = 1;
while (opts.argv[i0] && i1 < 15)
__argv[i1++] = opts.argv[i0++];
while (argv[i0] && i1 < 15)
__argv[i1++] = argv[i0++];
__argv[i1] = null;
} else {
__argv[1] = null;
}
__argv[0] = path;

// Adjust envp
if (opts.envp == null) {
opts.envp = cast(const(char)**)&__envp;
opts.envp[0] = null;
if (envp == null) {
envp = cast(const(char)**)&__envp;
envp[0] = null;
}

// Trace me
Expand Down Expand Up @@ -608,7 +608,7 @@ L_DEBUG_LOOP:
exception.fault_address = 0;
}

tracee.status = AdbgStatus.paused;
tracee.status = AdbgProcStatus.paused;
adbg_exception_translate(&exception, &tracee.pid, &stopsig);
}

Expand Down Expand Up @@ -720,7 +720,7 @@ version (Windows) {
return adbg_debugger_continue(tracee);
} else {
if (ptrace(PT_SINGLESTEP, tracee.pid, null, null) < 0) {
tracee.status = AdbgStatus.idle;
tracee.status = AdbgProcStatus.idle;
return adbg_oops(AdbgError.os);
}

Expand Down
4 changes: 4 additions & 0 deletions src/adbg/self.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/// License: BSD-3-Clause
module adbg.self;

import adbg.include.c.stdlib; // malloc, calloc, free, exit;
import adbg.include.c.stdio; // snprintf;
import adbg.include.c.stdarg;
import adbg.error;
import adbg.debugger.exception;

Expand Down Expand Up @@ -35,6 +38,7 @@ version (Windows) {
import core.sys.posix.signal;
import core.sys.posix.ucontext;
import core.sys.posix.unistd;
import adbg.include.posix.ptrace;

private enum NO_SIGACTION = cast(sigaction_t*)0;
}
Expand Down

0 comments on commit dc923fb

Please sign in to comment.