mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-23 12:03:41 +01:00
Code to read/write fpregs on FreeBSD
This commit is contained in:
parent
905034ce72
commit
d11456ffbf
3 changed files with 60 additions and 3 deletions
18
configure.in
18
configure.in
|
@ -28,7 +28,8 @@ CHECK_ATOMIC_OPS
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
|
AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
|
||||||
ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h)
|
ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
|
||||||
|
sys/procfs.h)
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
|
@ -51,6 +52,21 @@ AC_CHECK_TYPES([sighandler_t], [], [],
|
||||||
#endif
|
#endif
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_CHECK_DECLS(PTRACE_POKEUSER, [], [],
|
||||||
|
[$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
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
])
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
|
|
|
@ -25,6 +25,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
#include "_UPT_internal.h"
|
#include "_UPT_internal.h"
|
||||||
|
|
||||||
|
#if HAVE_DECL_PTRACE_POKEUSER || HAVE_TTRACE
|
||||||
int
|
int
|
||||||
_UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
|
_UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
|
||||||
int write, void *arg)
|
int write, void *arg)
|
||||||
|
@ -64,3 +65,41 @@ _UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#elif HAVE_DECL_PT_GETFPREGS
|
||||||
|
int
|
||||||
|
_UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
|
||||||
|
int write, void *arg)
|
||||||
|
{
|
||||||
|
unw_word_t *wp = (unw_word_t *) val;
|
||||||
|
struct UPT_info *ui = arg;
|
||||||
|
pid_t pid = ui->pid;
|
||||||
|
fpregset_t fpreg;
|
||||||
|
|
||||||
|
if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0]))
|
||||||
|
return -UNW_EBADREG;
|
||||||
|
|
||||||
|
if (ptrace(PT_GETFPREGS, pid, &fpreg, 0) == -1)
|
||||||
|
return -UNW_EBADREG;
|
||||||
|
if (write) {
|
||||||
|
#if defined(__amd64__)
|
||||||
|
memcpy(&fpreg.fpr_xacc[reg], val, sizeof(unw_fpreg_t));
|
||||||
|
#elif defined(__i386__)
|
||||||
|
memcpy(&fpreg.fpr_acc[reg], val, sizeof(unw_fpreg_t));
|
||||||
|
#else
|
||||||
|
#error Fix me
|
||||||
|
#endif
|
||||||
|
if (ptrace(PT_SETFPREGS, pid, &fpreg, 0) == -1)
|
||||||
|
return -UNW_EBADREG;
|
||||||
|
} else
|
||||||
|
#if defined(__amd64__)
|
||||||
|
memcpy(val, &fpreg.fpr_xacc[reg], sizeof(unw_fpreg_t));
|
||||||
|
#elif defined(__i386__)
|
||||||
|
memcpy(val, &fpreg.fpr_acc[reg], sizeof(unw_fpreg_t));
|
||||||
|
#else
|
||||||
|
#error Fix me
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error Fix me
|
||||||
|
#endif
|
||||||
|
|
|
@ -33,6 +33,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#ifdef HAVE_SYS_PROCFS_H
|
||||||
|
#include <sys/procfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libunwind-ptrace.h>
|
#include <libunwind-ptrace.h>
|
||||||
|
@ -40,8 +44,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
|
|
||||||
#include "libunwind_i.h"
|
#include "libunwind_i.h"
|
||||||
|
|
||||||
struct UPT_info
|
struct UPT_info
|
||||||
|
|
Loading…
Reference in a new issue