mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 10:33:30 +00:00
Linux debugger improvements
This commit is contained in:
parent
c04ae7dd64
commit
b5e262a6b9
@ -1,4 +1,4 @@
|
||||
/* radare2 - LGPL - Copyright 2008-2020 - pancake, Jody Frankowski */
|
||||
/* radare2 - LGPL - Copyright 2008-2021 - pancake, Jody Frankowski */
|
||||
|
||||
#include <r_cons.h>
|
||||
#include <r_util.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2019 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2021 - pancake */
|
||||
|
||||
#include <r_userconf.h>
|
||||
#include <r_debug.h>
|
||||
@ -667,7 +667,7 @@ static int bsd_reg_read (RDebug *dbg, int type, ut8* buf, int size) {
|
||||
case R_REG_TYPE_GPR:
|
||||
{
|
||||
R_DEBUG_REG_T regs;
|
||||
memset (®s, 0, sizeof(regs));
|
||||
memset (®s, 0, sizeof (regs));
|
||||
memset (buf, 0, size);
|
||||
#if __NetBSD__ || __OpenBSD__
|
||||
ret = ptrace (PTRACE_GETREGS, pid, (caddr_t)®s, sizeof (regs));
|
||||
@ -681,8 +681,12 @@ static int bsd_reg_read (RDebug *dbg, int type, ut8* buf, int size) {
|
||||
// process exists still.. is because there's a
|
||||
// missing call to 'wait'. and the process is not
|
||||
// yet available to accept more ptrace queries.
|
||||
if (ret != 0) return false;
|
||||
if (sizeof(regs) < size) size = sizeof(regs);
|
||||
if (ret != 0) {
|
||||
return false;
|
||||
}
|
||||
if (sizeof (regs) < size) {
|
||||
size = sizeof (regs);
|
||||
}
|
||||
memcpy (buf, ®s, size);
|
||||
return sizeof(regs);
|
||||
}
|
||||
|
@ -1176,10 +1176,6 @@ int linux_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
|
||||
};
|
||||
ret = r_debug_ptrace (dbg, PTRACE_GETREGSET, pid, 1, &io);
|
||||
// ret = ptrace (PTRACE_GETREGSET, pid, (void*)(size_t)(NT_PRSTATUS), NULL); // &io);
|
||||
if (ret != 0) {
|
||||
r_sys_perror("PTRACE_GETREGSET");
|
||||
return false;
|
||||
}
|
||||
#elif __BSD__ && (__POWERPC__ || __sparc__)
|
||||
ret = r_debug_ptrace (dbg, PTRACE_GETREGS, pid, ®s, NULL);
|
||||
#else
|
||||
@ -1227,8 +1223,8 @@ int linux_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
|
||||
ymm_space[ri*8+rj] = xstate.fpstate._xmm[ri].element[rj];
|
||||
#endif
|
||||
}
|
||||
for (rj=0; rj < 4; rj++) {
|
||||
ymm_space[ri*8+(rj+4)] = xstate.ymmh.ymmh_space[ri*4+rj];
|
||||
for (rj = 0; rj < 4; rj++) {
|
||||
ymm_space[ri * 8 + (rj + 4)] = xstate.ymmh.ymmh_space[ri * 4 + rj];
|
||||
}
|
||||
}
|
||||
size = R_MIN (sizeof (ymm_space), size);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifdef __GLIBC__
|
||||
typedef enum __ptrace_request ptrace_wrap_ptrace_request;
|
||||
#else
|
||||
typedef int ptrace_wrap_ptrace_request;
|
||||
typedef size_t ptrace_wrap_ptrace_request;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
|
@ -117,16 +117,16 @@ typedef struct r_io_t {
|
||||
SdbList *plugins;
|
||||
char *runprofile;
|
||||
char *envprofile;
|
||||
#if USE_PTRACE_WRAP
|
||||
struct ptrace_wrap_instance_t *ptrace_wrap;
|
||||
#endif
|
||||
#if __WINDOWS__
|
||||
struct w32dbg_wrap_instance_t *w32dbg_wrap;
|
||||
#endif
|
||||
char *args;
|
||||
REvent *event;
|
||||
PrintfCallback cb_printf;
|
||||
RCoreBind corebind;
|
||||
#if __WINDOWS__
|
||||
struct w32dbg_wrap_instance_t *w32dbg_wrap;
|
||||
#endif
|
||||
#if USE_PTRACE_WRAP
|
||||
struct ptrace_wrap_instance_t *ptrace_wrap;
|
||||
#endif
|
||||
} RIO;
|
||||
|
||||
typedef struct r_io_desc_t {
|
||||
|
@ -292,6 +292,14 @@ static int __close(RIODesc *desc) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void show_help(void) {
|
||||
eprintf ("Usage: =!cmd args\n"
|
||||
" =!ptrace - use ptrace io\n"
|
||||
" =!mem - use /proc/pid/mem io if possible\n"
|
||||
" =!pid - show targeted pid\n"
|
||||
" =!pid <#> - select new pid\n");
|
||||
}
|
||||
|
||||
static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
RIOPtrace *iop = (RIOPtrace*)fd->data;
|
||||
//printf("ptrace io command (%s)\n", cmd);
|
||||
@ -300,11 +308,7 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
return NULL;
|
||||
}
|
||||
if (!strcmp (cmd, "help")) {
|
||||
eprintf ("Usage: =!cmd args\n"
|
||||
" =!ptrace - use ptrace io\n"
|
||||
" =!mem - use /proc/pid/mem io if possible\n"
|
||||
" =!pid - show targeted pid\n"
|
||||
" =!pid <#> - select new pid\n");
|
||||
show_help ();
|
||||
} else
|
||||
if (!strcmp (cmd, "ptrace")) {
|
||||
close_pidmem (iop);
|
||||
@ -327,7 +331,7 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
return r_str_newf ("%d", iop->pid);
|
||||
}
|
||||
} else {
|
||||
eprintf ("Try: '=!pid'\n");
|
||||
show_help ();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ static void wrap_func(ptrace_wrap_instance *inst) {
|
||||
static void *th_run(ptrace_wrap_instance *inst) {
|
||||
while (1) {
|
||||
sem_wait (&inst->request_sem);
|
||||
|
||||
switch (inst->request.type) {
|
||||
case PTRACE_WRAP_REQUEST_TYPE_STOP:
|
||||
goto stop;
|
||||
@ -94,6 +95,7 @@ static void *th_run(ptrace_wrap_instance *inst) {
|
||||
wrap_func (inst);
|
||||
break;
|
||||
}
|
||||
|
||||
sem_post (&inst->result_sem);
|
||||
}
|
||||
stop:
|
||||
|
@ -9,6 +9,7 @@ printf "\033[33m"
|
||||
echo "Sanitize build script can be configured with the SANITIZE environment variable."
|
||||
echo "Use one of the following words to specify which sanitizers to use:"
|
||||
echo " - address - detect memory errors"
|
||||
echo " - thread - detect thread racing issues"
|
||||
echo " - leak - find memory leaks"
|
||||
echo " - memory - detect uninitialized reads"
|
||||
echo " - undefined - find undefined behaviour"
|
||||
|
Loading…
Reference in New Issue
Block a user