Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Disable thread specific breakpoints when thread dies
@ 2005-11-09 19:06 Andrew STUBBS
  2005-11-13 21:13 ` Daniel Jacobowitz
  0 siblings, 1 reply; 23+ messages in thread
From: Andrew STUBBS @ 2005-11-09 19:06 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

Hi,

The attached patch disables thread specific breakpoints if they are hit 
(in another thread) after the specific thread has died.

The rationale is that, once dead, the thread in question can never come 
back, and the breakpoint is then only a, potentially serious, 
performance drain. Even if another thread can be created with that ID it 
would not be appropriate to 'hit' the breakpoint.

The breakpoint is not deleted, only disabled. It may still be easily 
re-enabled when the program is re-run.

Is this OK?

Andrew Stubbs

[-- Attachment #2: thread-break.patch --]
[-- Type: text/plain, Size: 1472 bytes --]

2005-11-09  Andrew Stubbs  <andrew.stubbs@st.com>

	* breakpoint.c (breakpoint_thread_match): Disable thread specific
	breakpoints if we hit one after the thread has ceased to exist.

Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2005-05-29 04:13:17.000000000 +0100
+++ src/gdb/breakpoint.c	2005-11-01 13:49:40.000000000 +0000
@@ -1797,9 +1797,23 @@ breakpoint_thread_match (CORE_ADDR pc, p
 
       if ((breakpoint_enabled (bpt->owner)
 	   || bpt->owner->enable_state == bp_permanent)
-	  && bpt->address == pc
-	  && (bpt->owner->thread == -1 || bpt->owner->thread == thread))
+	  && bpt->address == pc)
 	{
+          /* Disable matched breakpoint if thread no longer exists: this
+	     prevents other tasks from hitting the breakpoint and improves
+	     performance.  */
+          if ((bpt->owner->thread != -1) && (bpt->owner->thread != thread))
+          {
+            if (!target_thread_alive(thread_id_to_pid(bpt->owner->thread)))
+              {
+                printf_filtered (
+		      "Breakpoint %d disabled as thread %d no longer alive.\n",
+		      bpt->owner->number, bpt->owner->thread);
+                disable_breakpoint(bpt->owner);
+              }
+            continue;  /* no need to consider this breakpoint any further */
+          }
+
 	  if (overlay_debugging 
 	      && section_is_overlay (bpt->section) 
 	      && !section_is_mapped (bpt->section))

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-02-02  2:30 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-09 19:06 [PATCH] Disable thread specific breakpoints when thread dies Andrew STUBBS
2005-11-13 21:13 ` Daniel Jacobowitz
2005-11-14 16:34   ` Andrew STUBBS
2005-11-14 17:11     ` Daniel Jacobowitz
2005-11-15 18:55       ` Andrew STUBBS
2005-11-16 16:23         ` Andrew STUBBS
2005-11-17  4:22           ` Daniel Jacobowitz
2005-11-17 16:34             ` Andrew STUBBS
2006-01-12 16:25               ` Andrew STUBBS
2006-01-13  4:19                 ` Michael Snyder
2006-01-13  4:31                   ` Daniel Jacobowitz
2006-01-12 16:27               ` Daniel Jacobowitz
2006-01-13 17:35                 ` Andrew STUBBS
2006-01-13 20:11                   ` Mark Kettenis
2006-01-14 15:46                     ` Daniel Jacobowitz
2006-01-14 15:56                       ` Mark Kettenis
2006-01-14 16:06                   ` Daniel Jacobowitz
2006-01-16 12:57                     ` Andrew STUBBS
2006-01-16 16:19                       ` Andrew STUBBS
2006-01-20 14:56                         ` Andrew STUBBS
2006-01-20 15:00                           ` Daniel Jacobowitz
2006-01-20 22:41                         ` Daniel Jacobowitz
2006-02-02  2:30                           ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox