This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[RFA] Fix for breakpoints in dynamically loaded libs
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA] Fix for breakpoints in dynamically loaded libs
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Sat, 13 May 2000 17:22:04 +0200
- CC: msnyder at cygnus dot com, jimb at cygnus dot com
The following patch makes breakpoints in dynamically loaded libraries
work more reliable. Without this patch they will be disabled by
breakpoint_re_set_one, and you'll have to re-enable them by hand,
which is pretty painful.
When restarting the program, you'll still see an error-message for
every symbol file that's loaded, until the symbol file that
corresponds to the module where the breakpoint is set is loaded. It's
not easy to change this without making a lot of changes to
decode_line_1. Ultimately GDB will print a message that there is a
breakpoint which hopefully restores the user's confidence about the
breakpoint.
Mark
2000-05-13 Mark Kettenis <kettenis@gnu.org>
* breakpoint.c (breakpoint_re_set_one): Handle breakpoints that
are shlib_disabled specially. Keep them shlib_disabled, but
prevent them from being enabled in re_enable_breakpoints_in_shlibs
by setting their address to 0.
(re_enable_breakpoints_in_shlibs): Don't enable a breakpoint that
has its address set at 0.
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.8
diff -u -p -r1.8 breakpoint.c
--- breakpoint.c 2000/03/30 18:54:28 1.8
+++ breakpoint.c 2000/05/13 15:09:13
@@ -4121,7 +4121,8 @@ re_enable_breakpoints_in_shlibs ()
/* Do not reenable the breakpoint if the shared library
is still not mapped in. */
- if (target_read_memory (b->address, buf, 1) == 0)
+ if (b->address != (CORE_ADDR) 0
+ && target_read_memory (b->address, buf, 1) == 0)
b->enable = enabled;
}
}
@@ -7124,6 +7125,7 @@ breakpoint_re_set_one (bint)
struct symtabs_and_lines sals;
char *s;
enum enable save_enable;
+ CORE_ADDR save_address;
switch (b->type)
{
@@ -7141,10 +7143,18 @@ breakpoint_re_set_one (bint)
delete_breakpoint (b);
return 0;
}
- /* In case we have a problem, disable this breakpoint. We'll restore
- its status if we succeed. */
+ /* In case we have a problem, disable this breakpoint. We'll
+ restore its status if we succeed. For breakpoints that are
+ shlib_disabled, we invalidate the address instead. This will
+ make sure that re_enable_breakpoints_in_shlibs won't enable
+ the breakpoint, unless a symbol table for the shared library
+ has been loaded and we've successfully re-set the breakpoint. */
save_enable = b->enable;
- b->enable = disabled;
+ save_address = b->address;
+ if (b->enable == shlib_disabled)
+ b->address = (CORE_ADDR) 0;
+ else
+ b->enable = disabled;
set_language (b->language);
input_radix = b->input_radix;
@@ -7165,7 +7175,7 @@ breakpoint_re_set_one (bint)
}
/* We need to re-set the breakpoint if the address changes... */
- if (b->address != sals.sals[i].pc
+ if (save_address != sals.sals[i].pc
/* ...or new and old breakpoints both have source files, and
the source file name or the line number changes... */
|| (b->source_file != NULL
@@ -7187,7 +7197,7 @@ breakpoint_re_set_one (bint)
savestring (sals.sals[i].symtab->filename,
strlen (sals.sals[i].symtab->filename));
b->line_number = sals.sals[i].line;
- b->address = sals.sals[i].pc;
+ b->address = save_address = sals.sals[i].pc;
/* Used to check for duplicates here, but that can
cause trouble, as it doesn't check for disable
@@ -7201,12 +7211,11 @@ breakpoint_re_set_one (bint)
}
b->section = sals.sals[i].section;
b->enable = save_enable; /* Restore it, this worked. */
+ b->address = save_address;
-
/* Now that this is re-enabled, check_duplicates
can be used. */
check_duplicates (b->address, b->section);
-
}
free ((PTR) sals.sals);
break;