diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-01-30 15:37:23 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-03-25 17:14:19 +0000 |
commit | 198ff6ff819c240545f9fc68b39636fd376d4ba9 (patch) | |
tree | 9d5f4bd1ef2e3dc80d9035ecc7402ee0c5e1e6e2 /gdb/i386-linux-tdep.c | |
parent | 61bb321605fc74703adc994fd7a78e9d2495ca7a (diff) | |
download | gdb-198ff6ff819c240545f9fc68b39636fd376d4ba9.zip gdb-198ff6ff819c240545f9fc68b39636fd376d4ba9.tar.gz gdb-198ff6ff819c240545f9fc68b39636fd376d4ba9.tar.bz2 |
gdb/gdbserver: share x86/linux tdesc caching
This commit builds on the previous series of commits to share the
target description caching code between GDB and gdbserver for
x86/Linux targets.
The objective of this commit is to move the four functions (2 each of)
i386_linux_read_description and amd64_linux_read_description into
gdb/nat/x86-linux-tdesc.c and combine them so we have just a single
copy of each. Then both GDB and gdbserver will link against these
shared functions.
It is worth reading the description of the previous commit to see why
this merging is not as simple as it seems: on the gdbserver side we
actually have two users of these functions, gdbserver itself, and the
in process agent (IPA).
However, the previous commit streamlined the gdbserver code, and so
now it is simple to move the two functions along with all their
support functions from the gdbserver directory into the gdb/nat/
directory, and then GDB is fine to call these functions.
One small curiosity with this patch is the function
x86_linux_post_init_tdesc. On the gdbserver side the two functions
amd64_linux_read_description and i386_linux_read_description have some
functionality that is not present on the GDB side, that is some
additional configuration that is performed as each target description
is created to setup the expedited registers.
To support this I've added the function x86_linux_post_init_tdesc.
This function is called from the two *_linux_read_description
functions, but is implemented separately for GDB and gdbserver.
This does mean adding back some non-shared code when this whole series
has been about sharing code, but now the only non-shared bit is the
single line that is actually different between GDB and gdbserver, all
the rest, which is identical, is now shared.
I did need to add a new rule to the gdbserver Makefile, this is to
allow the nat/x86-linux-tdesc.c file to be compiled for the IPA.
Approved-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/i386-linux-tdep.c')
-rw-r--r-- | gdb/i386-linux-tdep.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index f5f7a36..ed14422 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -681,29 +681,12 @@ i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch, layout) != 0; } -/* See i386-linux-tdep.h. */ +/* See nat/x86-linux-tdesc.h. */ -const struct target_desc * -i386_linux_read_description (uint64_t xcr0) +void +x86_linux_post_init_tdesc (target_desc *tdesc, bool is_64bit) { - if (xcr0 == 0) - return NULL; - - static struct target_desc *i386_linux_tdescs \ - [2/*X87*/][2/*SSE*/][2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {}; - struct target_desc **tdesc; - - tdesc = &i386_linux_tdescs[(xcr0 & X86_XSTATE_X87) ? 1 : 0] - [(xcr0 & X86_XSTATE_SSE) ? 1 : 0] - [(xcr0 & X86_XSTATE_AVX) ? 1 : 0] - [(xcr0 & X86_XSTATE_MPX) ? 1 : 0] - [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0] - [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]; - - if (*tdesc == NULL) - *tdesc = i386_create_target_description (xcr0, true, false); - - return *tdesc; + /* Nothing. */ } /* Get Linux/x86 target description from core dump. */ @@ -716,7 +699,10 @@ i386_linux_core_read_description (struct gdbarch *gdbarch, /* Linux/i386. */ x86_xsave_layout layout; uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout); - const struct target_desc *tdesc = i386_linux_read_description (xcr0); + + const struct target_desc *tdesc; + if (xcr0 != 0) + tdesc = i386_linux_read_description (xcr0); if (tdesc != NULL) return tdesc; |