* [patch] Fix for 'info threads' crashes if zombie threads exist
@ 2006-06-19 16:56 ` Jan Kratochvil
2006-06-20 17:05 ` RFC: " Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2006-06-19 16:56 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 724 bytes --]
Hi,
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=182116
Steps to Reproduce:
1.Start print-threads within GDB
2.Set a breakpoint in __pthread_unwind
3.Run the program
4.When the program stops at the breakpoint, run `info threads'
Patch disables handling of the TD_DEATH notification from __nptl_death_event()
and tries to keep the thread in TD_THR_ZOMBIE state as long as possible before
its LWP ceases to be. While expecting regressions so far no such was found,
statistically it improves some testcases (+24 passes,-14 fails), no negatives.
('longjmp' part not resolved; not reproducible for GDB-CVS)
Thread is now debuggable through pthread_exit(3) and the thread terminating
code.
Regards,
Jan Kratochvil
[-- Attachment #2: gdb-cvs20060619-pthread_exit.patch --]
[-- Type: text/plain, Size: 2932 bytes --]
Draft patch (for GDB-CVS) proposal for handling+tracing behing pthread_exit(3)
Patch disables handling of the TD_DEATH notification from __nptl_death_event()
and tries to keep the thread in TD_THR_ZOMBIE state as long as possible before
its LWP ceases to be. While expecting regressions so far no such was found,
statistically it improves some testcases (+24 passes,-14 fails), no negatives.
('longjmp' part not resolved; not reproducible for GDB-CVS)
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-thread-db.c
--- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16
+++ linux-thread-db.c 19 Jun 2006 16:27:16 -0000
@@ -541,6 +541,7 @@ enable_thread_event_reporting (void)
td_event_emptyset (&events);
td_event_addset (&events, TD_CREATE);
+#if 0 /* Do not track TD_DEATH to be able to trace pthread_exit(3). */
#ifdef HAVE_GNU_LIBC_VERSION_H
/* FIXME: kettenis/2000-04-23: The event reporting facility is
broken for TD_DEATH events in glibc 2.1.3, so don't enable it for
@@ -550,6 +551,7 @@ enable_thread_event_reporting (void)
&& (libc_major > 2 || (libc_major == 2 && libc_minor > 1)))
#endif
td_event_addset (&events, TD_DEATH);
+#endif
err = td_ta_set_event_p (thread_agent, &events);
if (err != TD_OK)
@@ -573,6 +575,7 @@ enable_thread_event_reporting (void)
return;
}
+#if 0 /* Do not track TD_DEATH to be able to trace pthread_exit(3). */
/* Set up the thread death event. */
err = enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr);
if (err != TD_OK)
@@ -581,6 +584,7 @@ enable_thread_event_reporting (void)
thread_db_err_str (err));
return;
}
+#endif
}
static void
@@ -1006,6 +1010,9 @@ thread_db_fetch_registers (int regno)
}
thread_info = find_thread_pid (inferior_ptid);
+ if (!thread_info)
+ error (_("Stopped at dead thread %ld; should not happen."),
+ (long) GET_THREAD (inferior_ptid));
thread_db_map_id2thr (thread_info, 1);
err = td_thr_getgregs_p (&thread_info->private->th, gregset);
@@ -1127,6 +1134,8 @@ thread_db_thread_alive (ptid_t ptid)
struct thread_info *thread_info;
thread_info = find_thread_pid (ptid);
+ if (!thread_info)
+ return 0;
thread_db_map_id2thr (thread_info, 0);
if (!thread_info->private->th_valid)
return 0;
@@ -1145,9 +1154,9 @@ thread_db_thread_alive (ptid_t ptid)
thread_info->private->ti_valid = 1;
}
- if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN
- || thread_info->private->ti.ti_state == TD_THR_ZOMBIE)
- return 0; /* A zombie thread. */
+ /* Never 0 on TD_THR_ZOMBIE to be able to trace pthread_exit(3). */
+ if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN)
+ return 0; /* A disappeared thread. */
return 1;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-06-19 16:56 ` [patch] Fix for 'info threads' crashes if zombie threads exist Jan Kratochvil
@ 2006-06-20 17:05 ` Jan Kratochvil
2006-06-20 17:11 ` Daniel Jacobowitz
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2006-06-20 17:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Daniel Jacobowitz, Christoph Bartoschek
Hi Christoph,
On Tue, 20 Jun 2006 18:21:41 +0200, Christoph Bartoschek wrote:
...
> I applied your patch to gdb 6.4 and do not see the error again.
sincerely thanks for the test.
Is there any objection regarding the patch import? What was the original
TD_DEATH notification reason? Not sure if the patch is compatible with
non-Linux platforms.
Thanks for any info,
Jan Kratochvil
On Mon, 19 Jun 2006 18:56:09 +0200, Jan Kratochvil wrote:
> Hi,
>
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=182116
>
> Steps to Reproduce:
> 1.Start print-threads within GDB
> 2.Set a breakpoint in __pthread_unwind
> 3.Run the program
> 4.When the program stops at the breakpoint, run `info threads'
>
>
> Patch disables handling of the TD_DEATH notification from __nptl_death_event()
> and tries to keep the thread in TD_THR_ZOMBIE state as long as possible before
> its LWP ceases to be. While expecting regressions so far no such was found,
> statistically it improves some testcases (+24 passes,-14 fails), no negatives.
> ('longjmp' part not resolved; not reproducible for GDB-CVS)
>
> Thread is now debuggable through pthread_exit(3) and the thread terminating
> code.
>
>
>
> Regards,
> Jan Kratochvil
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-06-20 17:05 ` RFC: " Jan Kratochvil
@ 2006-06-20 17:11 ` Daniel Jacobowitz
2006-06-20 18:54 ` Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-06-20 17:11 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Christoph Bartoschek
On Tue, Jun 20, 2006 at 07:04:51PM +0200, Jan Kratochvil wrote:
> Hi Christoph,
>
> On Tue, 20 Jun 2006 18:21:41 +0200, Christoph Bartoschek wrote:
> ...
> > I applied your patch to gdb 6.4 and do not see the error again.
>
> sincerely thanks for the test.
>
> Is there any objection regarding the patch import? What was the original
> TD_DEATH notification reason? Not sure if the patch is compatible with
> non-Linux platforms.
A little patience, please. It takes a while to review GDB patches,
especially non-obvious ones - and thread-db support seems to be quite
complicated.
TD_DEATH events were supported because there are all sorts of things
which can go wrong when you ask libthread_db about a thread that it
considers dead. At that point, as far as the library is concerned, the
thread is gone. A new thread can be created with the same thread ID -
even before this one exits. If you ask it to map that thread ID to an
LWP, it will refuse. After your patch, I strongly suspect there are
places where you could hit control-c and get mysterious errors from
GDB.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-06-20 17:11 ` Daniel Jacobowitz
@ 2006-06-20 18:54 ` Jan Kratochvil
2006-06-20 19:07 ` Daniel Jacobowitz
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2006-06-20 18:54 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Christoph Bartoschek
[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]
Hi Daniel,
On Tue, 20 Jun 2006 19:11:09 +0200, Daniel Jacobowitz wrote:
...
> TD_DEATH events were supported because there are all sorts of things
> which can go wrong when you ask libthread_db about a thread that it
> considers dead. At that point, as far as the library is concerned, the
> thread is gone.
> After your patch, I strongly suspect there are places where you could hit
> control-c and get mysterious errors from GDB.
OK... I checked now that my patch may have problems accessing TCB after:
if (IS_DETACHED (pd)) __free_tcb (pd);
for the detached threads and it even has problems before this point (not
analysed why):
Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread -1208153184 (unknown thread_db state 1)]
0x00000000 in ?? ()
Proposing the attached reduced patch with only the most important+safe part.
It still catches the initial terminating state with EXITING_BIT
(->TD_THR_ZOMBIE) where I hope most of the crashes/breakpoints may occur.
Still the perfect functionality would require patching libthread_db and it
looks to me a bit as a chicken&egg problem. :-)
> A new thread can be created with the same thread ID - even before this one
> exits.
Not sure of how much are non-Linux platforms a concern for these minor issues.
Apparently on Linux kernel the same LWP id cannot be created until the final
syscall __NR_exit.
Regards,
Jan Kratochvil
> A little patience, please. It takes a while to review GDB patches,
> especially non-obvious ones - and thread-db support seems to be quite
> complicated.
(Sorry, I only did not want to get the patch lost.)
[-- Attachment #2: gdb-cvs20060620-pthread_exit.patch --]
[-- Type: text/plain, Size: 1415 bytes --]
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-thread-db.c
--- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16
+++ linux-thread-db.c 20 Jun 2006 17:51:01 -0000
@@ -1006,6 +1006,9 @@ thread_db_fetch_registers (int regno)
}
thread_info = find_thread_pid (inferior_ptid);
+ if (!thread_info)
+ error (_("Stopped at dead thread %ld; should not happen."),
+ (long) GET_THREAD (inferior_ptid));
thread_db_map_id2thr (thread_info, 1);
err = td_thr_getgregs_p (&thread_info->private->th, gregset);
@@ -1127,6 +1130,8 @@ thread_db_thread_alive (ptid_t ptid)
struct thread_info *thread_info;
thread_info = find_thread_pid (ptid);
+ if (!thread_info)
+ return 0;
thread_db_map_id2thr (thread_info, 0);
if (!thread_info->private->th_valid)
return 0;
@@ -1145,9 +1150,9 @@ thread_db_thread_alive (ptid_t ptid)
thread_info->private->ti_valid = 1;
}
- if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN
- || thread_info->private->ti.ti_state == TD_THR_ZOMBIE)
- return 0; /* A zombie thread. */
+ /* Never 0 on TD_THR_ZOMBIE to be able to trace pthread_exit(3). */
+ if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN)
+ return 0; /* A disappeared thread. */
return 1;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-06-20 18:54 ` Jan Kratochvil
@ 2006-06-20 19:07 ` Daniel Jacobowitz
2006-07-13 4:01 ` Daniel Jacobowitz
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-06-20 19:07 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Christoph Bartoschek
On Tue, Jun 20, 2006 at 08:53:26PM +0200, Jan Kratochvil wrote:
> > A new thread can be created with the same thread ID - even before this one
> > exits.
>
> Not sure of how much are non-Linux platforms a concern for these minor issues.
Hint: the file was renamed a while back to "linux-thread-db.c".
> Apparently on Linux kernel the same LWP id cannot be created until the final
> syscall __NR_exit.
No, that's the LWP id. In linux-thread-db.c things are still indexed
by thread ID, which is a pointer in NPTL - and NPTL will aggressively
reuse them.
I think the real fix to this problem is going to involve less
dependence on thread IDs. I've been migrating the code away from that
and I'll try to find some time in the next week to finish the job;
maybe that will help.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-06-20 19:07 ` Daniel Jacobowitz
@ 2006-07-13 4:01 ` Daniel Jacobowitz
2006-07-13 13:28 ` Jan Kratochvil
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-07-13 4:01 UTC (permalink / raw)
To: Jan Kratochvil, gdb-patches, Christoph Bartoschek
On Tue, Jun 20, 2006 at 03:07:40PM -0400, Daniel Jacobowitz wrote:
> I think the real fix to this problem is going to involve less
> dependence on thread IDs. I've been migrating the code away from that
> and I'll try to find some time in the next week to finish the job;
> maybe that will help.
Here's an alternative patch that seems to work for the same test.
Could one of you let me know if it also helps for the problems you saw?
The main change is to remove the thread_db_thread_alive function. My
ptid_t representation change means that we can call the linux-nat.c
implementation directly. This change means we might have two threads
"live" at the same time with the same TID - but they'll have different
LWP IDs, so different PTIDs, so GDB won't get confused.
It also (long overdue) removes the dependence on fill_gregset, and
removes a not especially useful call into libthread_db for converting
threads to strings. There are a number of more possible cleanups,
but this hits the big ones.
--
Daniel Jacobowitz
CodeSourcery
2006-07-12 Daniel Jacobowitz <dan@codesourcery.com>
* linux-thread-db.c (td_thr_getfpregs_p, td_thr_getgregs_p)
(td_thr_setfpregs_p, td_thr_setgregs_p, thread_db_get_info)
(thread_db_fetch_registers, thread_db_store_registers)
(thread_db_thread_alive): Delete.
(thread_db_load): Don't look up regset functions.
(thread_db_pid_to_str): Simplify.
(init_thread_db_ops): Do not set to_fetch_registers,
to_store_registers, or to_thread_alive.
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-thread-db.c
--- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16
+++ linux-thread-db.c 13 Jul 2006 03:53:34 -0000
@@ -105,14 +105,6 @@ static td_err_e (*td_ta_event_getmsg_p)
static td_err_e (*td_thr_validate_p) (const td_thrhandle_t *th);
static td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th,
td_thrinfo_t *infop);
-static td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th,
- gdb_prfpregset_t *regset);
-static td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th,
- prgregset_t gregs);
-static td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th,
- const gdb_prfpregset_t *fpregs);
-static td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th,
- prgregset_t gregs);
static td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th,
int event);
@@ -330,27 +322,6 @@ thread_db_map_id2thr (struct thread_info
else
thread_info->private->th_valid = 1;
}
-
-static td_thrinfo_t *
-thread_db_get_info (struct thread_info *thread_info)
-{
- td_err_e err;
-
- if (thread_info->private->ti_valid)
- return &thread_info->private->ti;
-
- if (!thread_info->private->th_valid)
- thread_db_map_id2thr (thread_info, 1);
-
- err =
- td_thr_get_info_p (&thread_info->private->th, &thread_info->private->ti);
- if (err != TD_OK)
- error (_("thread_db_get_info: cannot get thread info: %s"),
- thread_db_err_str (err));
-
- thread_info->private->ti_valid = 1;
- return &thread_info->private->ti;
-}
\f
/* Convert between user-level thread ids and LWP ids. */
@@ -461,22 +432,6 @@ thread_db_load (void)
if (td_thr_get_info_p == NULL)
return 0;
- td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
- if (td_thr_getfpregs_p == NULL)
- return 0;
-
- td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
- if (td_thr_getgregs_p == NULL)
- return 0;
-
- td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
- if (td_thr_setfpregs_p == NULL)
- return 0;
-
- td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
- if (td_thr_setgregs_p == NULL)
- return 0;
-
/* Initialize the library. */
err = td_init_p ();
if (err != TD_OK)
@@ -991,81 +946,6 @@ thread_db_xfer_partial (struct target_op
}
static void
-thread_db_fetch_registers (int regno)
-{
- struct thread_info *thread_info;
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_fetch_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- err = td_thr_getgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot fetch general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- err = td_thr_getfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot get floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- /* Note that we must call supply_gregset after calling the thread_db
- routines because the thread_db routines call ps_lgetgregs and
- friends which clobber GDB's register cache. */
- supply_gregset ((gdb_gregset_t *) gregset);
- supply_fpregset (&fpregset);
-}
-
-static void
-thread_db_store_registers (int regno)
-{
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
- struct thread_info *thread_info;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_store_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- if (regno != -1)
- {
- gdb_byte raw[MAX_REGISTER_SIZE];
-
- regcache_raw_collect (current_regcache, regno, raw);
- thread_db_fetch_registers (-1);
- regcache_raw_supply (current_regcache, regno, raw);
- }
-
- fill_gregset ((gdb_gregset_t *) gregset, -1);
- fill_fpregset (&fpregset, -1);
-
- err = td_thr_setgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot store general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
- err = td_thr_setfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot store floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-}
-
-static void
thread_db_kill (void)
{
/* There's no need to save & restore inferior_ptid here, since the
@@ -1117,48 +997,6 @@ thread_db_mourn_inferior (void)
}
static int
-thread_db_thread_alive (ptid_t ptid)
-{
- td_thrhandle_t th;
- td_err_e err;
-
- if (is_thread (ptid))
- {
- struct thread_info *thread_info;
- thread_info = find_thread_pid (ptid);
-
- thread_db_map_id2thr (thread_info, 0);
- if (!thread_info->private->th_valid)
- return 0;
-
- err = td_thr_validate_p (&thread_info->private->th);
- if (err != TD_OK)
- return 0;
-
- if (!thread_info->private->ti_valid)
- {
- err =
- td_thr_get_info_p (&thread_info->private->th,
- &thread_info->private->ti);
- if (err != TD_OK)
- return 0;
- thread_info->private->ti_valid = 1;
- }
-
- if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN
- || thread_info->private->ti.ti_state == TD_THR_ZOMBIE)
- return 0; /* A zombie thread. */
-
- return 1;
- }
-
- if (target_beneath->to_thread_alive)
- return target_beneath->to_thread_alive (ptid);
-
- return 0;
-}
-
-static int
find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
{
td_thrinfo_t ti;
@@ -1200,32 +1038,18 @@ thread_db_pid_to_str (ptid_t ptid)
if (is_thread (ptid))
{
static char buf[64];
- td_thrinfo_t *ti_p;
- td_err_e err;
struct thread_info *thread_info;
thread_info = find_thread_pid (ptid);
- thread_db_map_id2thr (thread_info, 0);
- if (!thread_info->private->th_valid)
- {
- snprintf (buf, sizeof (buf), "Thread %ld (Missing)",
- GET_THREAD (ptid));
- return buf;
- }
-
- ti_p = thread_db_get_info (thread_info);
-
- if (ti_p->ti_state == TD_THR_ACTIVE && ti_p->ti_lid != 0)
- {
- snprintf (buf, sizeof (buf), "Thread %ld (LWP %d)",
- (long) ti_p->ti_tid, ti_p->ti_lid);
- }
+ if (thread_info == NULL)
+ snprintf (buf, sizeof (buf), "Thread %ld (LWP %ld) (Missing)",
+ GET_THREAD (ptid), GET_LWP (ptid));
+ else if (thread_info->private->dying)
+ snprintf (buf, sizeof (buf), "Thread %ld (LWP %ld) (Exiting)",
+ GET_THREAD (ptid), GET_LWP (ptid));
else
- {
- snprintf (buf, sizeof (buf), "Thread %ld (%s)",
- (long) ti_p->ti_tid,
- thread_db_state_str (ti_p->ti_state));
- }
+ snprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
+ GET_THREAD (ptid), GET_LWP (ptid));
return buf;
}
@@ -1306,14 +1130,11 @@ init_thread_db_ops (void)
thread_db_ops.to_detach = thread_db_detach;
thread_db_ops.to_resume = thread_db_resume;
thread_db_ops.to_wait = thread_db_wait;
- thread_db_ops.to_fetch_registers = thread_db_fetch_registers;
- thread_db_ops.to_store_registers = thread_db_store_registers;
thread_db_ops.to_xfer_partial = thread_db_xfer_partial;
thread_db_ops.to_kill = thread_db_kill;
thread_db_ops.to_create_inferior = thread_db_create_inferior;
thread_db_ops.to_post_startup_inferior = thread_db_post_startup_inferior;
thread_db_ops.to_mourn_inferior = thread_db_mourn_inferior;
- thread_db_ops.to_thread_alive = thread_db_thread_alive;
thread_db_ops.to_find_new_threads = thread_db_find_new_threads;
thread_db_ops.to_pid_to_str = thread_db_pid_to_str;
thread_db_ops.to_stratum = thread_stratum;
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 4:01 ` Daniel Jacobowitz
@ 2006-07-13 13:28 ` Jan Kratochvil
2006-07-13 13:43 ` Daniel Jacobowitz
2006-07-13 18:50 ` Mark Kettenis
2006-07-14 13:15 ` Christoph Bartoschek
2 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2006-07-13 13:28 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Christoph Bartoschek
[-- Attachment #1: Type: text/plain, Size: 805 bytes --]
On Thu, 13 Jul 2006 06:01:35 +0200, Daniel Jacobowitz wrote:
> On Tue, Jun 20, 2006 at 03:07:40PM -0400, Daniel Jacobowitz wrote:
> > I think the real fix to this problem is going to involve less
> > dependence on thread IDs. I've been migrating the code away from that
> > and I'll try to find some time in the next week to finish the job;
> > maybe that will help.
>
> Here's an alternative patch that seems to work for the same test.
> Could one of you let me know if it also helps for the problems you saw?
The test
1.Start print-threads within GDB
2.Set a breakpoint in __pthread_unwind
3.Run the program
4.When the program stops at the breakpoint, run `info threads'
still fails the same way. Logs attached - attached also that patch of mine
fixing/workaround it in some way.
Thanks,
Jan
[-- Attachment #2: print-threads.log --]
[-- Type: text/plain, Size: 4894 bytes --]
+ gdb -nx ../../gdb
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run -nx print-threads
Starting program: /home/lace/redhat/sources/gdb-clean/gdb -nx print-threads
GNU gdb 6.5.50.20060713-cvs
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b __pthread_unwind
Function "__pthread_unwind" not defined.
Make breakpoint pending on future shared library load? (y or [n]) Breakpoint 1 (__pthread_unwind) pending.
(gdb) r
Starting program: /home/lace/redhat/sources/gdb-clean/testsuite/gdb.threads/print-threads
[Thread debugging using libthread_db enabled]
[New Thread -1208133952 (LWP 22039)]
Breakpoint 2 at 0x443b0634
Pending breakpoint "__pthread_unwind" resolved
[New Thread -1208136800 (LWP 23163)]
[New Thread -1218626656 (LWP 23164)]
[New Thread -1229120608 (LWP 23165)]
[New Thread -1239610464 (LWP 23166)]
[New Thread -1250100320 (LWP 23167)]
[Switching to Thread -1208136800 (zombie)]
Breakpoint 2, 0x443b0634 in __pthread_unwind () from /lib/libpthread.so.0
(gdb) info threads
6 Thread -1250100320 (LWP 23167) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
5 Thread -1239610464 (LWP 23166) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
4 Thread -1229120608 (LWP 23165) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
3 Thread -1218626656 (LWP 23164) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
1 Thread -1208133952 (LWP 22039) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
Detaching after fork from child process 22039.
Detaching after fork from child process 23161.
Program received signal SIGSEGV, Segmentation fault.
thread_db_map_id2thr (thread_info=0x0, fatal=1) at .././gdb-clean/linux-thread-db.c:318
318 if (thread_info->private->th_valid)
(gdb) bt
#0 thread_db_map_id2thr (thread_info=0x0, fatal=1) at .././gdb-clean/linux-thread-db.c:318
#1 0x0809737e in thread_db_fetch_registers (regno=8) at .././gdb-clean/linux-thread-db.c:1009
#2 0x080e1739 in regcache_raw_read (regcache=0x9b83210, regnum=8, buf=0xbfe734a0 "\b") at regcache.c:590
#3 0x080e3482 in deprecated_read_register_gen (regnum=8, buf=0xbfe734a0 "\b") at regcache.c:659
#4 0x080e354d in read_register (regnum=8) at regcache.c:944
#5 0x080e37cb in read_pc_pid (ptid={pid = 22039, lwp = 23163, tid = -1208136800}) at regcache.c:1080
#6 0x080e3845 in read_pc () at regcache.c:1093
#7 0x0811b50e in switch_to_thread (ptid={pid = 22039, lwp = 23163, tid = -1208136800}) at thread.c:467
#8 0x0811bc43 in info_threads_command (arg=0x0, from_tty=1) at thread.c:435
#9 0x080840b3 in execute_command (p=0x9b4d134 "", from_tty=1) at top.c:452
#10 0x081203af in command_handler (command=0x9b4d128 "info threads") at event-top.c:512
#11 0x0812110d in command_line_handler (rl=0x9baf7b0 "info threads") at event-top.c:797
#12 0x081d1052 in rl_callback_read_char () at callback.c:204
#13 0x0812057b in rl_callback_read_char_wrapper (client_data=0x0) at event-top.c:178
#14 0x0811ff00 in handle_file_event (event_file_desc=0) at event-loop.c:730
#15 0x0811f3c9 in process_event () at event-loop.c:343
#16 0x0811fb85 in gdb_do_one_event (data=0x0) at event-loop.c:380
#17 0x0811c9b3 in catch_errors (func=0x811fa70 <gdb_do_one_event>, func_args=0x0, errstring=0x8265265 "", mask=6)
at exceptions.c:515
#18 0x080c62d9 in tui_command_loop (data=0x0) at .././gdb-clean/tui/tui-interp.c:151
#19 0x0811cfbf in current_interp_command_loop () at interps.c:278
#20 0x0807d44b in captured_command_loop (data=0x0) at .././gdb-clean/main.c:101
#21 0x0811c9b3 in catch_errors (func=0x807d440 <captured_command_loop>, func_args=0x0, errstring=0x8265265 "", mask=6)
at exceptions.c:515
#22 0x0807dc44 in captured_main (data=0xbfe73944) at .././gdb-clean/main.c:834
#23 0x0811c9b3 in catch_errors (func=0x807d480 <captured_main>, func_args=0xbfe73944, errstring=0x8265265 "", mask=6)
at exceptions.c:515
#24 0x0807d431 in gdb_main (args=0xbfe73944) at .././gdb-clean/main.c:843
#25 0x0807d3f5 in main (argc=Cannot access memory at address 0x5617
) at gdb.c:35
(gdb) quit
The program is running. Exit anyway? (y or n)
[-- Attachment #3: print-threads-patched.log --]
[-- Type: text/plain, Size: 2564 bytes --]
+ gdb -nx ../../gdb
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run -nx print-threads
Starting program: /home/lace/redhat/sources/gdb-clean/gdb -nx print-threads
GNU gdb 6.5.50.20060713-cvs
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b __pthread_unwind
Function "__pthread_unwind" not defined.
Make breakpoint pending on future shared library load? (y or [n]) Breakpoint 1 (__pthread_unwind) pending.
(gdb) r
Starting program: /home/lace/redhat/sources/gdb-clean/testsuite/gdb.threads/print-threads
[Thread debugging using libthread_db enabled]
[New Thread -1208396096 (LWP 25838)]
Breakpoint 2 at 0x443b0634
Pending breakpoint "__pthread_unwind" resolved
[New Thread -1208398944 (LWP 26959)]
[New Thread -1218888800 (LWP 26960)]
[New Thread -1229382752 (LWP 26961)]
[New Thread -1239872608 (LWP 26962)]
[New Thread -1250362464 (LWP 26963)]
[Switching to Thread -1208398944 (zombie)]
Breakpoint 2, 0x443b0634 in __pthread_unwind () from /lib/libpthread.so.0
(gdb) info threads
6 Thread -1250362464 (LWP 26963) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
5 Thread -1239872608 (LWP 26962) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
4 Thread -1229382752 (LWP 26961) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
3 Thread -1218888800 (LWP 26960) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
* 2 Thread -1208398944 (zombie) 0x443b0634 in __pthread_unwind () from /lib/libpthread.so.0
1 Thread -1208396096 (LWP 25838) 0x44031822 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) quit
The program is running. Exit anyway? (y or n) Detaching after fork from child process 25838.
Detaching after fork from child process 26957.
Program exited normally.
(gdb) quit
[-- Attachment #4: gdb-cvs20060620-pthread_exit.patch --]
[-- Type: text/plain, Size: 1415 bytes --]
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-thread-db.c
--- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16
+++ linux-thread-db.c 20 Jun 2006 17:51:01 -0000
@@ -1006,6 +1006,9 @@ thread_db_fetch_registers (int regno)
}
thread_info = find_thread_pid (inferior_ptid);
+ if (!thread_info)
+ error (_("Stopped at dead thread %ld; should not happen."),
+ (long) GET_THREAD (inferior_ptid));
thread_db_map_id2thr (thread_info, 1);
err = td_thr_getgregs_p (&thread_info->private->th, gregset);
@@ -1127,6 +1130,8 @@ thread_db_thread_alive (ptid_t ptid)
struct thread_info *thread_info;
thread_info = find_thread_pid (ptid);
+ if (!thread_info)
+ return 0;
thread_db_map_id2thr (thread_info, 0);
if (!thread_info->private->th_valid)
return 0;
@@ -1145,9 +1150,9 @@ thread_db_thread_alive (ptid_t ptid)
thread_info->private->ti_valid = 1;
}
- if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN
- || thread_info->private->ti.ti_state == TD_THR_ZOMBIE)
- return 0; /* A zombie thread. */
+ /* Never 0 on TD_THR_ZOMBIE to be able to trace pthread_exit(3). */
+ if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN)
+ return 0; /* A disappeared thread. */
return 1;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 13:28 ` Jan Kratochvil
@ 2006-07-13 13:43 ` Daniel Jacobowitz
2006-07-13 15:07 ` Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-07-13 13:43 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Christoph Bartoschek
On Thu, Jul 13, 2006 at 03:26:23PM +0200, Jan Kratochvil wrote:
> The test
> 1.Start print-threads within GDB
> 2.Set a breakpoint in __pthread_unwind
> 3.Run the program
> 4.When the program stops at the breakpoint, run `info threads'
>
> still fails the same way. Logs attached - attached also that patch of mine
> fixing/workaround it in some way.
You didn't apply the patch, or else you didn't rebuild, I think.
> Program received signal SIGSEGV, Segmentation fault.
> thread_db_map_id2thr (thread_info=0x0, fatal=1) at .././gdb-clean/linux-thread-db.c:318
> 318 if (thread_info->private->th_valid)
> (gdb) bt
> #0 thread_db_map_id2thr (thread_info=0x0, fatal=1) at .././gdb-clean/linux-thread-db.c:318
> #1 0x0809737e in thread_db_fetch_registers (regno=8) at .././gdb-clean/linux-thread-db.c:1009
From the patch:
(thread_db_fetch_registers, thread_db_store_registers)
(thread_db_thread_alive): Delete.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 13:43 ` Daniel Jacobowitz
@ 2006-07-13 15:07 ` Jan Kratochvil
0 siblings, 0 replies; 15+ messages in thread
From: Jan Kratochvil @ 2006-07-13 15:07 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Christoph Bartoschek
On Thu, 13 Jul 2006 15:43:34 +0200, Daniel Jacobowitz wrote:
> On Thu, Jul 13, 2006 at 03:26:23PM +0200, Jan Kratochvil wrote:
> > The test
> > 1.Start print-threads within GDB
> > 2.Set a breakpoint in __pthread_unwind
> > 3.Run the program
> > 4.When the program stops at the breakpoint, run `info threads'
> >
> > still fails the same way. Logs attached - attached also that patch of mine
> > fixing/workaround it in some way.
>
> You didn't apply the patch, or else you didn't rebuild, I think.
Did not apply the patch. I expected it is already committed.
Works for me now, thanks.
Regards,
Jan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 4:01 ` Daniel Jacobowitz
2006-07-13 13:28 ` Jan Kratochvil
@ 2006-07-13 18:50 ` Mark Kettenis
2006-07-13 19:47 ` Daniel Jacobowitz
2006-07-14 13:15 ` Christoph Bartoschek
2 siblings, 1 reply; 15+ messages in thread
From: Mark Kettenis @ 2006-07-13 18:50 UTC (permalink / raw)
To: drow; +Cc: lace, gdb-patches, bartoschek
> Date: Thu, 13 Jul 2006 00:01:35 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> The main change is to remove the thread_db_thread_alive function. My
> ptid_t representation change means that we can call the linux-nat.c
> implementation directly. This change means we might have two threads
> "live" at the same time with the same TID - but they'll have different
> LWP IDs, so different PTIDs, so GDB won't get confused.
Probably a good idea, given the fact that it's unlikely we'll see a
N:M threads library on Linux is the near future.
> It also (long overdue) removes the dependence on fill_gregset, and
> removes a not especially useful call into libthread_db for converting
> threads to strings. There are a number of more possible cleanups,
> but this hits the big ones.
Doesn't your simplification of thread_db_pid_to_str() lose some useful
information about the extra system thread that the LinuxThreads
library used to have (I'm not sure if that wart is still present in
NPTL)?
You might want to look at implementing to_extra_thread_info() to give
some state information; see bsd-uthread.c for an example.
Mark
> 2006-07-12 Daniel Jacobowitz <dan@codesourcery.com>
>
> * linux-thread-db.c (td_thr_getfpregs_p, td_thr_getgregs_p)
> (td_thr_setfpregs_p, td_thr_setgregs_p, thread_db_get_info)
> (thread_db_fetch_registers, thread_db_store_registers)
> (thread_db_thread_alive): Delete.
> (thread_db_load): Don't look up regset functions.
> (thread_db_pid_to_str): Simplify.
> (init_thread_db_ops): Do not set to_fetch_registers,
> to_store_registers, or to_thread_alive.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 18:50 ` Mark Kettenis
@ 2006-07-13 19:47 ` Daniel Jacobowitz
2006-07-13 23:16 ` Mark Kettenis
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-07-13 19:47 UTC (permalink / raw)
To: Mark Kettenis; +Cc: lace, gdb-patches, bartoschek
On Thu, Jul 13, 2006 at 08:49:52PM +0200, Mark Kettenis wrote:
> Probably a good idea, given the fact that it's unlikely we'll see a
> N:M threads library on Linux is the near future.
Exactly. I've already removed functional M:N support in the interest
of improving the 1:1 support we're actually using; these are some of
the remaining vestigal bits.
> > It also (long overdue) removes the dependence on fill_gregset, and
> > removes a not especially useful call into libthread_db for converting
> > threads to strings. There are a number of more possible cleanups,
> > but this hits the big ones.
>
> Doesn't your simplification of thread_db_pid_to_str() lose some useful
> information about the extra system thread that the LinuxThreads
> library used to have (I'm not sure if that wart is still present in
> NPTL)?
It's not still present in NPTL.
It doesn't actually lose anything about the manager thread, because we
were never providing any in the first place. We were only checking the
thread state, and the manager would always be TD_THR_ACTIVE. That was
really only useful on platforms which did use the other states, like
STOPPED and SLEEP, but LinuxThreads didn't.
Such information might have been handy - but we don't have any reliable
way to identify the manager thread :-(
> You might want to look at implementing to_extra_thread_info() to give
> some state information; see bsd-uthread.c for an example.
... and in any case that's a better place for the state information.
Nice. Unfortunately we don't really have useful state bits. I could
probably move the exiting/missing text there. I'll keep that in mind
for a future update, thanks!
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 19:47 ` Daniel Jacobowitz
@ 2006-07-13 23:16 ` Mark Kettenis
2006-07-18 22:55 ` Daniel Jacobowitz
0 siblings, 1 reply; 15+ messages in thread
From: Mark Kettenis @ 2006-07-13 23:16 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Date: Thu, 13 Jul 2006 15:47:31 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> > You might want to look at implementing to_extra_thread_info() to give
> > some state information; see bsd-uthread.c for an example.
>
> ... and in any case that's a better place for the state information.
> Nice. Unfortunately we don't really have useful state bits. I could
> probably move the exiting/missing text there.
That's what I had in mind...
> I'll keep that in mind for a future update, thanks!
Well, if this patch doesn't cause any regressions, there is no real
reason to hold it back. You can always add the to_extra_thread_info()
implementation later.
Mark
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 4:01 ` Daniel Jacobowitz
2006-07-13 13:28 ` Jan Kratochvil
2006-07-13 18:50 ` Mark Kettenis
@ 2006-07-14 13:15 ` Christoph Bartoschek
2006-07-14 13:36 ` Daniel Jacobowitz
2 siblings, 1 reply; 15+ messages in thread
From: Christoph Bartoschek @ 2006-07-14 13:15 UTC (permalink / raw)
To: Jan Kratochvil, gdb-patches
Am Donnerstag, 13. Juli 2006 06:01 schrieb Daniel Jacobowitz:
> On Tue, Jun 20, 2006 at 03:07:40PM -0400, Daniel Jacobowitz wrote:
> > I think the real fix to this problem is going to involve less
> > dependence on thread IDs. I've been migrating the code away from that
> > and I'll try to find some time in the next week to finish the job;
> > maybe that will help.
>
> Here's an alternative patch that seems to work for the same test.
> Could one of you let me know if it also helps for the problems you saw?
>
> The main change is to remove the thread_db_thread_alive function. My
> ptid_t representation change means that we can call the linux-nat.c
> implementation directly. This change means we might have two threads
> "live" at the same time with the same TID - but they'll have different
> LWP IDs, so different PTIDs, so GDB won't get confused.
>
> It also (long overdue) removes the dependence on fill_gregset, and
> removes a not especially useful call into libthread_db for converting
> threads to strings. There are a number of more possible cleanups,
> but this hits the big ones.
Hi,
on which revision should I apply the patch to get the most meaningful results?
Greetings
Christoph Bartoschek
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-14 13:15 ` Christoph Bartoschek
@ 2006-07-14 13:36 ` Daniel Jacobowitz
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-07-14 13:36 UTC (permalink / raw)
To: Christoph Bartoschek; +Cc: Jan Kratochvil, gdb-patches
On Fri, Jul 14, 2006 at 03:15:53PM +0200, Christoph Bartoschek wrote:
> on which revision should I apply the patch to get the most meaningful results?
It applies to CVS HEAD, and probably also to the 6.5 release.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Re: [patch] Fix for 'info threads' crashes if zombie threads exist
2006-07-13 23:16 ` Mark Kettenis
@ 2006-07-18 22:55 ` Daniel Jacobowitz
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Jacobowitz @ 2006-07-18 22:55 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Fri, Jul 14, 2006 at 01:16:14AM +0200, Mark Kettenis wrote:
> Well, if this patch doesn't cause any regressions, there is no real
> reason to hold it back. You can always add the to_extra_thread_info()
> implementation later.
May as well do it now; thank you for the pointer.
I have tested and checked in this variant.
--
Daniel Jacobowitz
CodeSourcery
2006-07-18 Daniel Jacobowitz <dan@codesourcery.com>
* linux-thread-db.c (td_thr_getfpregs_p, td_thr_getgregs_p)
(td_thr_setfpregs_p, td_thr_setgregs_p, thread_db_get_info)
(thread_db_fetch_registers, thread_db_store_registers)
(thread_db_thread_alive, thread_db_state_str): Delete.
(thread_db_load): Don't look up regset functions.
(thread_db_pid_to_str): Simplify.
(thread_db_extra_thread_info): New.
(init_thread_db_ops): Do not set to_fetch_registers,
to_store_registers, or to_thread_alive. Set to_extra_thread_info.
* Makefile.in: Remove linux-thread-db.o rule.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.830
diff -u -p -r1.830 Makefile.in
--- Makefile.in 17 Jul 2006 19:34:57 -0000 1.830
+++ Makefile.in 18 Jul 2006 22:42:54 -0000
@@ -1534,11 +1534,6 @@ printcmd.o: $(srcdir)/printcmd.c
procfs.o: $(srcdir)/procfs.c
$(CC) -c $(INTERNAL_WARN_CFLAGS) $(srcdir)/procfs.c
-# FIXME: Thread-db.o gets warnings because the definitions of the register
-# sets are different from kernel to kernel.
-linux-thread-db.o: $(srcdir)/linux-thread-db.c
- $(CC) -c $(INTERNAL_WARN_CFLAGS) $(srcdir)/linux-thread-db.c
-
v850ice.o: $(srcdir)/v850ice.c
$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \
$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-thread-db.c
--- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16
+++ linux-thread-db.c 18 Jul 2006 22:42:55 -0000
@@ -105,14 +105,6 @@ static td_err_e (*td_ta_event_getmsg_p)
static td_err_e (*td_thr_validate_p) (const td_thrhandle_t *th);
static td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th,
td_thrinfo_t *infop);
-static td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th,
- gdb_prfpregset_t *regset);
-static td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th,
- prgregset_t gregs);
-static td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th,
- const gdb_prfpregset_t *fpregs);
-static td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th,
- prgregset_t gregs);
static td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th,
int event);
@@ -220,31 +212,6 @@ thread_db_err_str (td_err_e err)
return buf;
}
}
-
-static char *
-thread_db_state_str (td_thr_state_e state)
-{
- static char buf[64];
-
- switch (state)
- {
- case TD_THR_STOPPED:
- return "stopped by debugger";
- case TD_THR_RUN:
- return "runnable";
- case TD_THR_ACTIVE:
- return "active";
- case TD_THR_ZOMBIE:
- return "zombie";
- case TD_THR_SLEEP:
- return "sleeping";
- case TD_THR_STOPPED_ASLEEP:
- return "stopped by debugger AND blocked";
- default:
- snprintf (buf, sizeof (buf), "unknown thread_db state %d", state);
- return buf;
- }
-}
\f
/* A callback function for td_ta_thr_iter, which we use to map all
threads to LWPs.
@@ -330,27 +297,6 @@ thread_db_map_id2thr (struct thread_info
else
thread_info->private->th_valid = 1;
}
-
-static td_thrinfo_t *
-thread_db_get_info (struct thread_info *thread_info)
-{
- td_err_e err;
-
- if (thread_info->private->ti_valid)
- return &thread_info->private->ti;
-
- if (!thread_info->private->th_valid)
- thread_db_map_id2thr (thread_info, 1);
-
- err =
- td_thr_get_info_p (&thread_info->private->th, &thread_info->private->ti);
- if (err != TD_OK)
- error (_("thread_db_get_info: cannot get thread info: %s"),
- thread_db_err_str (err));
-
- thread_info->private->ti_valid = 1;
- return &thread_info->private->ti;
-}
\f
/* Convert between user-level thread ids and LWP ids. */
@@ -461,22 +407,6 @@ thread_db_load (void)
if (td_thr_get_info_p == NULL)
return 0;
- td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
- if (td_thr_getfpregs_p == NULL)
- return 0;
-
- td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
- if (td_thr_getgregs_p == NULL)
- return 0;
-
- td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
- if (td_thr_setfpregs_p == NULL)
- return 0;
-
- td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
- if (td_thr_setgregs_p == NULL)
- return 0;
-
/* Initialize the library. */
err = td_init_p ();
if (err != TD_OK)
@@ -991,81 +921,6 @@ thread_db_xfer_partial (struct target_op
}
static void
-thread_db_fetch_registers (int regno)
-{
- struct thread_info *thread_info;
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_fetch_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- err = td_thr_getgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot fetch general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- err = td_thr_getfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot get floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- /* Note that we must call supply_gregset after calling the thread_db
- routines because the thread_db routines call ps_lgetgregs and
- friends which clobber GDB's register cache. */
- supply_gregset ((gdb_gregset_t *) gregset);
- supply_fpregset (&fpregset);
-}
-
-static void
-thread_db_store_registers (int regno)
-{
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
- struct thread_info *thread_info;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_store_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- if (regno != -1)
- {
- gdb_byte raw[MAX_REGISTER_SIZE];
-
- regcache_raw_collect (current_regcache, regno, raw);
- thread_db_fetch_registers (-1);
- regcache_raw_supply (current_regcache, regno, raw);
- }
-
- fill_gregset ((gdb_gregset_t *) gregset, -1);
- fill_fpregset (&fpregset, -1);
-
- err = td_thr_setgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot store general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
- err = td_thr_setfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot store floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-}
-
-static void
thread_db_kill (void)
{
/* There's no need to save & restore inferior_ptid here, since the
@@ -1117,48 +972,6 @@ thread_db_mourn_inferior (void)
}
static int
-thread_db_thread_alive (ptid_t ptid)
-{
- td_thrhandle_t th;
- td_err_e err;
-
- if (is_thread (ptid))
- {
- struct thread_info *thread_info;
- thread_info = find_thread_pid (ptid);
-
- thread_db_map_id2thr (thread_info, 0);
- if (!thread_info->private->th_valid)
- return 0;
-
- err = td_thr_validate_p (&thread_info->private->th);
- if (err != TD_OK)
- return 0;
-
- if (!thread_info->private->ti_valid)
- {
- err =
- td_thr_get_info_p (&thread_info->private->th,
- &thread_info->private->ti);
- if (err != TD_OK)
- return 0;
- thread_info->private->ti_valid = 1;
- }
-
- if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN
- || thread_info->private->ti.ti_state == TD_THR_ZOMBIE)
- return 0; /* A zombie thread. */
-
- return 1;
- }
-
- if (target_beneath->to_thread_alive)
- return target_beneath->to_thread_alive (ptid);
-
- return 0;
-}
-
-static int
find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
{
td_thrinfo_t ti;
@@ -1200,32 +1013,15 @@ thread_db_pid_to_str (ptid_t ptid)
if (is_thread (ptid))
{
static char buf[64];
- td_thrinfo_t *ti_p;
- td_err_e err;
struct thread_info *thread_info;
thread_info = find_thread_pid (ptid);
- thread_db_map_id2thr (thread_info, 0);
- if (!thread_info->private->th_valid)
- {
- snprintf (buf, sizeof (buf), "Thread %ld (Missing)",
- GET_THREAD (ptid));
- return buf;
- }
-
- ti_p = thread_db_get_info (thread_info);
-
- if (ti_p->ti_state == TD_THR_ACTIVE && ti_p->ti_lid != 0)
- {
- snprintf (buf, sizeof (buf), "Thread %ld (LWP %d)",
- (long) ti_p->ti_tid, ti_p->ti_lid);
- }
+ if (thread_info == NULL)
+ snprintf (buf, sizeof (buf), "Thread %ld (LWP %ld) (Missing)",
+ GET_THREAD (ptid), GET_LWP (ptid));
else
- {
- snprintf (buf, sizeof (buf), "Thread %ld (%s)",
- (long) ti_p->ti_tid,
- thread_db_state_str (ti_p->ti_state));
- }
+ snprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
+ GET_THREAD (ptid), GET_LWP (ptid));
return buf;
}
@@ -1236,6 +1032,18 @@ thread_db_pid_to_str (ptid_t ptid)
return normal_pid_to_str (ptid);
}
+/* Return a string describing the state of the thread specified by
+ INFO. */
+
+static char *
+thread_db_extra_thread_info (struct thread_info *info)
+{
+ if (info->private->dying)
+ return "Exiting";
+
+ return NULL;
+}
+
/* Get the address of the thread local variable in load module LM which
is stored at OFFSET within the thread local storage for thread PTID. */
@@ -1306,20 +1114,18 @@ init_thread_db_ops (void)
thread_db_ops.to_detach = thread_db_detach;
thread_db_ops.to_resume = thread_db_resume;
thread_db_ops.to_wait = thread_db_wait;
- thread_db_ops.to_fetch_registers = thread_db_fetch_registers;
- thread_db_ops.to_store_registers = thread_db_store_registers;
thread_db_ops.to_xfer_partial = thread_db_xfer_partial;
thread_db_ops.to_kill = thread_db_kill;
thread_db_ops.to_create_inferior = thread_db_create_inferior;
thread_db_ops.to_post_startup_inferior = thread_db_post_startup_inferior;
thread_db_ops.to_mourn_inferior = thread_db_mourn_inferior;
- thread_db_ops.to_thread_alive = thread_db_thread_alive;
thread_db_ops.to_find_new_threads = thread_db_find_new_threads;
thread_db_ops.to_pid_to_str = thread_db_pid_to_str;
thread_db_ops.to_stratum = thread_stratum;
thread_db_ops.to_has_thread_control = tc_schedlock;
thread_db_ops.to_get_thread_local_address
= thread_db_get_thread_local_address;
+ thread_db_ops.to_extra_thread_info = thread_db_extra_thread_info;
thread_db_ops.to_magic = OPS_MAGIC;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2006-07-18 22:55 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200606191719.00530.bartoschek@or.uni-bonn.de>
[not found] ` <200606201542.12070.bartoschek@or.uni-bonn.de>
[not found] ` <20060620135351.GA9853@host0.dyn.jankratochvil.net>
[not found] ` <200606201821.41941.bartoschek@or.uni-bonn.de>
[not found] ` <200606201456.57681.bartoschek@or.uni-bonn.de>
[not found] ` <20060620130932.GA21490@nevyn.them.org>
[not found] ` <200606201524.45099.bartoschek@or.uni-bonn.de>
[not found] ` <20060620132737.GA21951@nevyn.them.org>
2006-06-19 16:56 ` [patch] Fix for 'info threads' crashes if zombie threads exist Jan Kratochvil
2006-06-20 17:05 ` RFC: " Jan Kratochvil
2006-06-20 17:11 ` Daniel Jacobowitz
2006-06-20 18:54 ` Jan Kratochvil
2006-06-20 19:07 ` Daniel Jacobowitz
2006-07-13 4:01 ` Daniel Jacobowitz
2006-07-13 13:28 ` Jan Kratochvil
2006-07-13 13:43 ` Daniel Jacobowitz
2006-07-13 15:07 ` Jan Kratochvil
2006-07-13 18:50 ` Mark Kettenis
2006-07-13 19:47 ` Daniel Jacobowitz
2006-07-13 23:16 ` Mark Kettenis
2006-07-18 22:55 ` Daniel Jacobowitz
2006-07-14 13:15 ` Christoph Bartoschek
2006-07-14 13:36 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox