mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-01-11 03:23:43 +01:00
Code to read/write user memory on FreeBSD
This commit is contained in:
parent
d11456ffbf
commit
cf6ae3548f
2 changed files with 39 additions and 0 deletions
14
configure.in
14
configure.in
|
@ -59,6 +59,20 @@ AC_CHECK_DECLS(PTRACE_POKEUSER, [], [],
|
|||
#endif
|
||||
#include <sys/ptrace.h>
|
||||
])
|
||||
AC_CHECK_DECLS(PTRACE_POKEDATA, [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/ptrace.h>
|
||||
])
|
||||
AC_CHECK_DECLS(PT_IO, [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/ptrace.h>
|
||||
])
|
||||
AC_CHECK_DECLS(PT_GETFPREGS, [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_TYPES_H
|
||||
|
|
|
@ -25,6 +25,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|||
|
||||
#include "_UPT_internal.h"
|
||||
|
||||
#if HAVE_DECL_PTRACE_POKEDATA || HAVE_TTRACE
|
||||
int
|
||||
_UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val,
|
||||
int write, void *arg)
|
||||
|
@ -57,3 +58,27 @@ _UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val,
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#elif HAVE_DECL_PT_IO
|
||||
int
|
||||
_UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val,
|
||||
int write, void *arg)
|
||||
{
|
||||
struct UPT_info *ui = arg;
|
||||
pid_t pid = ui->pid;
|
||||
struct ptrace_io_desc iod;
|
||||
|
||||
iod.piod_offs = (void *)addr;
|
||||
iod.piod_addr = val;
|
||||
iod.piod_len = sizeof(*val);
|
||||
iod.piod_op = write ? PIOD_WRITE_D : PIOD_READ_D;
|
||||
if (write)
|
||||
Debug (16, "mem[%lx] <- %lx\n", (long) addr, (long) *val);
|
||||
if (ptrace(PT_IO, pid, (caddr_t)&iod, 0) == -1)
|
||||
return -UNW_EINVAL;
|
||||
if (!write)
|
||||
Debug (16, "mem[%lx] -> %lx\n", (long) addr, (long) *val);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#error Fix me
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue