aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch-gen.h
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-02-23 11:45:11 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-03-13 21:51:04 +0000
commitdeb65a3cd86462cb19d10a867ee474b3f4cf7012 (patch)
tree9c559cf9d59366a5e9be795de5b1c35fb7d8ff72 /gdb/gdbarch-gen.h
parent564cddf8edc75c1b043fcab93cc28861e0d48fa2 (diff)
downloadgdb-deb65a3cd86462cb19d10a867ee474b3f4cf7012.zip
gdb-deb65a3cd86462cb19d10a867ee474b3f4cf7012.tar.gz
gdb-deb65a3cd86462cb19d10a867ee474b3f4cf7012.tar.bz2
gdb: add gdbarch::displaced_step_buffer_length
The gdbarch::max_insn_length field is used mostly to support displaced stepping; it controls the size of the buffers allocated for the displaced-step instruction, and is also used when first copying the instruction, and later, when fixing up the instruction, in order to read in and parse the instruction being stepped. However, it has started to be used in other places in GDB, for example, it's used in the Python disassembler API, and it is used on amd64 as part of branch-tracing instruction classification. The problem is that the value assigned to max_insn_length is not always the maximum instruction length, but sometimes is a multiple of that length, as required to support displaced stepping, see rs600, ARM, and AArch64 for examples of this. It seems to me that we are overloading the meaning of the max_insn_length field, and I think that could potentially lead to confusion. I propose that we add a new gdbarch field, gdbarch::displaced_step_buffer_length, this new field will do exactly what it says on the tin; represent the required displaced step buffer size. The max_insn_length field can then do exactly what it claims to do; represent the maximum length of a single instruction. As some architectures (e.g. i386, and amd64) only require their displaced step buffers to be a single instruction in size, I propose that the default for displaced_step_buffer_length will be the value of max_insn_length. Architectures than need more buffer space can then override this default as needed. I've updated all architectures to setup the new field if appropriate, and I've audited all calls to gdbarch_max_insn_length and switched to gdbarch_displaced_step_buffer_length where appropriate. There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/gdbarch-gen.h')
-rw-r--r--gdb/gdbarch-gen.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index ddb97f6..76d12a1 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -1039,8 +1039,8 @@ extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_i
see the comments in infrun.c.
The TO area is only guaranteed to have space for
- gdbarch_max_insn_length (arch) bytes, so this function must not
- write more bytes than that to that area.
+ gdbarch_displaced_step_buffer_length (arch) octets, so this
+ function must not write more octets than that to this area.
If you do not provide this function, GDB assumes that the
architecture does not support displaced stepping.
@@ -1122,6 +1122,14 @@ typedef void (gdbarch_displaced_step_restore_all_in_ptid_ftype) (inferior *paren
extern void gdbarch_displaced_step_restore_all_in_ptid (struct gdbarch *gdbarch, inferior *parent_inf, ptid_t child_ptid);
extern void set_gdbarch_displaced_step_restore_all_in_ptid (struct gdbarch *gdbarch, gdbarch_displaced_step_restore_all_in_ptid_ftype *displaced_step_restore_all_in_ptid);
+/* The maximum length in octets required for a displaced-step instruction
+ buffer. By default this will be the same as gdbarch::max_insn_length,
+ but should be overridden for architectures that might expand a
+ displaced-step instruction to multiple replacement instructions. */
+
+extern ULONGEST gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch);
+extern void set_gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch, ULONGEST displaced_step_buffer_length);
+
/* Relocate an instruction to execute at a different address. OLDLOC
is the address in the inferior memory where the instruction to
relocate is currently at. On input, TO points to the destination