34 #include "elf/common.h" 36 #include <asm/ptrace.h> 38 #include <asm/types.h> 39 #include <sys/procfs.h> 40 #include <sys/ucontext.h> 88 static const struct regset s390_64_gregset =
90 s390_64_regmap_gregset,
95 #define S390_PSWM_OFFSET 0 96 #define S390_PSWA_OFFSET 8 101 #define PER_BIT(n) (1UL << (63 - (n))) 102 #define PER_EVENT_BRANCH PER_BIT (32) 103 #define PER_EVENT_IFETCH PER_BIT (33) 104 #define PER_EVENT_STORE PER_BIT (34) 105 #define PER_EVENT_NULLIFICATION PER_BIT (39) 106 #define PER_CONTROL_BRANCH_ADDRESS PER_BIT (40) 107 #define PER_CONTROL_SUSPENSION PER_BIT (41) 108 #define PER_CONTROL_ALTERATION PER_BIT (42) 138 (pswa & 0x7fffffff) | (pswm & 0x80000000));
185 pswm ^= (pswm ^ pswa) & 0x80000000;
239 parea.len =
sizeof (regs);
240 parea.process_addr = (addr_t) ®s;
241 parea.kernel_addr = offsetof (
struct user_regs_struct, psw);
242 if (
ptrace (PTRACE_PEEKUSR_AREA,
tid, (
long) &parea, 0) < 0)
256 parea.len =
sizeof (regs);
257 parea.process_addr = (addr_t) ®s;
258 parea.kernel_addr = offsetof (
struct user_regs_struct, psw);
259 if (
ptrace (PTRACE_PEEKUSR_AREA,
tid, (
long) &parea, 0) < 0)
264 if (
ptrace (PTRACE_POKEUSR_AREA,
tid, (
long) &parea, 0) < 0)
276 parea.len =
sizeof (fpregs);
277 parea.process_addr = (addr_t) &fpregs;
278 parea.kernel_addr = offsetof (
struct user_regs_struct, fp_regs);
279 if (
ptrace (PTRACE_PEEKUSR_AREA,
tid, (
long) &parea, 0) < 0)
293 parea.len =
sizeof (fpregs);
294 parea.process_addr = (addr_t) &fpregs;
295 parea.kernel_addr = offsetof (
struct user_regs_struct, fp_regs);
296 if (
ptrace (PTRACE_PEEKUSR_AREA,
tid, (
long) &parea, 0) < 0)
301 if (
ptrace (PTRACE_POKEUSR_AREA,
tid, (
long) &parea, 0) < 0)
311 int regset_id,
int regsize,
const struct regset *
regset)
313 void *buf = alloca (regsize);
317 iov.iov_len = regsize;
321 if (errno == ENODATA)
335 int regset_id,
int regsize,
const struct regset *
regset)
337 void *buf = alloca (regsize);
341 iov.iov_len = regsize;
357 void *buf = alloca (regsize);
361 iov.iov_len = regsize;
608 parea.len =
sizeof (per_info);
609 parea.process_addr = (addr_t) &per_info;
610 parea.kernel_addr = offsetof (
struct user_regs_struct, per_info);
612 if (
ptrace (PTRACE_PEEKUSR_AREA,
tid, &parea, 0) < 0)
616 " cr9-11: %lx %lx %lx\n" 617 " start, end: %lx %lx\n" 618 " code/ATMID: %x address: %lx PAID: %x\n",
621 per_info.control_regs.words.cr[0],
622 per_info.control_regs.words.cr[1],
623 per_info.control_regs.words.cr[2],
624 per_info.starting_addr,
625 per_info.ending_addr,
626 per_info.lowcore.words.perc_atmid,
627 per_info.lowcore.words.address,
628 per_info.lowcore.words.access_id);
636 per_lowcore_bits per_lowcore;
647 parea.len =
sizeof (per_lowcore);
648 parea.process_addr = (addr_t) & per_lowcore;
649 parea.kernel_addr = offsetof (
struct user_regs_struct, per_info.lowcore);
653 result = (per_lowcore.perc_storage_alteration == 1
654 && per_lowcore.perc_store_real_address == 0);
659 memset (&per_lowcore, 0,
sizeof (per_lowcore));
703 parea.len =
sizeof (per_info);
704 parea.process_addr = (addr_t) & per_info;
705 parea.kernel_addr = offsetof (
struct user_regs_struct, per_info);
709 memset (&per_info, 0,
sizeof (per_info));
710 per_info.single_step = (step != 0);
718 watch_lo_addr = std::min (watch_lo_addr, area->
lo_addr);
719 watch_hi_addr = std::max (watch_hi_addr, area->
hi_addr);
740 watch_lo_addr = std::min (watch_lo_addr, area->
lo_addr);
741 watch_hi_addr = std::max (watch_hi_addr, area->
hi_addr);
748 if (watch_hi_addr == watch_lo_addr)
755 watch_lo_addr = watch_lo_addr > 6 ? watch_lo_addr - 6 : 0;
756 per_info.control_regs.words.cr[0]
763 per_info.starting_addr = watch_lo_addr;
764 per_info.ending_addr = watch_hi_addr;
766 if (
ptrace (PTRACE_POKEUSR_AREA,
tid, &parea, 0) < 0)
861 "Attempt to remove nonexistent watchpoint.\n");
918 "Attempt to remove nonexistent breakpoint.\n");
941 if (errno == 0 && (pswm & 0x100000000ul) != 0)
959 if (endptr - ptr < sizeof_auxv_field * 2)
963 ptr += sizeof_auxv_field;
965 ptr += sizeof_auxv_field;
1069 Set whether to show the PER (debug) hardware state."),
_(
"\ 1070 Show whether to show the PER (debug) hardware state."),
_(
"\ 1071 Use \"on\" to enable, \"off\" to disable.\n\ 1072 If enabled, the PER state is shown after it is changed by GDB,\n\ 1073 and when the inferior triggers a breakpoint or watchpoint."),
struct gdbarch * target_gdbarch(void)
#define S390_V15_LOWER_REGNUM
void supply_fpregset(struct regcache *regcache, const fpregset_t *regp)
static int s390_target_wordsize(void)
static void fetch_fpregs(struct regcache *regcache, int tid)
#define PER_CONTROL_ALTERATION
static int s390_refresh_per_info_cb(struct lwp_info *lp, void *arg)
static void fetch_regs(struct regcache *regcache, int tid)
static int have_regset_tdb
static constexpr ptid_t tid
struct target_desc * tdesc_s390_vx_linux64
const struct target_desc *(* to_read_description)(struct target_ops *ops) TARGET_DEFAULT_RETURN(NULL)
struct target_desc * tdesc_s390x_gs_linux64
#define S390_SYSTEM_CALL_REGNUM
struct target_desc * tdesc_s390_te_linux64
struct arch_lwp_info * lwp_arch_private_info(struct lwp_info *lwp)
void fill_gregset(const struct regcache *regcache, gregset_t *regp, int regno)
struct target_desc * tdesc_s390_linux32v1
int ptid_get_pid(const ptid_t &ptid)
void linux_stop_lwp(struct lwp_info *lwp)
static int s390_refresh_per_info(void)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
static void s390_delete_thread(struct arch_lwp_info *arch_lwp)
static const struct target_desc * s390_read_description(struct target_ops *ops)
void linux_nat_set_new_thread(struct target_ops *t, void(*new_thread)(struct lwp_info *))
VEC_s390_watch_area * watch_areas
struct target_desc * tdesc_s390x_tevx_linux64
static int have_regset_gs
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
static int have_regset_system_call
VEC_s390_watch_area * break_areas
#define S390_R6_UPPER_REGNUM
ptid_t regcache_get_ptid(const struct regcache *regcache)
void * memset(T *s, int c, size_t n)=delete
static struct s390_process_info * s390_add_process(pid_t pid)
static void s390_prepare_to_resume(struct lwp_info *lp)
void regcache_supply_regset(const struct regset *regset, struct regcache *regcache, int regnum, const void *buf, size_t size)
#define VEC_unordered_remove(T, V, I)
#define S390_R2_UPPER_REGNUM
static void s390_linux_new_fork(struct lwp_info *parent, pid_t child_pid)
const struct regset s390_gregset
static struct s390_process_info * s390_find_process_pid(pid_t pid)
static int have_regset_last_break
#define VEC_safe_push(T, V, O)
struct target_desc * tdesc_s390_linux64v2
struct target_desc * tdesc_s390_linux32v2
static void s390_mark_per_info_changed(struct lwp_info *lp)
int(* to_remove_watchpoint)(struct target_ops *, CORE_ADDR, int, enum target_hw_bp_type, struct expression *) TARGET_DEFAULT_RETURN(-1)
int(* to_region_ok_for_hw_watchpoint)(struct target_ops *, CORE_ADDR, int) TARGET_DEFAULT_FUNC(default_region_ok_for_hw_watchpoint)
const struct regset s390_fpregset
int(* to_can_use_hw_breakpoint)(struct target_ops *, enum bptype, int, int) TARGET_DEFAULT_RETURN(0)
#define S390_IS_GREGSET_REGNUM(i)
struct target_desc * tdesc_s390_tevx_linux64
void linux_nat_set_new_fork(struct target_ops *t, linux_nat_new_fork_ftype *new_fork)
static struct s390_debug_reg_state * s390_get_debug_reg_state(pid_t pid)
#define S390_R11_UPPER_REGNUM
struct cmd_list_element * maintenance_set_cmdlist
#define S390_R4_UPPER_REGNUM
void supply_gregset(struct regcache *regcache, const gregset_t *regp)
struct s390_process_info * next
ptid_t ptid_of_lwp(struct lwp_info *lwp)
static int s390_insert_watchpoint(struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond)
#define S390_R7_UPPER_REGNUM
static void store_regset(struct regcache *regcache, int tid, int regset_id, int regsize, const struct regset *regset)
#define VEC_iterate(T, V, I, P)
const struct regset s390_vxrs_low_regset
static int s390_inferior_tid(void)
struct target_ops current_target
thread_state_data_t state
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
const struct regset s390_last_break_regset
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
int target_auxv_search(struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
ptid_t pid_to_ptid(int pid)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void linux_nat_set_prepare_to_resume(struct target_ops *t, void(*prepare_to_resume)(struct lwp_info *))
ptid_t current_lwp_ptid(void)
#define S390_R0_UPPER_REGNUM
#define S390_LAST_BREAK_REGNUM
void regcache_collect_regset(const struct regset *regset, const struct regcache *regcache, int regnum, void *buf, size_t size)
static int s390_auxv_parse(struct target_ops *ops, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
#define S390_R13_UPPER_REGNUM
#define PER_CONTROL_BRANCH_ADDRESS
struct target_desc * tdesc_s390_linux64v1
#define PER_EVENT_NULLIFICATION
void linux_nat_add_target(struct target_ops *t)
int(* to_insert_watchpoint)(struct target_ops *, CORE_ADDR, int, enum target_hw_bp_type, struct expression *) TARGET_DEFAULT_RETURN(-1)
static int s390_remove_watchpoint(struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond)
struct target_desc * tdesc_s390x_vx_linux64
const struct regset s390x_last_break_regset
static void s390_linux_store_inferior_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
const struct regset s390_system_call_regset
struct target_ops * linux_target(void)
long ptid_get_lwp(const ptid_t &ptid)
struct target_desc * tdesc_s390_gs_linux64
int(* to_insert_hw_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_RETURN(-1)
int lwp_is_stopped(struct lwp_info *lwp)
const struct regset s390_vxrs_high_regset
static void s390_forget_process(pid_t pid)
void fill_fpregset(const struct regcache *regcache, fpregset_t *regp, int regno)
static int s390_remove_hw_breakpoint(struct target_ops *self, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
#define S390_ORIG_R2_REGNUM
int(* to_auxv_parse)(struct target_ops *ops, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) TARGET_DEFAULT_FUNC(default_auxv_parse)
#define S390_R3_UPPER_REGNUM
static void s390_new_thread(struct lwp_info *lp)
int(* to_remove_hw_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_RETURN(-1)
static int have_regset_vxrs
static struct s390_process_info * s390_process_info_get(pid_t pid)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
struct target_desc * tdesc_s390x_linux64v2
DEF_VEC_O(s390_watch_area)
static void fetch_regset(struct regcache *regcache, int tid, int regset_id, int regsize, const struct regset *regset)
#define S390_GSEPLA_REGNUM
struct target_desc * tdesc_s390x_linux64v1
#define S390_IS_FPREGSET_REGNUM(i)
const struct regset s390_tdb_regset
#define S390_BC_GSD_REGNUM
static int check_regset(int tid, int regset, int regsize)
#define S390_R10_UPPER_REGNUM
#define S390_IS_TDBREGSET_REGNUM(i)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static struct s390_process_info * s390_process_list
struct target_desc * tdesc_s390_linux32
int(* to_stopped_by_watchpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
#define S390_R5_UPPER_REGNUM
struct target_desc * tdesc_s390x_linux64
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
struct watch_area s390_watch_area
int to_have_continuable_watchpoint
static void s390_show_debug_regs(int tid, const char *where)
#define S390_R15_UPPER_REGNUM
void _initialize_s390_nat(void)
unsigned long long ULONGEST
#define S390_R12_UPPER_REGNUM
static void store_fpregs(const struct regcache *regcache, int tid, int regnum)
static int s390_insert_hw_breakpoint(struct target_ops *self, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
#define S390_V0_LOWER_REGNUM
#define S390_R8_UPPER_REGNUM
void lwp_set_arch_private_info(struct lwp_info *lwp, struct arch_lwp_info *info)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
int lwp_is_stepping(struct lwp_info *lwp)
static int s390_region_ok_for_hw_watchpoint(struct target_ops *self, CORE_ADDR addr, int cnt)
pid_t get_ptrace_pid(ptid_t ptid)
void debug_printf(const char *fmt,...)
void linux_nat_set_forget_process(struct target_ops *t, linux_nat_forget_process_ftype *fn)
#define S390_R14_UPPER_REGNUM
const struct regset s390_gsbc_regset
struct target_desc * tdesc_s390x_te_linux64
struct s390_debug_reg_state state
struct target_desc * tdesc_s390_linux64
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
#define s390_sizeof_tdbregset
struct lwp_info * iterate_over_lwps(ptid_t filter, iterate_over_lwps_ftype callback, void *data)
struct cmd_list_element * maintenance_show_cmdlist
void linux_nat_set_delete_thread(struct target_ops *t, void(*delete_thread)(struct arch_lwp_info *))
enum bfd_endian byte_order
static int s390_can_use_hw_breakpoint(struct target_ops *self, enum bptype type, int cnt, int othertype)
#define HWCAP_S390_HIGH_GPRS
#define S390_R1_UPPER_REGNUM
static void s390_linux_fetch_inferior_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
const struct regset s390_gs_regset
static int s390_stopped_by_watchpoint(struct target_ops *ops)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
#define S390_R9_UPPER_REGNUM
#define S390_BC_GSEPLA_REGNUM
static void store_regs(const struct regcache *regcache, int tid, int regnum)