]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[wip] gdb: include NT_I386_TLS note in generated core files users/aburgess/gdb-core-i386-tls
authorAndrew Burgess <aburgess@redhat.com>
Tue, 21 Jan 2025 17:22:04 +0000 (17:22 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 22 Apr 2025 12:01:59 +0000 (13:01 +0100)
commitb4bb75ab86048736899fa2456bc9b126e69c0581
treecdee239f3c9872d9a396b6d4ad44e50ec72c580d
parent29b68e449be8816505487ef7cd5abde72ed21ca4
[wip] gdb: include NT_I386_TLS note in generated core files

This commit extends GDB for x86/Linux to include the NT_I386_TLS note
in generated core file (i.e. created with `generate-core-file`
command).

The NT_I386_TLS note should be added for i386 binaries, and for
binaries compiled with -m32.

[TODO] This commit does adds a basic framework for accessing the TLS
data, but currently only reads the information for one thread (the
current thread when the core file is created), which is not correct.
An actual kernel create core file includes a NT_I386_TLS for each
thread, so that needs fixing.

[TODO] Also, this commit doesn't know how to fetch the TLS descriptor
information for remote targets, so that needs fixing.

[TODO] Looking at how ARM/AArch64 handles similar TLS data, that
targets seems to use a custom register set.  I wonder if the approach
I've taken here is the wrong one; maybe we should add 3 custom
registers, each register representing 1 GDT entry, with an entry being
a base-address and limit.  GDB would then try to read that register
set for each thread...  I'm not entirely sure on the details, I'll
need to investigate how ARM/AArch64 does this a little more.

[TODO] This commit could do with a test in gdb.arch/.  Not sure
exactly what the test should do yet, but probably create a
multi-threaded inferior (with some TLS usage?) and generate a core
file.  We can then check that there is a NT_I386_TLS for each thread.
We can then load the core file and perform some action that depends on
the TLS descriptor ... need to figure out exactly what that is though.

[TODO] Finally, I wonder if we should add a new command that allows a
user to inspect the TLS descriptor information, though this should
probably be broken out into a separate commit.
gdb/amd64-linux-nat.c
gdb/i386-linux-nat.c
gdb/i386-linux-tdep.c
gdb/linux-tdep.c
gdb/linux-tdep.h
gdb/target.h
gdb/x86-linux-nat.c
gdb/x86-linux-nat.h