/* Dynamic architecture support for GDB, the GNU debugger.
- Copyright (C) 1998-2016 Free Software Foundation, Inc.
+ Copyright (C) 1998-2022 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef GDBARCH_UTILS_H
-#define GDBARCH_UTILS_H
+#ifndef ARCH_UTILS_H
+#define ARCH_UTILS_H
+
+#include "gdbarch.h"
-struct gdbarch;
struct frame_info;
struct minimal_symbol;
struct type;
struct gdbarch_info;
-
-#define GDBARCH_BREAKPOINT_FROM_PC(ARCH) \
- static const gdb_byte * \
- ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
- CORE_ADDR *pcptr, \
- int *lenptr) \
- { \
- int kind = ARCH##_breakpoint_kind_from_pc (gdbarch, pcptr); \
- \
- return ARCH##_sw_breakpoint_from_kind (gdbarch, kind, lenptr); \
+struct dwarf2_frame_state;
+
+template <size_t bp_size, const gdb_byte *break_insn>
+struct bp_manipulation
+{
+ static int
+ kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+ {
+ return bp_size;
}
-#define GDBARCH_BREAKPOINT_MANIPULATION(ARCH,BREAK_INSN) \
- static const gdb_byte * \
- ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
- CORE_ADDR *pcptr, \
- int *lenptr) \
- { \
- *lenptr = sizeof (BREAK_INSN); \
- return BREAK_INSN; \
+ static const gdb_byte *
+ bp_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+ {
+ *size = kind;
+ return break_insn;
+ }
+};
+
+template <size_t bp_size,
+ const gdb_byte *break_insn_little,
+ const gdb_byte *break_insn_big>
+struct bp_manipulation_endian
+{
+ static int
+ kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+ {
+ return bp_size;
}
-#define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH) \
- set_gdbarch_breakpoint_from_pc (gdbarch, ARCH##_breakpoint_from_pc)
-
-#define GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN(ARCH, \
- LITTLE_BREAK_INSN, \
- BIG_BREAK_INSN) \
- static const gdb_byte * \
- ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
- CORE_ADDR *pcptr, \
- int *lenptr) \
- { \
- gdb_static_assert (ARRAY_SIZE (LITTLE_BREAK_INSN) \
- == ARRAY_SIZE (BIG_BREAK_INSN)); \
- *lenptr = sizeof (LITTLE_BREAK_INSN); \
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
- return BIG_BREAK_INSN; \
- else \
- return LITTLE_BREAK_INSN; \
+ static const gdb_byte *
+ bp_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+ {
+ *size = kind;
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ return break_insn_big;
+ else
+ return break_insn_little;
}
+};
-/* An implementation of gdbarch_displaced_step_copy_insn for
- processors that don't need to modify the instruction before
- single-stepping the displaced copy.
-
- Simply copy gdbarch_max_insn_length (ARCH) bytes from FROM to TO.
- The closure is an array of that many bytes containing the
- instruction's bytes, allocated with xmalloc. */
-extern struct displaced_step_closure *
- simple_displaced_step_copy_insn (struct gdbarch *gdbarch,
- CORE_ADDR from, CORE_ADDR to,
- struct regcache *regs);
-
-/* Simple implementation of gdbarch_displaced_step_free_closure: Call
- xfree.
- This is appropriate for use with simple_displaced_step_copy_insn. */
-extern void
- simple_displaced_step_free_closure (struct gdbarch *gdbarch,
- struct displaced_step_closure *closure);
+#define BP_MANIPULATION(BREAK_INSN) \
+ bp_manipulation<sizeof (BREAK_INSN), BREAK_INSN>
+
+#define BP_MANIPULATION_ENDIAN(BREAK_INSN_LITTLE, BREAK_INSN_BIG) \
+ bp_manipulation_endian<sizeof (BREAK_INSN_LITTLE), \
+ BREAK_INSN_LITTLE, BREAK_INSN_BIG>
/* Default implementation of gdbarch_displaced_hw_singlestep. */
-extern int
- default_displaced_step_hw_singlestep (struct gdbarch *,
- struct displaced_step_closure *);
+extern bool default_displaced_step_hw_singlestep (struct gdbarch *);
/* Possible value for gdbarch_displaced_step_location:
Place displaced instructions at the program's entry point,
CORE_ADDR default_adjust_dwarf2_line (CORE_ADDR addr, int rel);
+/* Default DWARF vendor CFI handler. */
+
+bool default_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op,
+ struct dwarf2_frame_state *fs);
+
/* Version of cannot_fetch_register() / cannot_store_register() that
always fails. */
default_floatformat_for_type (struct gdbarch *gdbarch,
const char *name, int len);
+/* Default implementation of gdbarch_memtag_to_string. */
+extern std::string default_memtag_to_string (struct gdbarch *gdbarch,
+ struct value *tag);
+
+/* Default implementation of gdbarch_tagged_address_p. */
+bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address);
+
+/* Default implementation of gdbarch_memtag_matches_p. */
+extern bool default_memtag_matches_p (struct gdbarch *gdbarch,
+ struct value *address);
+
+/* Default implementation of gdbarch_set_memtags. */
+bool default_set_memtags (struct gdbarch *gdbarch,
+ struct value *address, size_t length,
+ const gdb::byte_vector &tags,
+ memtag_type tag_type);
+
+/* Default implementation of gdbarch_get_memtag. */
+struct value *default_get_memtag (struct gdbarch *gdbarch,
+ struct value *address,
+ memtag_type tag_type);
+
extern CORE_ADDR generic_skip_trampoline_code (struct frame_info *frame,
CORE_ADDR pc);
was explicitly selected. */
extern const char *selected_architecture_name (void);
-/* Initialize a ``struct info''. Can't use memset(0) since some
- default values are not zero. "fill" takes all available
- information and fills in any unspecified fields. */
-
-extern void gdbarch_info_init (struct gdbarch_info *info);
-
/* Similar to init, but this time fill in the blanks. Information is
obtained from the global "set ..." options and explicitly
initialized INFO fields. */
extern int default_has_shared_address_space (struct gdbarch *);
extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
- CORE_ADDR addr, char **msg);
+ CORE_ADDR addr, std::string *msg);
-extern void default_remote_breakpoint_from_pc (struct gdbarch *,
- CORE_ADDR *pcptr, int *kindptr);
+extern const gdb_byte *default_breakpoint_from_pc (struct gdbarch *gdbarch,
+ CORE_ADDR *pcptr,
+ int *lenptr);
+
+extern int default_breakpoint_kind_from_current_state (struct gdbarch *gdbarch,
+ struct regcache *regcache,
+ CORE_ADDR *pcptr);
extern void default_gen_return_address (struct gdbarch *gdbarch,
struct agent_expr *ax,
extern int default_insn_is_ret (struct gdbarch *, CORE_ADDR);
extern int default_insn_is_jump (struct gdbarch *, CORE_ADDR);
+/* Default implementation of gdbarch_program_breakpoint_here_p. */
+extern bool default_program_breakpoint_here_p (struct gdbarch *gdbarch,
+ CORE_ADDR addr);
+
/* Do-nothing version of vsyscall_range. Returns false. */
extern int default_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range);
extern CORE_ADDR default_infcall_mmap (CORE_ADDR size, unsigned prot);
extern void default_infcall_munmap (CORE_ADDR addr, CORE_ADDR size);
-extern char *default_gcc_target_options (struct gdbarch *gdbarch);
+extern std::string default_gcc_target_options (struct gdbarch *gdbarch);
extern const char *default_gnu_triplet_regexp (struct gdbarch *gdbarch);
extern int default_addressable_memory_unit_size (struct gdbarch *gdbarch);
struct regcache *regcache,
CORE_ADDR addr);
-#endif
+extern int default_print_insn (bfd_vma memaddr, disassemble_info *info);
+
+/* Wrapper to gdbarch_skip_prologue, but doesn't throw exception. Catch
+ exception thrown from gdbarch_skip_prologue, and return PC. */
+
+extern CORE_ADDR gdbarch_skip_prologue_noexcept (gdbarch *gdbarch,
+ CORE_ADDR pc) noexcept;
+
+/* Default implementation of gdbarch_in_indirect_branch_thunk that returns
+ false. */
+extern bool default_in_indirect_branch_thunk (gdbarch *gdbarch,
+ CORE_ADDR pc);
+
+/* Default implementation of gdbarch type_align method. */
+extern ULONGEST default_type_align (struct gdbarch *gdbarch,
+ struct type *type);
+
+/* Default implementation of gdbarch get_pc_address_flags method. */
+extern std::string default_get_pc_address_flags (frame_info *frame,
+ CORE_ADDR pc);
+
+/* Default implementation of gdbarch read_core_file_mappings method. */
+extern void default_read_core_file_mappings (struct gdbarch *gdbarch,
+ struct bfd *cbfd,
+ gdb::function_view<void (ULONGEST count)>
+ pre_loop_cb,
+ gdb::function_view<void (int num,
+ ULONGEST start,
+ ULONGEST end,
+ ULONGEST file_ofs,
+ const char *filename)>
+ loop_cb);
+#endif /* ARCH_UTILS_H */