public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Support for thread-local variables on FreeBSD
@ 2019-01-22 18:43 John Baldwin
  2019-01-22 18:43 ` [PATCH 3/9] Handle TLS variable lookups when using separate debug object files John Baldwin
                   ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: John Baldwin @ 2019-01-22 18:43 UTC (permalink / raw)
  To: gdb-patches

This series adds support for thread-local variables on a few FreeBSD
architectures.  Unlike other platforms, this patch series does not
rely on libthread_db but uses a different approach.  It instead relies
on an architecture-specific method to locate an individual thread's
DTV array of TLS block pointers.  The code to locate the specific TLS
block for an object file is shared in a helper function (patch 5) that
the per-architecture methods invoke after locating the DTV array.
Unlike the libthread_db approach, this permits examining TLS variables
of single-threaded variables and supports arbitrary cross debugging
(subject to the relevant registers being available from a core dump).
This did require introducing a new gdbarch method to resolve a TLS
variable address used instead of a target method (patch 4).

For FreeBSD/i386, TLS variables are stored relative to the %gs segment
register.  This requires access to the base address of %gs to locate
the DTV array.  To facilitate this, the first two patches add support
for the %fs_base and %gs_base registers on i386.  I did test this on
Linux x86-64 where it introduces no new regressions in the test suite
in my testing.

There are some limitations in the FreeBSD TLS support:

1) FreeBSD/amd64 and FreeBSD/i386 do not currently include the
   %fs_base and %gs_base registers in core dumps, so TLS only works
   for "live" processes currently.

2) TLS variables in the executable didn't work for me on FreeBSD/riscv,
   but this appears to be a compiler bug as the variable did not have
   a valid DW_at_location in the dwarf info.  TLS variables in libc
   worked fine both live and with core dumps.

3) For FreeBSD/powerpc, I was only able to test powerpc64 using a
   cross-debugger on amd64.

John Baldwin (9):
  Support the fs_base and gs_base registers on i386.
  Support fs_base and gs_base on FreeBSD/i386.
  Handle TLS variable lookups when using separate debug object files.
  Add a new gdbarch method to resolve the address of TLS variables.
  Add a helper function to resolve TLS variable addresses for FreeBSD.
  Support TLS variables on FreeBSD/amd64.
  Support TLS variables on FreeBSD/i386.
  Support TLS variables on FreeBSD/riscv.
  Support TLS variables on FreeBSD/powerpc.

 gdb/ChangeLog                        |  96 ++++++++++++++++++
 gdb/amd64-bsd-nat.c                  |  26 +++--
 gdb/amd64-fbsd-nat.c                 |   4 +-
 gdb/amd64-fbsd-tdep.c                |  25 +++++
 gdb/amd64-tdep.c                     |  10 +-
 gdb/arch/i386.c                      |   6 +-
 gdb/arch/i386.h                      |   3 +-
 gdb/fbsd-tdep.c                      | 146 +++++++++++++++++++++++++++
 gdb/fbsd-tdep.h                      |  10 ++
 gdb/features/i386/32bit-segments.c   |  15 +++
 gdb/features/i386/32bit-segments.xml |  12 +++
 gdb/gdbarch.c                        |  32 ++++++
 gdb/gdbarch.h                        |   6 ++
 gdb/gdbarch.sh                       |   1 +
 gdb/gdbserver/ChangeLog              |   8 ++
 gdb/gdbserver/linux-x86-tdesc.c      |   2 +-
 gdb/gdbserver/lynx-i386-low.c        |   2 +-
 gdb/gdbserver/nto-x86-low.c          |   2 +-
 gdb/gdbserver/win32-i386-low.c       |   2 +-
 gdb/i386-bsd-nat.c                   |  54 ++++++++++
 gdb/i386-fbsd-nat.c                  |   2 +-
 gdb/i386-fbsd-tdep.c                 |  31 +++++-
 gdb/i386-go32-tdep.c                 |   2 +-
 gdb/i386-linux-tdep.c                |   2 +-
 gdb/i386-tdep.c                      |  33 ++++--
 gdb/i386-tdep.h                      |  12 ++-
 gdb/ppc-fbsd-tdep.c                  |  35 +++++++
 gdb/riscv-fbsd-tdep.c                |  27 +++++
 gdb/solib-svr4.c                     |   5 +
 gdb/target.c                         |  13 ++-
 30 files changed, 580 insertions(+), 44 deletions(-)
 create mode 100644 gdb/features/i386/32bit-segments.c
 create mode 100644 gdb/features/i386/32bit-segments.xml

-- 
2.19.2

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-02-09  0:34 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 18:43 [PATCH 0/9] Support for thread-local variables on FreeBSD John Baldwin
2019-01-22 18:43 ` [PATCH 3/9] Handle TLS variable lookups when using separate debug object files John Baldwin
2019-02-02 15:52   ` Simon Marchi
2019-02-04 20:02     ` John Baldwin
2019-02-05 20:06       ` Simon Marchi
2019-02-05 22:21         ` John Baldwin
2019-02-05 22:33           ` John Baldwin
2019-02-07  4:05             ` Simon Marchi
2019-02-07  4:08               ` Simon Marchi
2019-01-22 18:43 ` [PATCH 9/9] Support TLS variables on FreeBSD/powerpc John Baldwin
2019-01-22 18:43 ` [PATCH 2/9] Support fs_base and gs_base on FreeBSD/i386 John Baldwin
2019-02-02 15:26   ` Simon Marchi
2019-02-04 19:45     ` John Baldwin
2019-02-05 18:59       ` Simon Marchi
2019-01-22 18:43 ` [PATCH 6/9] Support TLS variables on FreeBSD/amd64 John Baldwin
2019-01-22 18:43 ` [PATCH 7/9] Support TLS variables on FreeBSD/i386 John Baldwin
2019-01-22 18:43 ` [PATCH 1/9] Support the fs_base and gs_base registers on i386 John Baldwin
2019-01-27  4:22   ` Simon Marchi
2019-01-28 17:54     ` John Baldwin
2019-02-02 15:11       ` Simon Marchi
2019-01-22 18:52 ` [PATCH 4/9] Add a new gdbarch method to resolve the address of TLS variables John Baldwin
2019-01-22 18:52 ` [PATCH 5/9] Add a helper function to resolve TLS variable addresses for FreeBSD John Baldwin
2019-01-24 17:09   ` John Baldwin
2019-02-07  5:05     ` Simon Marchi
2019-02-07 17:02       ` John Baldwin
2019-02-09  0:34         ` John Baldwin
2019-01-22 18:52 ` [PATCH 8/9] Support TLS variables on FreeBSD/riscv John Baldwin
2019-01-27 23:35   ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).