22 #include "elf/common.h" 26 #include <sys/procfs.h> 77 *child_state = *parent_state;
95 #define AMD64_LINUX_USER64_CS 0x33 100 #define AMD64_LINUX_X32_DS 0x2b 113 static uint64_t xcr0;
114 uint64_t xcr0_features_bits;
129 offsetof (
struct user_regs_struct, cs), 0);
133 is_64bit = cs == AMD64_LINUX_USER64_CS;
138 offsetof (
struct user_regs_struct, ds), 0);
142 is_x32 = ds == AMD64_LINUX_X32_DS;
144 if (
sizeof (
void *) == 4 && is_64bit && !is_x32)
145 error (
_(
"Can't debug 64-bit process with 32-bit GDB"));
147 #elif HAVE_PTRACE_GETFPXREGS 150 elf_fpxregset_t fpxregs;
152 if (
ptrace (PTRACE_GETFPXREGS,
tid, 0, (
int) &fpxregs) < 0)
166 iov.iov_base = xstateregs;
167 iov.iov_len =
sizeof (xstateregs);
171 (
unsigned int) NT_X86_XSTATE, &iov) < 0)
179 /
sizeof (uint64_t))];
190 xcr0_features_bits = 0;
225 error (
_(
"Could not enable branch tracing for %s: %s."),
240 error (
_(
"Could not disable branch tracing."));
297 unsigned int desc[4];
303 #ifndef PTRACE_GET_THREAD_AREA 304 #define PTRACE_GET_THREAD_AREA 25 310 *base_addr = desc[1];
struct x86_debug_reg_state * x86_debug_reg_state(pid_t pid)
struct arch_lwp_info * arch_private
unsigned long x86_linux_dr_get_status(void)
static constexpr ptid_t tid
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)
const struct target_desc * i386_linux_read_description(uint64_t xcr0)
#define X86_XSTATE_SSE_MASK
int ptid_get_pid(const ptid_t &ptid)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
void linux_nat_set_new_thread(struct target_ops *t, void(*new_thread)(struct lwp_info *))
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)
void(* set_control)(unsigned long)
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)
void x86_linux_new_thread(struct lwp_info *lwp)
int linux_supports_btrace(struct target_ops *ops, enum btrace_format format)
void(* set_addr)(int, CORE_ADDR)
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)
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
const target_desc * amd64_linux_read_description(uint64_t xcr0_features_bit, bool is_x32)
struct target_ops * linux_target(void)
long ptid_get_lwp(const ptid_t &ptid)
unsigned long(* get_control)(void)
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_X87_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
void x86_linux_delete_thread(struct arch_lwp_info *arch_lwp)
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)
const char * target_pid_to_str(ptid_t ptid)
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)
void x86_set_debug_register_length(int len)
void x86_use_watchpoints(struct target_ops *t)
struct btrace_target_info * linux_enable_btrace(ptid_t ptid, const struct btrace_config *conf)
#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)
void linux_nat_set_delete_thread(struct target_ops *t, void(*delete_thread)(struct arch_lwp_info *))
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)
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