22 #include "elf/common.h"
24 #include <sys/ptrace.h>
26 #include <sys/procfs.h>
87 *child_state = *parent_state;
105 #define AMD64_LINUX_USER64_CS 0x33
110 #define AMD64_LINUX_X32_DS 0x2b
123 static uint64_t xcr0;
124 uint64_t xcr0_features_bits;
138 cs =
ptrace (PTRACE_PEEKUSER, tid,
139 offsetof (
struct user_regs_struct, cs), 0);
143 is_64bit = cs == AMD64_LINUX_USER64_CS;
147 ds =
ptrace (PTRACE_PEEKUSER, tid,
148 offsetof (
struct user_regs_struct, ds), 0);
152 is_x32 = ds == AMD64_LINUX_X32_DS;
154 if (
sizeof (
void *) == 4 && is_64bit && !is_x32)
155 error (
_(
"Can't debug 64-bit process with 32-bit GDB"));
157 #elif HAVE_PTRACE_GETFPXREGS
160 elf_fpxregset_t fpxregs;
162 if (
ptrace (PTRACE_GETFPXREGS, tid, 0, (
int) &fpxregs) < 0)
176 iov.iov_base = xstateregs;
177 iov.iov_len =
sizeof (xstateregs);
181 (
unsigned int) NT_X86_XSTATE, &iov) < 0)
189 /
sizeof (uint64_t))];
200 xcr0_features_bits = 0;
205 switch (xcr0_features_bits)
233 switch (xcr0_features_bits)
264 error (
_(
"Could not enable branch tracing for %s: %s."),
285 error (
_(
"Could not disable branch tracing."));
342 unsigned int desc[4];
348 #ifndef PTRACE_GET_THREAD_AREA
349 #define PTRACE_GET_THREAD_AREA 25
355 *base_addr = desc[1];
struct x86_debug_reg_state * x86_debug_reg_state(pid_t pid)
#define X86_XSTATE_AVX_MASK
struct arch_lwp_info * arch_private
unsigned long x86_linux_dr_get_status(void)
const struct target_desc *(* to_read_description)(struct target_ops *ops) TARGET_DEFAULT_RETURN(NULL)
static const struct btrace_config * x86_linux_btrace_conf(struct target_ops *self, const struct btrace_target_info *btinfo)
#define X86_XSTATE_MPX_MASK
void linux_nat_set_new_thread(struct target_ops *t, void(*new_thread)(struct lwp_info *))
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
static void x86_linux_disable_btrace(struct target_ops *self, struct btrace_target_info *tinfo)
static void(* super_post_startup_inferior)(struct target_ops *self, ptid_t ptid)
struct target_ops * x86_linux_create_target(void)
ps_err_e x86_linux_get_thread_area(pid_t pid, void *addr, unsigned int *base_addr)
enum btrace_error linux_read_btrace(struct btrace_data *btrace, struct btrace_target_info *tinfo, enum btrace_read_type type)
char * target_pid_to_str(ptid_t ptid)
void(* set_control)(unsigned long)
struct target_desc * tdesc_amd64_mpx_linux
struct target_desc * tdesc_x32_linux
struct target_desc * tdesc_amd64_linux
int have_ptrace_getfpxregs
#define PTRACE_GET_THREAD_AREA
void x86_linux_dr_set_control(unsigned long control)
struct x86_dr_low_type x86_dr_low
void linux_nat_set_new_fork(struct target_ops *t, linux_nat_new_fork_ftype *new_fork)
CORE_ADDR(* get_addr)(int)
int debug_registers_changed
void x86_linux_new_thread(struct lwp_info *lwp)
struct target_desc * tdesc_x32_avx512_linux
struct target_desc * tdesc_i386_avx512_linux
int linux_supports_btrace(struct target_ops *ops, enum btrace_format format)
void(* set_addr)(int, CORE_ADDR)
struct target_desc * tdesc_x32_avx_linux
enum tribool have_ptrace_getregset
unsigned long(* get_status)(void)
#define X86_XSTATE_SSE_SIZE
#define gdb_assert_not_reached(message)
const struct btrace_config * linux_btrace_conf(const struct btrace_target_info *tinfo)
void linux_nat_set_prepare_to_resume(struct target_ops *t, void(*prepare_to_resume)(struct lwp_info *))
struct btrace_target_info *(* to_enable_btrace)(struct target_ops *, ptid_t ptid, const struct btrace_config *conf) TARGET_DEFAULT_NORETURN(tcomplain())
static const struct target_desc * x86_linux_read_description(struct target_ops *ops)
void x86_linux_add_target(struct target_ops *t)
#define X86_XSTATE_MPX_AVX512_MASK
void linux_nat_add_target(struct target_ops *t)
static enum btrace_error x86_linux_read_btrace(struct target_ops *self, struct btrace_data *data, struct btrace_target_info *btinfo, enum btrace_read_type type)
const struct btrace_config *(* to_btrace_conf)(struct target_ops *self, const struct btrace_target_info *) TARGET_DEFAULT_RETURN(NULL)
void x86_linux_dr_set_addr(int regnum, CORE_ADDR addr)
struct btrace_config conf
struct target_ops * linux_target(void)
struct target_desc * tdesc_amd64_avx_linux
unsigned long(* get_control)(void)
int ptid_get_pid(ptid_t ptid)
CORE_ADDR x86_linux_dr_get_addr(int regnum)
enum btrace_error(* to_read_btrace)(struct target_ops *self, struct btrace_data *data, struct btrace_target_info *btinfo, enum btrace_read_type type) TARGET_DEFAULT_NORETURN(tcomplain())
#define X86_XSTATE_AVX512_MASK
void x86_forget_process(pid_t pid)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
struct target_desc * tdesc_i386_mpx_linux
struct target_desc * tdesc_amd64_avx512_linux
void(* to_teardown_btrace)(struct target_ops *, struct btrace_target_info *tinfo) TARGET_DEFAULT_NORETURN(tcomplain())
enum btrace_error linux_disable_btrace(struct btrace_target_info *tinfo)
char * safe_strerror(int)
unsigned long x86_linux_dr_get_control(void)
static void x86_linux_teardown_btrace(struct target_ops *self, struct btrace_target_info *tinfo)
static void x86_linux_new_fork(struct lwp_info *parent, pid_t child_pid)
struct target_desc * tdesc_i386_mmx_linux
void x86_set_debug_register_length(int len)
long ptid_get_lwp(ptid_t ptid)
void x86_use_watchpoints(struct target_ops *t)
struct btrace_target_info * linux_enable_btrace(ptid_t ptid, const struct btrace_config *conf)
struct target_desc * tdesc_i386_linux
#define I386_LINUX_XSAVE_XCR0_OFFSET
void linux_nat_set_forget_process(struct target_ops *t, linux_nat_forget_process_ftype *fn)
int(* to_supports_btrace)(struct target_ops *, enum btrace_format) TARGET_DEFAULT_RETURN(0)
void x86_cleanup_dregs(void)
#define target_thread_architecture(ptid)
struct target_desc * tdesc_i386_avx_linux
void(* to_disable_btrace)(struct target_ops *, struct btrace_target_info *tinfo) TARGET_DEFAULT_NORETURN(tcomplain())
void error(const char *fmt,...)
void x86_linux_prepare_to_resume(struct lwp_info *lwp)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
static struct btrace_target_info * x86_linux_enable_btrace(struct target_ops *self, ptid_t ptid, const struct btrace_config *conf)
static void x86_linux_child_post_startup_inferior(struct target_ops *self, ptid_t ptid)
void(* to_post_startup_inferior)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
#define X86_XSTATE_ALL_MASK