/* GNU/Linux S/390 specific low level interface, for the remote server
for GDB.
- Copyright (C) 2001-2020 Free Software Foundation, Inc.
+ Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of GDB.
{
public:
+ const regs_info *get_regs_info () override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+ bool supports_z_point_type (char z_type) override;
+
+ bool supports_tracepoints () override;
+
+ bool supports_fast_tracepoints () override;
+
+ int install_fast_tracepoint_jump_pad
+ (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err) override;
+
+ int get_min_fast_tracepoint_insn_len () override;
+
+ void low_collect_ptrace_register (regcache *regcache, int regno,
+ char *buf) override;
+
+ void low_supply_ptrace_register (regcache *regcache, int regno,
+ const char *buf) override;
+
+ struct emit_ops *emit_ops () override;
+
+ int get_ipa_tdesc_idx () override;
+
+protected:
+
+ void low_arch_setup () override;
+
+ bool low_cannot_fetch_register (int regno) override;
+
+ bool low_cannot_store_register (int regno) override;
+
+ bool low_supports_breakpoints () override;
+
+ CORE_ADDR low_get_pc (regcache *regcache) override;
+
+ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
+
+ int low_decr_pc_after_break () override;
+
+ bool low_breakpoint_at (CORE_ADDR pc) override;
+
+ int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
};
/* The singleton target ops object. */
#endif
-static int
-s390_cannot_fetch_register (int regno)
+bool
+s390_target::low_cannot_fetch_register (int regno)
{
- return 0;
+ return false;
}
-static int
-s390_cannot_store_register (int regno)
+bool
+s390_target::low_cannot_store_register (int regno)
{
- return 0;
+ return false;
}
-static void
-s390_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
+void
+s390_target::low_collect_ptrace_register (regcache *regcache, int regno,
+ char *buf)
{
int size = register_size (regcache->tdesc, regno);
- const struct regs_info *regs_info = (*the_low_target.regs_info) ();
+ const struct regs_info *regs_info = get_regs_info ();
struct usrregs_info *usr = regs_info->usrregs;
int regaddr = usr->regmap[regno];
collect_register (regcache, regno, buf);
}
-static void
-s390_supply_ptrace_register (struct regcache *regcache,
- int regno, const char *buf)
+void
+s390_target::low_supply_ptrace_register (regcache *regcache, int regno,
+ const char *buf)
{
int size = register_size (regcache->tdesc, regno);
- const struct regs_info *regs_info = (*the_low_target.regs_info) ();
+ const struct regs_info *regs_info = get_regs_info ();
struct usrregs_info *usr = regs_info->usrregs;
int regaddr = usr->regmap[regno];
s390_fill_gregset (struct regcache *regcache, void *buf)
{
int i;
- const struct regs_info *regs_info = (*the_low_target.regs_info) ();
+ const struct regs_info *regs_info = the_linux_target->get_regs_info ();
struct usrregs_info *usr = regs_info->usrregs;
for (i = 0; i < usr->num_regs; i++)
|| usr->regmap[i] > PT_ACR15)
continue;
- s390_collect_ptrace_register (regcache, i,
- (char *) buf + usr->regmap[i]);
+ ((s390_target *) the_linux_target)->low_collect_ptrace_register
+ (regcache, i, (char *) buf + usr->regmap[i]);
}
}
static const gdb_byte s390_breakpoint[] = { 0, 1 };
#define s390_breakpoint_len 2
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
+/* Implementation of target ops method "sw_breakpoint_from_kind". */
-static const gdb_byte *
-s390_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+s390_target::sw_breakpoint_from_kind (int kind, int *size)
{
*size = s390_breakpoint_len;
return s390_breakpoint;
}
-static CORE_ADDR
-s390_get_pc (struct regcache *regcache)
+bool
+s390_target::low_supports_breakpoints ()
+{
+ return true;
+}
+
+CORE_ADDR
+s390_target::low_get_pc (regcache *regcache)
{
if (register_size (regcache->tdesc, 0) == 4)
{
}
}
-static void
-s390_set_pc (struct regcache *regcache, CORE_ADDR newpc)
+void
+s390_target::low_set_pc (regcache *regcache, CORE_ADDR newpc)
{
if (register_size (regcache->tdesc, 0) == 4)
{
}
}
+int
+s390_target::low_decr_pc_after_break ()
+{
+ return s390_breakpoint_len;
+}
+
/* Determine the word size for the given PID, in bytes. */
#ifdef __s390x__
static int have_hwcap_s390_high_gprs = 0;
static int have_hwcap_s390_vx = 0;
-static void
-s390_arch_setup (void)
+void
+s390_target::low_arch_setup ()
{
const struct target_desc *tdesc;
struct regset_info *regset;
/* Determine word size and HWCAP. */
int pid = pid_of (current_thread);
int wordsize = s390_get_wordsize (pid);
- unsigned long hwcap = linux_get_hwcap (wordsize);
+ unsigned long hwcap = linux_get_hwcap (pid, wordsize);
/* Check whether the kernel supports extra register sets. */
int have_regset_last_break
}
-static int
-s390_breakpoint_at (CORE_ADDR pc)
+bool
+s390_target::low_breakpoint_at (CORE_ADDR pc)
{
unsigned char c[s390_breakpoint_len];
read_inferior_memory (pc, c, s390_breakpoint_len);
/* Breakpoint/Watchpoint support. */
-/* The "supports_z_point_type" linux_target_ops method. */
+/* The "supports_z_point_type" target ops method. */
-static int
-s390_supports_z_point_type (char z_type)
+bool
+s390_target::supports_z_point_type (char z_type)
{
switch (z_type)
{
case Z_PACKET_SW_BP:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
-/* Support for hardware single step. */
-
-static int
-s390_supports_hardware_single_step (void)
-{
- return 1;
-}
-
static struct usrregs_info s390_usrregs_info =
{
s390_num_regs,
NULL, /* disabled_regsets */
};
-static struct regs_info regs_info =
+static struct regs_info myregs_info =
{
NULL, /* regset_bitmap */
&s390_usrregs_info,
&s390_regsets_info_3264
};
-static const struct regs_info *
-s390_regs_info (void)
+const regs_info *
+s390_target::get_regs_info ()
{
if (have_hwcap_s390_high_gprs)
{
return ®s_info_3264;
#endif
}
- return ®s_info;
+ return &myregs_info;
}
-/* The "supports_tracepoints" linux_target_ops method. */
+/* The "supports_tracepoints" target ops method. */
-static int
-s390_supports_tracepoints (void)
+bool
+s390_target::supports_tracepoints ()
{
- return 1;
+ return true;
}
-/* Implementation of linux_target_ops method "get_thread_area". */
+/* Implementation of linux target ops method "low_get_thread_area". */
-static int
-s390_get_thread_area (int lwpid, CORE_ADDR *addrp)
+int
+s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
{
CORE_ADDR res = ptrace (PTRACE_PEEKUSER, lwpid, (long) PT_ACR0, (long) 0);
#ifdef __s390x__
return 0;
}
-/* Implementation of linux_target_ops method
+bool
+s390_target::supports_fast_tracepoints ()
+{
+ return true;
+}
+
+/* Implementation of target ops method
"install_fast_tracepoint_jump_pad". */
-static int
-s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
- CORE_ADDR tpaddr,
- CORE_ADDR collector,
- CORE_ADDR lockaddr,
- ULONGEST orig_size,
- CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline,
- ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn,
- ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+int
+s390_target::install_fast_tracepoint_jump_pad
+ (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err)
{
int i;
int64_t loffset;
return 0;
}
-/* Implementation of linux_target_ops method
+/* Implementation of target ops method
"get_min_fast_tracepoint_insn_len". */
-static int
-s390_get_min_fast_tracepoint_insn_len (void)
+int
+s390_target::get_min_fast_tracepoint_insn_len ()
{
/* We only support using 6-byte jumps to reach the tracepoint code.
If the tracepoint buffer were allocated sufficiently close (64kiB)
return 6;
}
-/* Implementation of linux_target_ops method "get_ipa_tdesc_idx". */
+/* Implementation of target ops method "get_ipa_tdesc_idx". */
-static int
-s390_get_ipa_tdesc_idx (void)
+int
+s390_target::get_ipa_tdesc_idx ()
{
struct regcache *regcache = get_thread_regcache (current_thread, 0);
const struct target_desc *tdesc = regcache->tdesc;
{
CORE_ADDR buildaddr = current_insn_ptr;
- if (debug_threads)
- debug_printf ("Adding %d bytes of insn at %s\n",
- len, paddress (buildaddr));
+ threads_debug_printf ("Adding %d bytes of insn at %s",
+ len, paddress (buildaddr));
append_insns (&buildaddr, len, start);
current_insn_ptr = buildaddr;
0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
};
if (num < 0x8000 && num >= 0)
- {
add_insns (buf_s, sizeof buf_s);
- }
else
- {
- s390_emit_litpool (8);
- add_insns ((unsigned char *) &n, sizeof n);
- add_insns (buf_l, sizeof buf_l);
- }
+ {
+ s390_emit_litpool (8);
+ add_insns ((unsigned char *) &n, sizeof n);
+ add_insns (buf_l, sizeof buf_l);
+ }
}
/* The "emit_call" emit_ops method for s390. */
0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
};
if (arg1 < 0x8000 && arg1 >= -0x8000)
- {
add_insns (buf_s, sizeof buf_s);
- }
else
- {
- s390_emit_litpool (4);
- add_insns ((unsigned char *) &arg1, sizeof arg1);
- add_insns (buf_l, sizeof buf_l);
- }
+ {
+ s390_emit_litpool (4);
+ add_insns ((unsigned char *) &arg1, sizeof arg1);
+ add_insns (buf_l, sizeof buf_l);
+ }
}
/* The "emit_int_call_1" emit_ops method for s390. */
0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
};
if (num < 0x8000 && num >= -0x8000)
- {
add_insns (buf_s, sizeof buf_s);
- }
else
- {
- s390_emit_litpool (8);
- add_insns ((unsigned char *) &n, sizeof n);
- add_insns (buf_l, sizeof buf_l);
- }
+ {
+ s390_emit_litpool (8);
+ add_insns ((unsigned char *) &n, sizeof n);
+ add_insns (buf_l, sizeof buf_l);
+ }
}
/* The "emit_call" emit_ops method for s390x. */
};
#endif
-/* The "emit_ops" linux_target_ops method. */
+/* The "emit_ops" target ops method. */
-static struct emit_ops *
-s390_emit_ops (void)
+emit_ops *
+s390_target::emit_ops ()
{
#ifdef __s390x__
struct regcache *regcache = get_thread_regcache (current_thread, 0);
return &s390_emit_ops_impl;
}
-struct linux_target_ops the_low_target = {
- s390_arch_setup,
- s390_regs_info,
- s390_cannot_fetch_register,
- s390_cannot_store_register,
- NULL, /* fetch_register */
- s390_get_pc,
- s390_set_pc,
- NULL, /* breakpoint_kind_from_pc */
- s390_sw_breakpoint_from_kind,
- NULL,
- s390_breakpoint_len,
- s390_breakpoint_at,
- s390_supports_z_point_type,
- NULL,
- NULL,
- NULL,
- NULL,
- s390_collect_ptrace_register,
- s390_supply_ptrace_register,
- NULL, /* siginfo_fixup */
- NULL, /* new_process */
- NULL, /* delete_process */
- NULL, /* new_thread */
- NULL, /* delete_thread */
- NULL, /* new_fork */
- NULL, /* prepare_to_resume */
- NULL, /* process_qsupported */
- s390_supports_tracepoints,
- s390_get_thread_area,
- s390_install_fast_tracepoint_jump_pad,
- s390_emit_ops,
- s390_get_min_fast_tracepoint_insn_len,
- NULL, /* supports_range_stepping */
- NULL, /* breakpoint_kind_from_current_state */
- s390_supports_hardware_single_step,
- NULL, /* get_syscall_trapinfo */
- s390_get_ipa_tdesc_idx,
-};
-
/* The linux target ops object. */
linux_process_target *the_linux_target = &the_s390_target;