This is the mail archive of the gdb-patches@sources.redhat.com 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]

GDB doesnt quit


Hi all,

I have come across this problem when debugging threads. I get an error
'Cannot find user-level thread'. 
And the quit command fails to quit.

I am very much a novice when it comes to GDB internals, but i feel that
no matter what kind of internal error gdb encountered, the quit command
should make sure
it quits. 

A li'l bit of code reading made me understand this, 

 quit_force() --> thread_db_kill() -- > lwp_from_thread() --> /* Conks
here */ and 
a longjmp (by error(), maybe :-?) is done to go back to gdb prompt.

i came up with a very basic & crude patch. it worked though !. 

i would greatly appreciate comments/criticisms.

But what i would like to know more is, am i wrong if i said, 'quit'
should make gdb quit no matter
what internal state gdb is in ?

TIA

Cheers.
Raj Inguva

--- thread-db.c	Fri Jul 18 10:20:31 2003
+++ thread-db.c.mod	Fri Jul 18 10:24:41 2003
@@ -248,25 +248,32 @@
 
   return BUILD_THREAD (ti.ti_tid, GET_PID (ptid));
 }
-
+//Flag to quit immediately
+unsigned int bailout;
 static ptid_t
 lwp_from_thread (ptid_t ptid)
 {
   td_thrinfo_t ti;
   td_thrhandle_t th;
   td_err_e err;
+  ptid_t dummyptid;
 
   if (!is_thread (ptid))
     return ptid;
-
   err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
-  if (err != TD_OK)
-    error ("Cannot find thread %ld: %s",
+  if (err != TD_OK) {
+    fprintf (stdout,"Cannot find thread %ld: %s",
 	   (long) GET_THREAD (ptid), thread_db_err_str (err));
+    bailout = 1;
+    return dummyptid;
+  }
 
   err = td_thr_get_info_p (&th, &ti);
-  if (err != TD_OK)
-    error ("Cannot get thread info: %s", thread_db_err_str (err));
+  if (err != TD_OK) {
+    fprintf (stdout,"Cannot get thread info: %s", thread_db_err_str
(err));
+    bailout = 1;
+    return dummyptid;
+  }
 
   return BUILD_LWP (ti.ti_lid, GET_PID (ptid));
 }
@@ -846,13 +853,14 @@
     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
      inferior isn't supposed to survive this function call.  */
+  bailout = 0;
   inferior_ptid = lwp_from_thread (inferior_ptid);
+  if(bailout) return; //Could not kill somehow.
   target_beneath->to_kill ();
 }


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