mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-06 18:13:46 +00:00
Add dbg.wrap for changing want_ptrace at runtime ##debug (#18607)
This commit is contained in:
parent
1721ebf558
commit
f98bdc775f
2
configure
vendored
2
configure
vendored
@ -184,7 +184,7 @@ Optional Features:
|
||||
--disable-loadlibs disable loading plugins
|
||||
--without-dylink disable support for dynamic loading of plugins
|
||||
--without-fork disable fork
|
||||
--without-ptrace-wrap disable ptrace-wrap build
|
||||
--without-ptrace-wrap build ptrace-wrap support needed for the iaito debugger on Linux
|
||||
--with-libr build libr.a and libr.dylib
|
||||
--with-syscapstone force to use system-wide capstone
|
||||
--with-syszip force to use system's libzip and zlib
|
||||
|
@ -30,7 +30,7 @@ ARG_DISABLE LOADLIBS loadlibs disable loading plugins ;
|
||||
|
||||
ARG_WITHOUT WANT_DYLINK dylink disable support for dynamic loading of plugins ;
|
||||
ARG_WITHOUT HAVE_FORK fork disable fork ;
|
||||
ARG_WITHOUT WANT_PTRACE_WRAP ptrace-wrap disable ptrace-wrap build ;
|
||||
ARG_WITHOUT WANT_PTRACE_WRAP ptrace-wrap build ptrace-wrap support needed for the iaito debugger on Linux ;
|
||||
|
||||
ARG_WITH WITH_LIBR libr build libr.a and libr.dylib ;
|
||||
|
||||
|
@ -1517,6 +1517,13 @@ static bool cb_dbg_maxsnapsize(void *user, void *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_dbg_wrap(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
core->io->want_ptrace_wrap = node->i_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_dbg_libs(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
@ -3547,6 +3554,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETI ("stack.delta", 0, "Delta for the stack dump");
|
||||
|
||||
SETCB ("dbg.maxsnapsize", "32M", &cb_dbg_maxsnapsize, "Dont make snapshots of maps bigger than a specific size");
|
||||
SETCB ("dbg.wrap", "false", &cb_dbg_wrap, "Enable the ptrace-wrap abstraction layer (needed for debugging from iaito)");
|
||||
SETCB ("dbg.libs", "", &cb_dbg_libs, "If set stop when loading matching libname");
|
||||
SETBPREF ("dbg.skipover", "false", "Make dso perform a dss (same goes for esil and visual/graph");
|
||||
SETI ("dbg.hwbp", 0, "Set HW or SW breakpoints");
|
||||
|
@ -49,6 +49,9 @@ typedef void * r_ptrace_data_t;
|
||||
typedef int r_ptrace_request_t;
|
||||
typedef void * r_ptrace_data_t;
|
||||
#define R_PTRACE_NODATA NULL
|
||||
#elif __APPLE__
|
||||
typedef int r_ptrace_request_t;
|
||||
typedef int r_ptrace_data_t;
|
||||
#else
|
||||
typedef int r_ptrace_request_t;
|
||||
typedef void *r_ptrace_data_t;
|
||||
@ -121,6 +124,7 @@ typedef struct r_io_t {
|
||||
REvent *event;
|
||||
PrintfCallback cb_printf;
|
||||
RCoreBind corebind;
|
||||
bool want_ptrace_wrap;
|
||||
#if __WINDOWS__
|
||||
struct w32dbg_wrap_instance_t *w32dbg_wrap;
|
||||
#endif
|
||||
|
30
libr/io/io.c
30
libr/io/io.c
@ -647,32 +647,34 @@ static ptrace_wrap_instance *io_ptrace_wrap_instance(RIO *io) {
|
||||
|
||||
R_API long r_io_ptrace(RIO *io, r_ptrace_request_t request, pid_t pid, void *addr, r_ptrace_data_t data) {
|
||||
#if USE_PTRACE_WRAP
|
||||
ptrace_wrap_instance *wrap = io_ptrace_wrap_instance (io);
|
||||
if (!wrap) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
if (io->want_ptrace_wrap) {
|
||||
ptrace_wrap_instance *wrap = io_ptrace_wrap_instance (io);
|
||||
if (!wrap) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
}
|
||||
return ptrace_wrap (wrap, request, pid, addr, data);
|
||||
}
|
||||
return ptrace_wrap (wrap, request, pid, addr, data);
|
||||
#else
|
||||
return ptrace (request, pid, addr, data);
|
||||
#endif
|
||||
return ptrace (request, pid, addr, data);
|
||||
}
|
||||
|
||||
R_API pid_t r_io_ptrace_fork(RIO *io, void (*child_callback)(void *), void *child_callback_user) {
|
||||
#if USE_PTRACE_WRAP
|
||||
ptrace_wrap_instance *wrap = io_ptrace_wrap_instance (io);
|
||||
if (!wrap) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
if (io->want_ptrace_wrap) {
|
||||
ptrace_wrap_instance *wrap = io_ptrace_wrap_instance (io);
|
||||
if (!wrap) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
}
|
||||
return ptrace_wrap_fork (wrap, child_callback, child_callback_user);
|
||||
}
|
||||
return ptrace_wrap_fork (wrap, child_callback, child_callback_user);
|
||||
#else
|
||||
#endif
|
||||
pid_t r = r_sys_fork ();
|
||||
if (r == 0) {
|
||||
child_callback (child_callback_user);
|
||||
}
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API void *r_io_ptrace_func(RIO *io, void *(*func)(void *), void *user) {
|
||||
|
@ -288,10 +288,10 @@ endif
|
||||
|
||||
has_debugger = get_option('debugger')
|
||||
have_ptrace = not ['windows', 'cygwin', 'sunos'].contains(host_machine.system())
|
||||
use_ptrace_wrap = ['linux'].contains(host_machine.system())
|
||||
can_ptrace_wrap = ['linux'].contains(host_machine.system())
|
||||
|
||||
have_ptrace = have_ptrace and has_debugger
|
||||
use_ptrace_wrap = use_ptrace_wrap and has_debugger
|
||||
use_ptrace_wrap = can_ptrace_wrap and has_debugger
|
||||
|
||||
message('HAVE_PTRACE: @0@'.format(have_ptrace))
|
||||
message('USE_PTRACE_WRAP: @0@'.format(use_ptrace_wrap))
|
||||
|
@ -39,6 +39,7 @@ option('use_libuv', type: 'boolean', value: true)
|
||||
option('use_fork', type: 'boolean', value: true)
|
||||
option('use_dylink', type: 'boolean', value: true)
|
||||
option('debugger', type: 'boolean', value: true)
|
||||
option('want_ptrace_wrap', type: 'boolean', value: true)
|
||||
option('nogpl', type: 'boolean', value: false)
|
||||
|
||||
option('use_webui', type: 'boolean', value: false, description: 'install different WebUIs for radare2')
|
||||
|
Loading…
Reference in New Issue
Block a user