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]

[commit] Do not call get_thread_regcache for dead thread


Hello,

another fall-out from per-thread architecture work: adjust_pc_after_break
always calls get_thread_regcache, even if the thread has already exited
(which adjust_pc_after_break notices shortly after, and does nothing anyway).

This is harmless with the current get_thread_regcache implemented (even
though a bit wasteful), but once get_thread_regcache does more active work,
this will break.

The following patch simply moves the get_thread_regcache call until after
adjust_pc_after_break has determined the thread is alive.

Tested on powerpc-linux and powerpc64-linux.
Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* infrun.c (adjust_pc_after_break): Do not call get_thread_regcache
	if the thread has already exited.


Index: gdb/infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.304
diff -u -p -r1.304 infrun.c
--- gdb/infrun.c	19 Aug 2008 13:57:28 -0000	1.304
+++ gdb/infrun.c	22 Aug 2008 13:43:26 -0000
@@ -1743,15 +1743,10 @@ context_switch_to (ptid_t ptid)
 static void
 adjust_pc_after_break (struct execution_control_state *ecs)
 {
-  struct regcache *regcache = get_thread_regcache (ecs->ptid);
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct regcache *regcache;
+  struct gdbarch *gdbarch;
   CORE_ADDR breakpoint_pc;
 
-  /* If this target does not decrement the PC after breakpoints, then
-     we have nothing to do.  */
-  if (gdbarch_decr_pc_after_break (gdbarch) == 0)
-    return;
-
   /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP.  If
      we aren't, just return.
 
@@ -1779,6 +1774,13 @@ adjust_pc_after_break (struct execution_
   if (ecs->ws.value.sig != TARGET_SIGNAL_TRAP)
     return;
 
+  /* If this target does not decrement the PC after breakpoints, then
+     we have nothing to do.  */
+  regcache = get_thread_regcache (ecs->ptid);
+  gdbarch = get_regcache_arch (regcache);
+  if (gdbarch_decr_pc_after_break (gdbarch) == 0)
+    return;
+
   /* Find the location where (if we've hit a breakpoint) the
      breakpoint would be.  */
   breakpoint_pc = regcache_read_pc (regcache)
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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