diff options
author | John Baldwin <jhb@FreeBSD.org> | 2022-04-01 13:16:46 -0700 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2022-04-01 13:16:46 -0700 |
commit | f3215e1526d762f005fdf86abac81da514c74e50 (patch) | |
tree | 82cb41adcb6fd2d9f736114fee76675e701a6c32 /gdb/i386-fbsd-tdep.c | |
parent | b5c2367c3ac5f696221d9c24f470498abdb83257 (diff) | |
download | fsf-binutils-gdb-f3215e1526d762f005fdf86abac81da514c74e50.zip fsf-binutils-gdb-f3215e1526d762f005fdf86abac81da514c74e50.tar.gz fsf-binutils-gdb-f3215e1526d762f005fdf86abac81da514c74e50.tar.bz2 |
FreeBSD/x86: Read segment base registers from NT_X86_SEGBASES.
FreeBSD kernels recently grew a new register core dump note containing
the base addresses of the %fs and %gs segments (corresponding to the
%fsbase and %gsbase registers). Parse this note to permit inspecting
TLS variables in core dumps. Native processes already supported TLS
via older ptrace() operations.
Diffstat (limited to 'gdb/i386-fbsd-tdep.c')
-rw-r--r-- | gdb/i386-fbsd-tdep.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c index 16ffd57..fad091f 100644 --- a/gdb/i386-fbsd-tdep.c +++ b/gdb/i386-fbsd-tdep.c @@ -35,6 +35,9 @@ /* The general-purpose regset consists of 19 32-bit slots. */ #define I386_FBSD_SIZEOF_GREGSET (19 * 4) +/* The segment base register set consists of 2 32-bit registers. */ +#define I386_FBSD_SIZEOF_SEGBASES_REGSET (2 * 4) + /* Register maps. */ static const struct regcache_map_entry i386_fbsd_gregmap[] = @@ -61,6 +64,13 @@ static const struct regcache_map_entry i386_fbsd_gregmap[] = { 0 } }; +static const struct regcache_map_entry i386_fbsd_segbases_regmap[] = +{ + { 1, I386_FSBASE_REGNUM, 0 }, + { 1, I386_GSBASE_REGNUM, 0 }, + { 0 } +}; + /* This layout including fsbase and gsbase was adopted in FreeBSD 8.0. */ @@ -103,6 +113,11 @@ const struct regset i386_fbsd_gregset = i386_fbsd_gregmap, regcache_supply_regset, regcache_collect_regset }; +const struct regset i386_fbsd_segbases_regset = +{ + i386_fbsd_segbases_regmap, regcache_supply_regset, regcache_collect_regset +}; + /* Support for signal handlers. */ /* In a signal frame, esp points to a 'struct sigframe' which is @@ -316,6 +331,9 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, &i386_fbsd_gregset, NULL, cb_data); cb (".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset, &i386_fpregset, NULL, cb_data); + cb (".reg-x86-segbases", I386_FBSD_SIZEOF_SEGBASES_REGSET, + I386_FBSD_SIZEOF_SEGBASES_REGSET, &i386_fbsd_segbases_regset, + "segment bases", cb_data); if (tdep->xcr0 & X86_XSTATE_AVX) cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0), |