This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA]corelow.c: Add tid to add_to_thread_list


On Friday 06 August 2010 18:17:48, Pedro Alves wrote:
> On Friday 06 August 2010 17:47:53, Hui Zhu wrote:

> > struct thread_info *
> > add_thread_silent (ptid_t ptid)
> > {
> 
> If this function hit an internal error in this scenario, then
> it has a bug.  I think Maciej wrote a patch to fix it in our
> internal tree.  I'll try to look for it.  Note that with this
> fixed, gdb would still discard all idle threads but one,
> and, when accessing the registers of the one that stays, we'd
> be accessing the wrong .reg section.

Here's the patch.  (Making Maciej's words mine, and tweaking
for context, ) this assertion:

.../gdb/thread.c:880: internal-error: switch_to_thread: Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

is related to this change:

2009-05-24  Pedro Alves  <pedro@codesourcery.com>

        * thread.c (new_thread): New function.
        (add_thread_silent): Use it.

which removed a piece of code that actually added minus_one_ptid to
the list of threads.  The current state of switch_to_thread doesn't
allow minus_one_ptid in this context, but null_ptid can be safely used
instead to the same effect.  The change was bogus --- the intent was
to use new_thread (minus_one_ptid), not new_thread (ptid).
Maciej's patch fixes this just as well (or perhaps better), so I've
applied to mainline, and the 7.2 and 7.1 branches.

-- 
Pedro Alves

2010-08-06  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* thread.c (add_thread_silent): Use null_ptid instead of
	minus_one_ptid while getting rid of stale inferior_ptid.

Index: gdb/thread.c
===================================================================
--- gdb/thread.c	(revision 283123)
+++ gdb/thread.c	(working copy)
@@ -187,11 +187,11 @@ add_thread_silent (ptid_t ptid)
 
       if (ptid_equal (inferior_ptid, ptid))
 	{
-	  tp = new_thread (ptid);
+	  tp = new_thread (null_ptid);
 
 	  /* Make switch_to_thread not read from the thread.  */
 	  tp->state_ = THREAD_EXITED;
-	  switch_to_thread (minus_one_ptid);
+	  switch_to_thread (null_ptid);
 
 	  /* Now we can delete it.  */
 	  delete_thread (ptid);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]