aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2008-02-08 00:42:07 +0000
committerDoug Evans <dje@google.com>2008-02-08 00:42:07 +0000
commit776592bf173a191aa5d142808ca9164fd243c0ce (patch)
treede93b4f22843af0ac994cdb88997e54683932eca /gdb/breakpoint.c
parentb29242315eb0d6694d66d75895116361e20c8003 (diff)
downloadgdb-776592bf173a191aa5d142808ca9164fd243c0ce.zip
gdb-776592bf173a191aa5d142808ca9164fd243c0ce.tar.gz
gdb-776592bf173a191aa5d142808ca9164fd243c0ce.tar.bz2
* breakpoint.c: #include "hashtab.h".
(ambiguous_names_p): New fn. (update_breakpoint_locations): When restoring bp enable status, don't compare function names if any functions have same name. * Makefile.in (breakpoint.o): Add hashtab.h dependency. * gdb.cp/mb-inline.exp: New. * gdb.cp/mb-inline.h: New. * gdb.cp/mb-inline1.cc: New. * gdb.cp/mb-inline2.cc: New.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c71
1 files changed, 64 insertions, 7 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c2bf50a..dca4ca1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -21,6 +21,7 @@
#include "defs.h"
#include <ctype.h>
+#include "hashtab.h"
#include "symtab.h"
#include "frame.h"
#include "breakpoint.h"
@@ -7081,6 +7082,43 @@ all_locations_are_pending (struct bp_location *loc)
return 1;
}
+/* Subroutine of update_breakpoint_locations to simplify it.
+ Return non-zero if multiple fns in list LOC have the same name.
+ Null names are ignored. */
+
+static int
+ambiguous_names_p (struct bp_location *loc)
+{
+ struct bp_location *l;
+ htab_t htab = htab_create_alloc (13, htab_hash_string,
+ (int (*) (const void *, const void *)) streq,
+ NULL, xcalloc, xfree);
+
+ for (l = loc; l != NULL; l = l->next)
+ {
+ const char **slot;
+ const char *name = l->function_name;
+
+ /* Allow for some names to be NULL, ignore them. */
+ if (name == NULL)
+ continue;
+
+ slot = (const char **) htab_find_slot (htab, (const void *) name,
+ INSERT);
+ /* NOTE: We can assume slot != NULL here because xcalloc never returns
+ NULL. */
+ if (*slot != NULL)
+ {
+ htab_delete (htab);
+ return 1;
+ }
+ *slot = name;
+ }
+
+ htab_delete (htab);
+ return 0;
+}
+
static void
update_breakpoint_locations (struct breakpoint *b,
struct symtabs_and_lines sals)
@@ -7143,18 +7181,37 @@ update_breakpoint_locations (struct breakpoint *b,
/* If possible, carry over 'disable' status from existing breakpoints. */
{
struct bp_location *e = existing_locations;
+ /* If there are multiple breakpoints with the same function name,
+ e.g. for inline functions, comparing function names won't work.
+ Instead compare pc addresses; this is just a heuristic as things
+ may have moved, but in practice it gives the correct answer
+ often enough until a better solution is found. */
+ int have_ambiguous_names = ambiguous_names_p (b->loc);
+
for (; e; e = e->next)
{
if (!e->enabled && e->function_name)
{
struct bp_location *l = b->loc;
- for (; l; l = l->next)
- if (l->function_name
- && strcmp (e->function_name, l->function_name) == 0)
- {
- l->enabled = 0;
- break;
- }
+ if (have_ambiguous_names)
+ {
+ for (; l; l = l->next)
+ if (e->address == l->address)
+ {
+ l->enabled = 0;
+ break;
+ }
+ }
+ else
+ {
+ for (; l; l = l->next)
+ if (l->function_name
+ && strcmp (e->function_name, l->function_name) == 0)
+ {
+ l->enabled = 0;
+ break;
+ }
+ }
}
}
}