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]

Re: [rfa/threads] Convert thread event descriptors to code addrs


In the light of roland's comments, I've checked in the attached variation on the original patch.

It still does the conversion but in GDB's libthread_db caller (enable_thread_event_reporting) and not in libthread_db's symbol lookup callee (ps_pglobal_lookup).

This way, libthread_db is free to search for either:
.__nptl_create_event: the start address
__nptl_create_event: the descriptor
(the original change would have restricted searches to just the start address - not a problem now but we never know) and at the same time ensure that GDB sets breakpoints at the address it needs.


Andrew
2003-11-25  Andrew Cagney  <cagney@redhat.com>

	* thread-db.c (enable_thread_event): New function.  Ensure that BP
	is a code address.
	(enable_thread_event_reporting): Use enable_thread_event.
	
Index: ./gdb/thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.34
diff -u -r1.34 thread-db.c
--- ./gdb/thread-db.c	4 Sep 2003 21:03:37 -0000	1.34
+++ ./gdb/thread-db.c	25 Nov 2003 23:28:49 -0000
@@ -465,6 +465,26 @@
   return 1;
 }
 
+static int
+enable_thread_event (td_thragent_t *thread_agent, int event, CORE_ADDR *bp)
+{
+  td_notify_t notify;
+  int err;
+
+  /* Get the breakpoint address for thread EVENT.  */
+  err = td_ta_event_addr_p (thread_agent, event, &notify);
+  if (err != TD_OK)
+    return 0;
+
+  /* Set up the breakpoint.  */
+  (*bp) = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
+					      (CORE_ADDR) notify.u.bptaddr,
+					      &current_target);
+  create_thread_event_breakpoint ((*bp));
+
+  return 1;
+}
+
 static void
 enable_thread_event_reporting (void)
 {
@@ -498,32 +518,24 @@
 
   /* Delete previous thread event breakpoints, if any.  */
   remove_thread_event_breakpoints ();
+  td_create_bp_addr = 0;
+  td_death_bp_addr = 0;
 
-  /* Get address for thread creation breakpoint.  */
-  err = td_ta_event_addr_p (thread_agent, TD_CREATE, &notify);
-  if (err != TD_OK)
+  /* Set up the thread creation event.  */
+  if (!enable_thread_event (thread_agent, TD_CREATE, &td_create_bp_addr))
     {
       warning ("Unable to get location for thread creation breakpoint: %s",
 	       thread_db_err_str (err));
       return;
     }
 
-  /* Set up the breakpoint.  */
-  td_create_bp_addr = (CORE_ADDR) notify.u.bptaddr;
-  create_thread_event_breakpoint (td_create_bp_addr);
-
-  /* Get address for thread death breakpoint.  */
-  err = td_ta_event_addr_p (thread_agent, TD_DEATH, &notify);
-  if (err != TD_OK)
+  /* Set up the thread death event.  */
+  if (!enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr))
     {
       warning ("Unable to get location for thread death breakpoint: %s",
 	       thread_db_err_str (err));
       return;
     }
-
-  /* Set up the breakpoint.  */
-  td_death_bp_addr = (CORE_ADDR) notify.u.bptaddr;
-  create_thread_event_breakpoint (td_death_bp_addr);
 }
 
 static void

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