diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-02-23 11:45:11 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-03-13 21:51:04 +0000 |
commit | deb65a3cd86462cb19d10a867ee474b3f4cf7012 (patch) | |
tree | 9c559cf9d59366a5e9be795de5b1c35fb7d8ff72 /gdb/displaced-stepping.c | |
parent | 564cddf8edc75c1b043fcab93cc28861e0d48fa2 (diff) | |
download | fsf-binutils-gdb-deb65a3cd86462cb19d10a867ee474b3f4cf7012.zip fsf-binutils-gdb-deb65a3cd86462cb19d10a867ee474b3f4cf7012.tar.gz fsf-binutils-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/displaced-stepping.c')
-rw-r--r-- | gdb/displaced-stepping.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c index 06b32a8..9f98ea8 100644 --- a/gdb/displaced-stepping.c +++ b/gdb/displaced-stepping.c @@ -55,7 +55,7 @@ displaced_step_buffers::prepare (thread_info *thread, CORE_ADDR &displaced_pc) regcache *regcache = get_thread_regcache (thread); const address_space *aspace = regcache->aspace (); gdbarch *arch = regcache->arch (); - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_buffer_length (arch); /* Search for an unused buffer. */ displaced_step_buffer *buffer = nullptr; @@ -243,7 +243,7 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread, below. */ thread->inf->displaced_step_state.unavailable = false; - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_buffer_length (arch); /* Restore memory of the buffer. */ write_memory_ptid (thread->ptid, buffer->addr, @@ -302,7 +302,7 @@ displaced_step_buffers::restore_in_ptid (ptid_t ptid) regcache *regcache = get_thread_regcache (buffer.current_thread); gdbarch *arch = regcache->arch (); - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_buffer_length (arch); write_memory_ptid (ptid, buffer.addr, buffer.saved_copy.data (), len); |