public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Support kernel-backed user threads on FreeBSD
@ 2016-01-11 18:53 John Baldwin
  2016-01-12 18:55 ` John Baldwin
  0 siblings, 1 reply; 6+ messages in thread
From: John Baldwin @ 2016-01-11 18:53 UTC (permalink / raw)
  To: gdb-patches, binutils

This set of patches adds support for examining kernel-backed user threads on
FreeBSD.  There is more history in a comment in fbsd-nat.c, but this target
uses ptrace directly (instead of libthread_db) to support the current
threading library (libthr) on FreeBSD which uses a kernel thread for each
user thread.  Support for thread names in both core dumps (via FreeBSD's
OS-specific NT_THRMISC core note) and live is supported as is scheduler
locking.  gcore generates register notes for each thread as well.

The first two patches are to binutils to support FreeBSD-specific core
notes.  The last four are to GDB.

John Baldwin (6):
  Add support to readelf for reading FreeBSD ELF core notes.
  Add a psuedosection for the NT_FREEBSD_THRMISC note.
  Display per-thread information for threads in FreeBSD cores.
  Use LWP IDs with ptrace register requests on FreeBSD.
  Add support for LWP-based threads on FreeBSD.
  Dump register notes for each thread when generating a FreeBSD core.

 bfd/ChangeLog         |   4 +
 bfd/elf.c             |   7 +
 binutils/ChangeLog    |   5 +
 binutils/readelf.c    |  35 ++++
 gdb/ChangeLog         |  68 ++++++++
 gdb/amd64bsd-nat.c    |  35 ++--
 gdb/config.in         |   3 +
 gdb/configure         |  16 ++
 gdb/configure.ac      |   7 +
 gdb/fbsd-nat.c        | 452 +++++++++++++++++++++++++++++++++++++++++++++++---
 gdb/fbsd-tdep.c       | 185 ++++++++++++++++++---
 gdb/i386bsd-nat.c     |  41 +++--
 gdb/ppcfbsd-nat.c     |  23 ++-
 include/elf/ChangeLog |  27 +++
 include/elf/common.h  |  14 ++
 15 files changed, 842 insertions(+), 80 deletions(-)
 create mode 100644 include/elf/ChangeLog

-- 
2.7.0

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

* Re: [PATCH 0/6] Support kernel-backed user threads on FreeBSD
  2016-01-11 18:53 [PATCH 0/6] Support kernel-backed user threads on FreeBSD John Baldwin
@ 2016-01-12 18:55 ` John Baldwin
  2016-01-12 19:06   ` Mark Kettenis
  2016-01-12 19:07   ` Paul_Koning
  0 siblings, 2 replies; 6+ messages in thread
From: John Baldwin @ 2016-01-12 18:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: binutils

On Monday, January 11, 2016 10:53:50 AM John Baldwin wrote:
> This set of patches adds support for examining kernel-backed user threads on
> FreeBSD.  There is more history in a comment in fbsd-nat.c, but this target
> uses ptrace directly (instead of libthread_db) to support the current
> threading library (libthr) on FreeBSD which uses a kernel thread for each
> user thread.  Support for thread names in both core dumps (via FreeBSD's
> OS-specific NT_THRMISC core note) and live is supported as is scheduler
> locking.  gcore generates register notes for each thread as well.
> 
> The first two patches are to binutils to support FreeBSD-specific core
> notes.  The last four are to GDB.

(Apologies for fubar'ing the threading on the patches in this series.)

One other note I forgot to mention is that currently I leave the ptid for
single-threaded processes as (pid, 0, 0) (i.e. I only use LWPs in PTIDs
when there is more than one thread).  What is the best practice?  Should
I always use LWPs in ptids instead?

-- 
John Baldwin

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

* Re: [PATCH 0/6] Support kernel-backed user threads on FreeBSD
  2016-01-12 18:55 ` John Baldwin
@ 2016-01-12 19:06   ` Mark Kettenis
  2016-01-12 19:07   ` Paul_Koning
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2016-01-12 19:06 UTC (permalink / raw)
  To: jhb; +Cc: gdb-patches, binutils

> From: John Baldwin <jhb@freebsd.org>
> Date: Tue, 12 Jan 2016 10:55:34 -0800
> 
> On Monday, January 11, 2016 10:53:50 AM John Baldwin wrote:
> > This set of patches adds support for examining kernel-backed user threads on
> > FreeBSD.  There is more history in a comment in fbsd-nat.c, but this target
> > uses ptrace directly (instead of libthread_db) to support the current
> > threading library (libthr) on FreeBSD which uses a kernel thread for each
> > user thread.  Support for thread names in both core dumps (via FreeBSD's
> > OS-specific NT_THRMISC core note) and live is supported as is scheduler
> > locking.  gcore generates register notes for each thread as well.
> > 
> > The first two patches are to binutils to support FreeBSD-specific core
> > notes.  The last four are to GDB.
> 
> (Apologies for fubar'ing the threading on the patches in this series.)
> 
> One other note I forgot to mention is that currently I leave the ptid for
> single-threaded processes as (pid, 0, 0) (i.e. I only use LWPs in PTIDs
> when there is more than one thread).  What is the best practice?  Should
> I always use LWPs in ptids instead?

I think that is the best approach.

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

* Re: [PATCH 0/6] Support kernel-backed user threads on FreeBSD
  2016-01-12 18:55 ` John Baldwin
  2016-01-12 19:06   ` Mark Kettenis
@ 2016-01-12 19:07   ` Paul_Koning
  2016-01-12 19:24     ` Pedro Alves
  1 sibling, 1 reply; 6+ messages in thread
From: Paul_Koning @ 2016-01-12 19:07 UTC (permalink / raw)
  To: jhb; +Cc: gdb-patches, binutils


> On Jan 12, 2016, at 1:55 PM, John Baldwin <jhb@freebsd.org> wrote:
> 
> On Monday, January 11, 2016 10:53:50 AM John Baldwin wrote:
>> This set of patches adds support for examining kernel-backed user threads on
>> FreeBSD.  There is more history in a comment in fbsd-nat.c, but this target
>> uses ptrace directly (instead of libthread_db) to support the current
>> threading library (libthr) on FreeBSD which uses a kernel thread for each
>> user thread.  Support for thread names in both core dumps (via FreeBSD's
>> OS-specific NT_THRMISC core note) and live is supported as is scheduler
>> locking.  gcore generates register notes for each thread as well.
>> 
>> The first two patches are to binutils to support FreeBSD-specific core
>> notes.  The last four are to GDB.
> 
> (Apologies for fubar'ing the threading on the patches in this series.)
> 
> One other note I forgot to mention is that currently I leave the ptid for
> single-threaded processes as (pid, 0, 0) (i.e. I only use LWPs in PTIDs
> when there is more than one thread).  What is the best practice?  Should
> I always use LWPs in ptids instead?

I would say always use the LWP.

For one thing, the process might start out single-threaded, then at some point midway through the debug session start more threads.  If you always use the LWP, the main thread doesn't change identity.  But if you fake the PTID to (pid,0,0) then that ID no longer applies once the new thread starts.  You'd end up with the confusion of apparently seeing a thread disappear and a new one appear in its place, when in reality that's just the main thread continuing in existence.

	paul

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

* Re: [PATCH 0/6] Support kernel-backed user threads on FreeBSD
  2016-01-12 19:07   ` Paul_Koning
@ 2016-01-12 19:24     ` Pedro Alves
  2016-01-12 21:08       ` John Baldwin
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2016-01-12 19:24 UTC (permalink / raw)
  To: Paul_Koning, jhb; +Cc: gdb-patches, binutils

On 01/12/2016 07:06 PM, Paul_Koning@Dell.com wrote:
> 
>> On Jan 12, 2016, at 1:55 PM, John Baldwin <jhb@freebsd.org> wrote:
>>
>> On Monday, January 11, 2016 10:53:50 AM John Baldwin wrote:

>> One other note I forgot to mention is that currently I leave the ptid for
>> single-threaded processes as (pid, 0, 0) (i.e. I only use LWPs in PTIDs
>> when there is more than one thread).  What is the best practice?  Should
>> I always use LWPs in ptids instead?
> 
> I would say always use the LWP.
> 
> For one thing, the process might start out single-threaded, then at some point midway through the debug session start more threads.  If you always use the LWP, the main thread doesn't change identity.  But if you fake the PTID to (pid,0,0) then that ID no longer applies once the new thread starts.  You'd end up with the confusion of apparently seeing a thread disappear and a new one appear in its place, when in reality that's just the main thread continuing in existence.

We have thread_change_ptid to handle that scenario, but it's indeed best
to avoid it if possible.

Thanks,
Pedro Alves

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

* Re: [PATCH 0/6] Support kernel-backed user threads on FreeBSD
  2016-01-12 19:24     ` Pedro Alves
@ 2016-01-12 21:08       ` John Baldwin
  0 siblings, 0 replies; 6+ messages in thread
From: John Baldwin @ 2016-01-12 21:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves, Paul_Koning, binutils

On Tuesday, January 12, 2016 07:24:45 PM Pedro Alves wrote:
> On 01/12/2016 07:06 PM, Paul_Koning@Dell.com wrote:
> > 
> >> On Jan 12, 2016, at 1:55 PM, John Baldwin <jhb@freebsd.org> wrote:
> >>
> >> On Monday, January 11, 2016 10:53:50 AM John Baldwin wrote:
> 
> >> One other note I forgot to mention is that currently I leave the ptid for
> >> single-threaded processes as (pid, 0, 0) (i.e. I only use LWPs in PTIDs
> >> when there is more than one thread).  What is the best practice?  Should
> >> I always use LWPs in ptids instead?
> > 
> > I would say always use the LWP.
> > 
> > For one thing, the process might start out single-threaded, then at some point midway through the debug session start more threads.  If you always use the LWP, the main thread doesn't change identity.  But if you fake the PTID to (pid,0,0) then that ID no longer applies once the new thread starts.  You'd end up with the confusion of apparently seeing a thread disappear and a new one appear in its place, when in reality that's just the main thread continuing in existence.
> 
> We have thread_change_ptid to handle that scenario, but it's indeed best
> to avoid it if possible.

Yes, I use that now.  However, I will update it to switch to LWPs always
and re-post (with --threaded this time).

-- 
John Baldwin

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

end of thread, other threads:[~2016-01-12 21:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 18:53 [PATCH 0/6] Support kernel-backed user threads on FreeBSD John Baldwin
2016-01-12 18:55 ` John Baldwin
2016-01-12 19:06   ` Mark Kettenis
2016-01-12 19:07   ` Paul_Koning
2016-01-12 19:24     ` Pedro Alves
2016-01-12 21:08       ` John Baldwin

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