GDB doesn't display thread_id while debugging a core file

Carlos Eduardo Seo
2007-08-06T20:27:07Z

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello

While debugging a core file from a multi-threaded application, I noticed
that GDB doesn't show the thread_id:

(gdb) thread
[Current thread is 4 (process 8466)]

instead of something like this:

(gdb) thread
[Current thread is 5 (Thread 2199033284976 (LWP 4124))]

As far as I'm aware of, this big number is actually the thread pointer
minus an offset value.

For ppc64, I can get the thread pointer from register r13 (which is in
the core file) and then subtract (TLS_PRE_TCB_SIZE + 0x7000) to get the
thread_id. 0x7000 is fixed per the ABI and TLS_PRE_TCB_SIZE can be
calculated from the size of two structs defined in GLIBC (so, I must
assume that the user has a GLIBC with debug information in order to get
the size of those structs).

I know this is an issue that has a solution which is arch-dependent, so
my concern here is to make a fix that's easily extensible to other archs.

Is a solution like this acceptable?

Thanks and regards,

- --
Carlos Eduardo Seo
Software Engineer
IBM Linux Technology Center
E-Mail: cseo@linux.vnet.ibm.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGt4QFqvq7Aov/qQARAt12AJ9szUdI05rLYuJ+r+oiCwPKZjI+BwCfaHpz
YUp9BcgLXvfsoWJ7Id9DDBk=
=ayr3
-----END PGP SIGNATURE-----