Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: GDB doesn't display thread_id while debugging a core file
@ 2008-04-15  3:05 Icarus Sparry
  2008-04-15  3:10 ` Michael Snyder
  0 siblings, 1 reply; 13+ messages in thread
From: Icarus Sparry @ 2008-04-15  3:05 UTC (permalink / raw)
  To: gdb

Last November there was some discussion on this topic, which ended with
Daniel Jacobowitz saying in

http://sourceware.org/ml/gdb/2007-08/msg00068.html

	If we assume that the host's libthread_db will either recognize
the
	core file and do the right thing, or reject the core file, then
we can
	write a small target layer that uses it on top of corelow.c in a
	similar way to how linux-thread-db.c / proc-service.c use
linux-nat.c.

	It's just a matter of testing that on a couple of different
setups,
	like LinuxThreads and cross debuggers, to see how it behaves.
Or
	doesn't behave.


Being able to access variables declared with __thread in core files
would certainly be useful. Could someone give some reasonable guess of
the amount of effort required to do this? In particular for a powerpc32
corefile from a linux process with NPTL being debugged on an x86 linux
box.

Thanks.


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: GDB doesn't display thread_id while debugging a core file
@ 2007-08-08 19:13 msnyder
  2007-08-08 19:21 ` Daniel Jacobowitz
  0 siblings, 1 reply; 13+ messages in thread
From: msnyder @ 2007-08-08 19:13 UTC (permalink / raw)
  To: gdb; +Cc: cseo, drow

Daniel writes:
> On Mon, Aug 06, 2007 at 06:20:58PM -0300, Carlos Eduardo Seo wrote:
> > > The thread ID is produced by NPTL's libthread_db library,
> > Yes, and this number is also an address, the thread pointer used to
> > access the TCB, as it is defined in the TLS definitions in the ABI.
> > So, there's no magic involved. :)
>
> That's incorrect.  The fact that pthread_self, and thus libthread_db,
> use a pointer to the "struct pthread" as their thread ID is an
> internal implementation detail of NPTL, i.e. subject to change.  That
> means it's the province of libthread_db.

Agree with Daniel.  This is an abi spec.  We are not allowed
to presume that we know the internal details of implementation.
That is what the libthread_db API is for.

> > This may be a silly question, but, how can we use libthread_db in
> > order to get the thread ID from threads within a core file?
>
> If we assume that the host's libthread_db will either recognize the
> core file and do the right thing, or reject the core file, then we can
> write a small target layer that uses it on top of corelow.c in a
> similar way to how linux-thread-db.c / proc-service.c use linux-nat.c.

Daniel, I think it's even simpler than that.

libthread_db works via callbacks to gdb that do nothing more
complicated than read memory.  GDB can read memory from the corefile.

The only question is whether the versions of libthread and
libthread_db match, on the host and (corefile-generating) target.

If they do, "it should just work" (tm).

And if there is a version string somewhere in the library's read/write
memory sections, it should also exist in the corefile.

Michael





^ permalink raw reply	[flat|nested] 13+ messages in thread
* GDB doesn't display thread_id while debugging a core file
@ 2007-08-06 20:27 Carlos Eduardo Seo
  2007-08-06 20:33 ` Daniel Jacobowitz
  0 siblings, 1 reply; 13+ messages in thread
From: Carlos Eduardo Seo @ 2007-08-06 20:27 UTC (permalink / raw)
  To: gdb

-----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-----


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

end of thread, other threads:[~2008-04-15 20:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15  3:05 GDB doesn't display thread_id while debugging a core file Icarus Sparry
2008-04-15  3:10 ` Michael Snyder
2008-04-15  6:54   ` Icarus Sparry
2008-04-15  8:12     ` Daniel Jacobowitz
2008-04-15 18:17       ` Michael Snyder
2008-04-15 20:46         ` Icarus Sparry
2008-04-15 23:48           ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2007-08-08 19:13 msnyder
2007-08-08 19:21 ` Daniel Jacobowitz
2007-08-06 20:27 Carlos Eduardo Seo
2007-08-06 20:33 ` Daniel Jacobowitz
2007-08-06 21:21   ` Carlos Eduardo Seo
2007-08-07 11:31     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox