1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-26 11:21:44 +02:00

Code to read/write user memory on FreeBSD

This commit is contained in:
Konstantin Belousov 2010-03-06 15:04:56 +02:00
parent d11456ffbf
commit cf6ae3548f
2 changed files with 39 additions and 0 deletions

View file

@ -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

View file

@ -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