diff --git a/app/common.d b/app/common.d index d09e254..1ab2686 100644 --- a/app/common.d +++ b/app/common.d @@ -24,9 +24,9 @@ none, invalidParameter, invalidCommand, // or action or sub-command - couldntLoad, - noHelp, - notPaused, + unavailable, + loadFailed, + pauseRequired, } // Platforms diff --git a/app/ui/cmd.d b/app/ui/cmd.d index 7690a35..cf3b08b 100644 --- a/app/ui/cmd.d +++ b/app/ui/cmd.d @@ -192,7 +192,7 @@ if (adbg_load(argv[1], argc > 2 ? argv + 2: null)) { printerror; - return AppError.couldntLoad; + return AppError.loadFailed; } printf("Program '%s' loaded\n", argv[1]); @@ -213,12 +213,18 @@ int cmd_c_r(int argc, const(char) **argv) { if (paused == false) { puts("No program loaded or not paused"); - return AppError.notPaused; + return AppError.pauseRequired; } thread_context_t ctx = void; adbg_ctx_init(&ctx); adbg_ctx_get(&ctx); + + if (ctx.count == 0) { + puts("No registers available"); + return AppError.unavailable; + } + int m = ctx.count; register_t *r = ctx.items.ptr; const(char) *reg = argv[1]; @@ -261,7 +267,7 @@ continue; if (comm.help == null) { puts("Command has no help article available"); - return AppError.noHelp; + return AppError.unavailable; } printf("COMMAND\n\t%s - %s\n\nSYNOPSIS\n\t%s %s\n\n", comm.str, comm.desc, diff --git a/src/adbg/dbg/context.d b/src/adbg/dbg/context.d index cd9612b..6311f7b 100644 --- a/src/adbg/dbg/context.d +++ b/src/adbg/dbg/context.d @@ -86,25 +86,36 @@ WOW64_CONTEXT winctxwow64 = void; if (g_debuggee.wow64) { winctxwow64.ContextFlags = CONTEXT_ALL; - Wow64GetThreadContext(g_debuggee.htid, &winctxwow64); + if (Wow64GetThreadContext(g_debuggee.htid, &winctxwow64) == FALSE) { + ctx.count = 0; + return; + } adbg_ctx_os_wow64(ctx, &winctxwow64); } else { winctx.ContextFlags = CONTEXT_ALL; - GetThreadContext(g_debuggee.htid, &winctx); + if (GetThreadContext(g_debuggee.htid, &winctx)) { + ctx.count = 0; + return; + } adbg_ctx_os(ctx, &winctx); } } else { winctx.ContextFlags = CONTEXT_ALL; - GetThreadContext(g_debuggee.htid, &winctx); + if (GetThreadContext(g_debuggee.htid, &winctx)) { + ctx.count = 0; + return; + } adbg_ctx_os(ctx, &winctx); } } else version (Posix) { + //TODO: PTRACE_GETFPREGS user_regs_struct u = void; - if (ptrace(PTRACE_GETREGS, g_debuggee.pid, null, &u) < 0) + if (ptrace(PTRACE_GETREGS, g_debuggee.pid, null, &u) < 0) { ctx.count = 0; - else - adbg_ctx_os(ctx, &u); + return; + } + adbg_ctx_os(ctx, &u); } } diff --git a/src/adbg/dbg/debugger.d b/src/adbg/dbg/debugger.d index 224b0d0..5755286 100644 --- a/src/adbg/dbg/debugger.d +++ b/src/adbg/dbg/debugger.d @@ -508,10 +508,6 @@ adbg_ex_dbg(&e, g_debuggee.pid, chld_signo); -// iovec v = void; -// if (ptrace(PTRACE_GETREGSET, g_pid, NT_PRSTATUS, &v)) -// return errno; - with (AdbgAction) switch (userfunc(&e)) { case exit: diff --git a/src/adbg/sys/posix/ptrace.d b/src/adbg/sys/posix/ptrace.d index ee80918..e3582d5 100644 --- a/src/adbg/sys/posix/ptrace.d +++ b/src/adbg/sys/posix/ptrace.d @@ -349,7 +349,7 @@ * and system call tracing. * * Params: - * request = See PTRACE_* enumeration values + * req = PTRACE_* request * pid = Process ID number * addr = Memory pointer * data = Data pointer @@ -357,4 +357,4 @@ * Returns: 0 on success; -1 on error. For PTRACE_PEEK requests, check errno * first */ -c_long ptrace(int request, ...); \ No newline at end of file +c_long ptrace(int req, ...); \ No newline at end of file