GDBserver
Classes | Macros | Typedefs | Functions | Variables
linux-aarch64-low.c File Reference
#include "server.h"
#include "linux-low.h"
#include "elf/common.h"
#include <signal.h>
#include <sys/user.h>
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include <sys/uio.h>
#include "gdb_proc_service.h"

Go to the source code of this file.

Classes

struct  aarch64_debug_reg_state
 
struct  arch_process_info
 
struct  arch_lwp_info
 
struct  aarch64_dr_update_callback_param
 

Macros

#define AARCH64_X_REGS_NUM   31
 
#define AARCH64_V_REGS_NUM   32
 
#define AARCH64_X0_REGNO   0
 
#define AARCH64_SP_REGNO   31
 
#define AARCH64_PC_REGNO   32
 
#define AARCH64_CPSR_REGNO   33
 
#define AARCH64_V0_REGNO   34
 
#define AARCH64_FPSR_REGNO   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM)
 
#define AARCH64_FPCR_REGNO   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 1)
 
#define AARCH64_NUM_REGS   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 2)
 
#define AARCH64_HBP_MAX_NUM   16
 
#define AARCH64_HWP_MAX_NUM   16
 
#define AARCH64_HBP_ALIGNMENT   4
 
#define AARCH64_HWP_ALIGNMENT   8
 
#define AARCH64_HWP_MAX_LEN_PER_REG   8
 
#define DR_MARK_ALL_CHANGED(x, m)
 
#define DR_MARK_N_CHANGED(x, n)
 
#define DR_CLEAR_CHANGED(x)
 
#define DR_HAS_CHANGED(x)   ((x) != 0)
 
#define DR_N_HAS_CHANGED(x, n)   ((x) & ((dr_changed_t)1 << (n)))
 
#define aarch64_breakpoint_len   4
 
#define DR_CONTROL_ENABLED(ctrl)   (((ctrl) & 0x1) == 1)
 
#define DR_CONTROL_LENGTH(ctrl)   (((ctrl) >> 5) & 0xff)
 
#define AARCH64_DEBUG_NUM_SLOTS(x)   ((x) & 0xff)
 
#define AARCH64_DEBUG_ARCH(x)   (((x) >> 8) & 0xff)
 
#define AARCH64_DEBUG_ARCH_V8   0x6
 

Typedefs

typedef unsigned long long dr_changed_t
 

Functions

void init_registers_aarch64 (void)
 
static int aarch64_cannot_store_register (int regno)
 
static int aarch64_cannot_fetch_register (int regno)
 
static void aarch64_fill_gregset (struct regcache *regcache, void *buf)
 
static void aarch64_store_gregset (struct regcache *regcache, const void *buf)
 
static void aarch64_fill_fpregset (struct regcache *regcache, void *buf)
 
static void aarch64_store_fpregset (struct regcache *regcache, const void *buf)
 
static CORE_ADDR aarch64_get_pc (struct regcache *regcache)
 
static void aarch64_set_pc (struct regcache *regcache, CORE_ADDR pc)
 
static int aarch64_breakpoint_at (CORE_ADDR where)
 
static void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, const char *func, CORE_ADDR addr, int len, enum target_hw_bp_type type)
 
static void aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
 
static unsigned int aarch64_watchpoint_length (unsigned int ctrl)
 
static unsigned int aarch64_point_encode_ctrl_reg (enum target_hw_bp_type type, int len)
 
static int aarch64_point_is_aligned (int is_watchpoint, CORE_ADDR addr, int len)
 
static void aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p, int *aligned_len_p, CORE_ADDR *next_addr_p, int *next_len_p)
 
static void aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, int tid, int watchpoint)
 
static int debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
 
void aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state, int is_watchpoint, unsigned int idx)
 
static struct aarch64_debug_reg_stateaarch64_get_debug_reg_state ()
 
static int aarch64_dr_state_insert_one_point (struct aarch64_debug_reg_state *state, enum target_hw_bp_type type, CORE_ADDR addr, int len)
 
static int aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state, enum target_hw_bp_type type, CORE_ADDR addr, int len)
 
static int aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert)
 
static int aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert)
 
static int aarch64_handle_unaligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert)
 
static int aarch64_handle_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert)
 
static int aarch64_supports_z_point_type (char z_type)
 
static int aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int len, struct raw_breakpoint *bp)
 
static int aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int len, struct raw_breakpoint *bp)
 
static CORE_ADDR aarch64_stopped_data_address (void)
 
static int aarch64_stopped_by_watchpoint (void)
 
ps_err_e ps_get_thread_area (const struct ps_prochandle *ph, lwpid_t lwpid, int idx, void **base)
 
static struct arch_process_infoaarch64_linux_new_process (void)
 
static void aarch64_linux_new_thread (struct lwp_info *lwp)
 
static void aarch64_linux_new_fork (struct process_info *parent, struct process_info *child)
 
static void aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 
static void aarch64_arch_setup (void)
 
static const struct regs_infoaarch64_regs_info (void)
 
void initialize_low_arch (void)
 

Variables

const struct target_desctdesc_aarch64
 
static int aarch64_regmap []
 
static int aarch64_num_bp_regs
 
static int aarch64_num_wp_regs
 
int debug_threads
 
static const gdb_byte aarch64_breakpoint [] = {0x00, 0x00, 0x20, 0xd4}
 
static struct regset_info aarch64_regsets []
 
static struct regsets_info aarch64_regsets_info
 
static struct usrregs_info aarch64_usrregs_info
 
static struct regs_info regs_info
 
struct linux_target_ops the_low_target
 

Macro Definition Documentation

#define aarch64_breakpoint_len   4

Definition at line 298 of file linux-aarch64-low.c.

Referenced by aarch64_breakpoint_at().

#define AARCH64_CPSR_REGNO   33

Definition at line 47 of file linux-aarch64-low.c.

Referenced by aarch64_fill_gregset(), and aarch64_store_gregset().

#define AARCH64_DEBUG_ARCH (   x)    (((x) >> 8) & 0xff)

Definition at line 1212 of file linux-aarch64-low.c.

Referenced by aarch64_arch_setup().

#define AARCH64_DEBUG_ARCH_V8   0x6

Definition at line 1213 of file linux-aarch64-low.c.

Referenced by aarch64_arch_setup().

#define AARCH64_DEBUG_NUM_SLOTS (   x)    ((x) & 0xff)

Definition at line 1211 of file linux-aarch64-low.c.

Referenced by aarch64_arch_setup().

#define AARCH64_FPCR_REGNO   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 1)

Definition at line 50 of file linux-aarch64-low.c.

Referenced by aarch64_fill_fpregset(), and aarch64_store_fpregset().

#define AARCH64_FPSR_REGNO   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM)

Definition at line 49 of file linux-aarch64-low.c.

Referenced by aarch64_fill_fpregset(), and aarch64_store_fpregset().

#define AARCH64_HBP_ALIGNMENT   4

Definition at line 106 of file linux-aarch64-low.c.

Referenced by aarch64_point_is_aligned().

#define AARCH64_HBP_MAX_NUM   16

Definition at line 89 of file linux-aarch64-low.c.

Referenced by aarch64_arch_setup(), and aarch64_init_debug_reg_state().

#define AARCH64_HWP_ALIGNMENT   8

Definition at line 107 of file linux-aarch64-low.c.

Referenced by aarch64_align_watchpoint(), and aarch64_point_is_aligned().

#define AARCH64_HWP_MAX_LEN_PER_REG   8

Definition at line 112 of file linux-aarch64-low.c.

Referenced by aarch64_align_watchpoint().

#define AARCH64_HWP_MAX_NUM   16

Definition at line 90 of file linux-aarch64-low.c.

Referenced by aarch64_arch_setup(), and aarch64_init_debug_reg_state().

#define AARCH64_NUM_REGS   (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 2)
#define AARCH64_PC_REGNO   32

Definition at line 46 of file linux-aarch64-low.c.

Referenced by aarch64_fill_gregset(), and aarch64_store_gregset().

#define AARCH64_SP_REGNO   31

Definition at line 45 of file linux-aarch64-low.c.

Referenced by aarch64_fill_gregset(), and aarch64_store_gregset().

#define AARCH64_V0_REGNO   34

Definition at line 48 of file linux-aarch64-low.c.

Referenced by aarch64_fill_fpregset(), and aarch64_store_fpregset().

#define AARCH64_V_REGS_NUM   32

Definition at line 43 of file linux-aarch64-low.c.

Referenced by aarch64_fill_fpregset(), and aarch64_store_fpregset().

#define AARCH64_X0_REGNO   0

Definition at line 44 of file linux-aarch64-low.c.

Referenced by aarch64_fill_gregset(), and aarch64_store_gregset().

#define AARCH64_X_REGS_NUM   31

Definition at line 42 of file linux-aarch64-low.c.

Referenced by aarch64_fill_gregset(), and aarch64_store_gregset().

#define DR_CLEAR_CHANGED (   x)
Value:
do \
{ \
(x) = 0; \
} while (0)

Definition at line 150 of file linux-aarch64-low.c.

Referenced by aarch64_linux_prepare_to_resume().

#define DR_CONTROL_ENABLED (   ctrl)    (((ctrl) & 0x1) == 1)

Definition at line 381 of file linux-aarch64-low.c.

Referenced by aarch64_stopped_data_address().

#define DR_CONTROL_LENGTH (   ctrl)    (((ctrl) >> 5) & 0xff)

Definition at line 382 of file linux-aarch64-low.c.

Referenced by aarch64_watchpoint_length().

#define DR_HAS_CHANGED (   x)    ((x) != 0)

Definition at line 156 of file linux-aarch64-low.c.

Referenced by aarch64_linux_prepare_to_resume().

#define DR_MARK_ALL_CHANGED (   x,
 
)
Value:
do \
{ \
gdb_assert (sizeof ((x)) * 8 >= (m)); \
(x) = (((dr_changed_t)1 << (m)) - 1); \
} while (0)
unsigned long long dr_changed_t

Definition at line 137 of file linux-aarch64-low.c.

Referenced by aarch64_linux_new_thread().

#define DR_MARK_N_CHANGED (   x,
 
)
Value:
do \
{ \
(x) |= ((dr_changed_t)1 << (n)); \
} while (0)
unsigned long long dr_changed_t

Definition at line 144 of file linux-aarch64-low.c.

Referenced by debug_reg_change_callback().

#define DR_N_HAS_CHANGED (   x,
 
)    ((x) & ((dr_changed_t)1 << (n)))

Definition at line 157 of file linux-aarch64-low.c.

Typedef Documentation

typedef unsigned long long dr_changed_t

Definition at line 133 of file linux-aarch64-low.c.

Function Documentation

static void aarch64_align_watchpoint ( CORE_ADDR  addr,
int  len,
CORE_ADDR aligned_addr_p,
int *  aligned_len_p,
CORE_ADDR next_addr_p,
int *  next_len_p 
)
static
static void aarch64_arch_setup ( void  )
static
static int aarch64_breakpoint_at ( CORE_ADDR  where)
static
static int aarch64_cannot_fetch_register ( int  regno)
static

Definition at line 221 of file linux-aarch64-low.c.

References AARCH64_NUM_REGS.

static int aarch64_cannot_store_register ( int  regno)
static

Definition at line 215 of file linux-aarch64-low.c.

References AARCH64_NUM_REGS.

static int aarch64_dr_state_insert_one_point ( struct aarch64_debug_reg_state state,
enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len 
)
static
static int aarch64_dr_state_remove_one_point ( struct aarch64_debug_reg_state state,
enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len 
)
static
static void aarch64_fill_fpregset ( struct regcache regcache,
void *  buf 
)
static
static void aarch64_fill_gregset ( struct regcache regcache,
void *  buf 
)
static
static struct aarch64_debug_reg_state* aarch64_get_debug_reg_state ( )
static
static CORE_ADDR aarch64_get_pc ( struct regcache regcache)
static

Definition at line 281 of file linux-aarch64-low.c.

References collect_register_by_name(), debug_printf(), and debug_threads.

static int aarch64_handle_aligned_watchpoint ( enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len,
int  is_insert 
)
static
static int aarch64_handle_breakpoint ( enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len,
int  is_insert 
)
static
static int aarch64_handle_unaligned_watchpoint ( enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len,
int  is_insert 
)
static
static int aarch64_handle_watchpoint ( enum target_hw_bp_type  type,
CORE_ADDR  addr,
int  len,
int  is_insert 
)
static
static void aarch64_init_debug_reg_state ( struct aarch64_debug_reg_state state)
static
static int aarch64_insert_point ( enum raw_bkpt_type  type,
CORE_ADDR  addr,
int  len,
struct raw_breakpoint bp 
)
static
static void aarch64_linux_new_fork ( struct process_info parent,
struct process_info child 
)
static
static struct arch_process_info* aarch64_linux_new_process ( void  )
static
static void aarch64_linux_new_thread ( struct lwp_info lwp)
static
static void aarch64_linux_prepare_to_resume ( struct lwp_info lwp)
static
static void aarch64_linux_set_debug_regs ( const struct aarch64_debug_reg_state state,
int  tid,
int  watchpoint 
)
static
void aarch64_notify_debug_reg_change ( const struct aarch64_debug_reg_state state,
int  is_watchpoint,
unsigned int  idx 
)
static unsigned int aarch64_point_encode_ctrl_reg ( enum target_hw_bp_type  type,
int  len 
)
static
static int aarch64_point_is_aligned ( int  is_watchpoint,
CORE_ADDR  addr,
int  len 
)
static
static const struct regs_info* aarch64_regs_info ( void  )
static

Definition at line 1302 of file linux-aarch64-low.c.

References regs_info.

static int aarch64_remove_point ( enum raw_bkpt_type  type,
CORE_ADDR  addr,
int  len,
struct raw_breakpoint bp 
)
static
static void aarch64_set_pc ( struct regcache regcache,
CORE_ADDR  pc 
)
static

Definition at line 292 of file linux-aarch64-low.c.

References supply_register_by_name().

static void aarch64_show_debug_reg_state ( struct aarch64_debug_reg_state state,
const char *  func,
CORE_ADDR  addr,
int  len,
enum target_hw_bp_type  type 
)
static
static int aarch64_stopped_by_watchpoint ( void  )
static

Definition at line 1081 of file linux-aarch64-low.c.

References aarch64_stopped_data_address().

static CORE_ADDR aarch64_stopped_data_address ( void  )
static
static void aarch64_store_fpregset ( struct regcache regcache,
const void *  buf 
)
static
static void aarch64_store_gregset ( struct regcache regcache,
const void *  buf 
)
static
static int aarch64_supports_z_point_type ( char  z_type)
static
static unsigned int aarch64_watchpoint_length ( unsigned int  ctrl)
inlinestatic

Definition at line 392 of file linux-aarch64-low.c.

References DR_CONTROL_LENGTH.

Referenced by aarch64_stopped_data_address().

static int debug_reg_change_callback ( struct inferior_list_entry entry,
void *  ptr 
)
static
void init_registers_aarch64 ( void  )

Referenced by initialize_low_arch().

void initialize_low_arch ( void  )

Definition at line 1336 of file linux-aarch64-low.c.

Referenced by initialize_low().

ps_err_e ps_get_thread_area ( const struct ps_prochandle ph,
lwpid_t  lwpid,
int  idx,
void **  base 
)

Definition at line 1092 of file linux-aarch64-low.c.

References PS_ERR, PS_OK, and PTRACE_GETREGSET.

Variable Documentation

const gdb_byte aarch64_breakpoint[] = {0x00, 0x00, 0x20, 0xd4}
static

Definition at line 303 of file linux-aarch64-low.c.

Referenced by aarch64_breakpoint_at().

int aarch64_num_bp_regs
static
int aarch64_num_wp_regs
static
int aarch64_regmap[]
static
Initial value:
=
{
0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8,
16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8,
24*8, 25*8, 26*8, 27*8, 28*8,
29*8,
30*8,
31*8,
32*8,
33*8,
0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16,
16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16,
24*16, 25*16, 26*16, 27*16, 28*16, 29*16, 30*16, 31*16
}

Definition at line 55 of file linux-aarch64-low.c.

struct regset_info aarch64_regsets[]
static
Initial value:
=
{
sizeof (struct user_pt_regs), GENERAL_REGS,
sizeof (struct user_fpsimd_state), FP_REGS,
},
{ 0, 0, 0, -1, -1, NULL, NULL }
}
static void aarch64_store_gregset(struct regcache *regcache, const void *buf)
static void aarch64_fill_gregset(struct regcache *regcache, void *buf)
static void aarch64_fill_fpregset(struct regcache *regcache, void *buf)
#define PTRACE_SETREGSET
Definition: linux-ptrace.h:51
#define PTRACE_GETREGSET
Definition: linux-ptrace.h:47
static void aarch64_store_fpregset(struct regcache *regcache, const void *buf)

Definition at line 1269 of file linux-aarch64-low.c.

struct regsets_info aarch64_regsets_info
static
Initial value:
=
{
0,
NULL,
}
static struct regset_info aarch64_regsets[]

Definition at line 1281 of file linux-aarch64-low.c.

struct usrregs_info aarch64_usrregs_info
static
Initial value:
=
{
}
static int aarch64_regmap[]
#define AARCH64_NUM_REGS

Definition at line 1288 of file linux-aarch64-low.c.

int debug_threads

Definition at line 24 of file debug.c.

Referenced by aarch64_get_pc().

struct regs_info regs_info
static
Initial value:
=
{
NULL,
}
static struct regsets_info aarch64_regsets_info
static struct usrregs_info aarch64_usrregs_info

Definition at line 1294 of file linux-aarch64-low.c.

Referenced by aarch64_regs_info().

const struct target_desc* tdesc_aarch64

Referenced by aarch64_arch_setup().

struct linux_target_ops the_low_target
Initial value:
=
{
NULL,
(const unsigned char *) &aarch64_breakpoint,
NULL,
0,
NULL,
NULL,
NULL,
}
static void aarch64_linux_new_thread(struct lwp_info *lwp)
static int aarch64_cannot_fetch_register(int regno)
static CORE_ADDR aarch64_stopped_data_address(void)
static int aarch64_supports_z_point_type(char z_type)
static void aarch64_arch_setup(void)
static struct arch_process_info * aarch64_linux_new_process(void)
static int aarch64_breakpoint_at(CORE_ADDR where)
static CORE_ADDR aarch64_get_pc(struct regcache *regcache)
static const gdb_byte aarch64_breakpoint[]
static int aarch64_cannot_store_register(int regno)
#define aarch64_breakpoint_len
static void aarch64_linux_new_fork(struct process_info *parent, struct process_info *child)
static void aarch64_set_pc(struct regcache *regcache, CORE_ADDR pc)
static int aarch64_remove_point(enum raw_bkpt_type type, CORE_ADDR addr, int len, struct raw_breakpoint *bp)
static int aarch64_stopped_by_watchpoint(void)
static const struct regs_info * aarch64_regs_info(void)
static void aarch64_linux_prepare_to_resume(struct lwp_info *lwp)
static int aarch64_insert_point(enum raw_bkpt_type type, CORE_ADDR addr, int len, struct raw_breakpoint *bp)

Definition at line 1307 of file linux-aarch64-low.c.

Referenced by add_lwp(), can_hardware_single_step(), check_stopped_by_breakpoint(), check_stopped_by_watchpoint(), child_add_thread(), child_fetch_inferior_registers(), child_store_inferior_registers(), do_attach(), do_initial_child_stuff(), get_pc(), handle_extended_wait(), initialize_low(), linux_add_process(), linux_detach_one_lwp(), linux_emit_ops(), linux_fast_tracepoint_collecting(), linux_fetch_registers(), linux_get_min_fast_tracepoint_insn_len(), linux_insert_point(), linux_install_fast_tracepoint_jump_pad(), linux_low_filter_event(), linux_process_qsupported(), linux_read_pc(), linux_remove_point(), linux_resume_one_lwp_throw(), linux_store_registers(), linux_supports_range_stepping(), linux_supports_tracepoints(), linux_supports_z_point_type(), linux_wait_1(), linux_write_pc(), maybe_move_out_of_jump_pad(), nto_fetch_registers(), nto_store_registers(), siginfo_fixup(), start_step_over(), supports_breakpoints(), supports_fast_tracepoints(), thread_still_has_status_pending_p(), win32_get_thread_context(), win32_insert_point(), win32_prepare_to_resume(), win32_remove_point(), win32_resume(), win32_stopped_by_watchpoint(), win32_stopped_data_address(), and win32_supports_z_point_type().