27#include "elf/common.h"
30#include <sys/ptrace.h>
31#include <machine/armreg.h>
32#include <machine/reg.h>
40#if __FreeBSD_version >= 1400005
43#include <unordered_set>
73 void probe_debug_regs (
int pid);
74 static bool debug_regs_probed;
106 store_register_set<struct reg> (
regcache,
regnum, PT_GETREGS, PT_SETREGS,
129bool aarch64_fbsd_nat_target::debug_regs_probed;
133static std::unordered_set<lwpid_t> aarch64_debug_pending_threads;
147 if (siginfo.si_signo != SIGTRAP
148 || siginfo.si_code != TRAP_TRACE
149 || siginfo.si_trapno != EXCP_WATCHPT_EL0)
152 const CORE_ADDR addr_trap = (CORE_ADDR) siginfo.si_addr;
181 if (siginfo.si_signo != SIGTRAP
182 || siginfo.si_code != TRAP_TRACE
183 || siginfo.si_trapno != EXCP_WATCHPT_EL0)
200aarch64_fbsd_nat_target::probe_debug_regs (
int pid)
202 if (!debug_regs_probed)
206 debug_regs_probed =
true;
212 switch (reg.db_debug_ver)
226 warning (_(
"Unexpected number of hardware breakpoint registers"
227 " reported by ptrace, got %d, expected %d."),
234 warning (_(
"Unexpected number of hardware watchpoint registers"
235 " reported by ptrace, got %d, expected %d."),
249 probe_debug_regs (ptid.pid ());
259 probe_debug_regs (
pid);
273 if (parent_state ==
nullptr)
284 *child_state = *parent_state;
296 if (tp->
ptid.lwp_p ())
297 aarch64_debug_pending_threads.emplace (tp->
ptid.lwp ());
306 gdb_assert(tp->
ptid.lwp_p ());
307 aarch64_debug_pending_threads.erase (tp->
ptid.lwp ());
315 gdb_assert(tp->
ptid.lwp_p ());
317 if (aarch64_debug_pending_threads.erase (tp->
ptid.lwp ()) == 0)
322 gdb_assert(state !=
nullptr);
325 memset (®, 0,
sizeof(reg));
328 reg.db_breakregs[i].dbr_addr = state->
dr_addr_bp[i];
329 reg.db_breakregs[i].dbr_ctrl = state->
dr_ctrl_bp[i];
333 reg.db_watchregs[i].dbw_addr = state->
dr_addr_wp[i];
334 reg.db_watchregs[i].dbw_ctrl = state->
dr_ctrl_wp[i];
337 error (_(
"Failed to set hardware debug registers"));
static aarch64_fbsd_nat_target the_aarch64_fbsd_nat_target
void aarch64_notify_debug_reg_change(ptid_t ptid, int is_watchpoint, unsigned int idx)
void _initialize_aarch64_fbsd_nat()
const struct regset aarch64_fbsd_fpregset
const struct regset aarch64_fbsd_gregset
const struct regset aarch64_fbsd_tls_regset
#define AARCH64_HBP_MAX_NUM
#define AARCH64_DEBUG_ARCH_V8_1
#define AARCH64_DEBUG_ARCH_V8_4
#define AARCH64_DEBUG_ARCH_V8
#define AARCH64_HWP_MAX_NUM
#define AARCH64_DEBUG_ARCH_V8_2
void aarch64_initialize_hw_point()
struct aarch64_debug_reg_state * aarch64_lookup_debug_reg_state(pid_t pid)
struct aarch64_debug_reg_state * aarch64_get_debug_reg_state(pid_t pid)
bool aarch64_stopped_data_address(const struct aarch64_debug_reg_state *state, CORE_ADDR addr_trap, CORE_ADDR *addr_p)
void aarch64_remove_debug_reg_state(pid_t pid)
const target_desc * aarch64_read_description(const aarch64_features &features)
bool is_watchpoint(const struct breakpoint *bpt)
size_t have_regset(ptid_t ptid, int note)
virtual void low_new_fork(ptid_t parent, pid_t child)
void post_startup_inferior(ptid_t) override
virtual void low_delete_thread(thread_info *)
virtual void low_prepare_to_resume(thread_info *)
void post_attach(int) override
bool fbsd_nat_get_siginfo(ptid_t ptid, siginfo_t *siginfo)
#define ptrace(request, pid, addr, data)
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 add_inf_child_target(inf_child_target *target)
struct inferior * current_inferior(void)
CORE_ADDR dr_addr_bp[AARCH64_HBP_MAX_NUM]
unsigned int dr_ctrl_wp[AARCH64_HWP_MAX_NUM]
CORE_ADDR dr_addr_wp[AARCH64_HWP_MAX_NUM]
unsigned int dr_ctrl_bp[AARCH64_HBP_MAX_NUM]
void store_registers(struct regcache *, int) override
void fetch_registers(struct regcache *, int) override
const struct target_desc * read_description() override
virtual bool stopped_by_watchpoint() TARGET_DEFAULT_RETURN(false)
virtual bool stopped_data_address(CORE_ADDR *) TARGET_DEFAULT_RETURN(false)
virtual bool stopped_by_hw_breakpoint() TARGET_DEFAULT_RETURN(false)
virtual bool supports_stopped_by_hw_breakpoint() TARGET_DEFAULT_RETURN(false)