[patch] Fix a crash when displaying variables from shared library.

Paul Pluzhnikov ppluzhnikov@google.com
Thu Mar 12 02:45:00 GMT 2009


On Tue, Mar 10, 2009 at 6:37 AM, Daniel Jacobowitz <drow@false.org> wrote:

> Disabling a shlib_event breakpoint is pretty weird - there won't be an
> event to restore it, so unless we're restarting the program it won't
> be enabled again ever.  If we're disabling a step-return or finish
> breakpoint, we'll lose control of the inferior.  And so forth...

Thanks, I think I understood how this works now.

Attached patch is simply a cleanup (i.e. I dont't really care if
it is applied or not, though I think it is more efficient and
easier to understand the source). It introduces no regressions
of Linux/x86_64.

OK to commit?
-- 
Paul Pluzhnikov


2009-03-11  Paul Pluzhnikov  <ppluzhnikov@google.com>

	    * breakpoint.c (disable_breakpoints_in_shlibs): Use
	    solib_contains_address_p instead of searching.
-------------- next part --------------
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.383
diff -u -p -u -r1.383 breakpoint.c
--- breakpoint.c	11 Mar 2009 20:26:02 -0000	1.383
+++ breakpoint.c	12 Mar 2009 01:04:34 -0000
@@ -4442,7 +4442,7 @@ disable_breakpoints_in_shlibs (void)
        all breakpoints.  If we don't set shlib_disabled here, we'll try
        to insert those breakpoints and fail.  */
     if (((b->type == bp_breakpoint) || (b->type == bp_hardware_breakpoint))
-	&& !loc->shlib_disabled
+ 	&& !loc->shlib_disabled
 #ifdef PC_SOLIB
 	&& PC_SOLIB (loc->address)
 #else
@@ -4477,28 +4477,22 @@ disable_breakpoints_in_unloaded_shlib (s
     struct breakpoint *b = loc->owner;
     if ((loc->loc_type == bp_loc_hardware_breakpoint
 	 || loc->loc_type == bp_loc_software_breakpoint)
-	&& !loc->shlib_disabled)
+	&& !loc->shlib_disabled
+	&& (b->type == bp_breakpoint || b->type == bp_hardware_breakpoint)
+	&& solib_contains_address_p (solib, loc->address))
       {
-#ifdef PC_SOLIB
-	char *so_name = PC_SOLIB (loc->address);
-#else
-	char *so_name = solib_name_from_address (loc->address);
-#endif
-	if (so_name && !strcmp (so_name, solib->so_name))
-          {
-	    loc->shlib_disabled = 1;
-	    /* At this point, we cannot rely on remove_breakpoint
-	       succeeding so we must mark the breakpoint as not inserted
-	       to prevent future errors occurring in remove_breakpoints.  */
-	    loc->inserted = 0;
-	    if (!disabled_shlib_breaks)
-	      {
-		target_terminal_ours_for_output ();
-		warning (_("Temporarily disabling breakpoints for unloaded shared library \"%s\""),
-			  so_name);
-	      }
-	    disabled_shlib_breaks = 1;
+	loc->shlib_disabled = 1;
+	/* At this point, we cannot rely on remove_breakpoint
+	   succeeding so we must mark the breakpoint as not inserted
+	   to prevent future errors occurring in remove_breakpoints.  */
+	loc->inserted = 0;
+	if (!disabled_shlib_breaks)
+	  {
+	    target_terminal_ours_for_output ();
+	    warning (_("Temporarily disabling breakpoints for unloaded shared library \"%s\""),
+		     solib->so_name);
 	  }
+	disabled_shlib_breaks = 1;
       }
   }
 }


More information about the Gdb-patches mailing list