This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] unexpected multiple location for breakpoint
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Joel Brobecker <brobecker at adacore dot com>
- Date: Mon, 22 Nov 2010 17:10:25 -0800
- Subject: [RFA] unexpected multiple location for breakpoint
This is a proposed fix for the issue presented at:
http://www.sourceware.org/ml/gdb/2010-11/msg00026.html.
It changes the multiple-location filtering mechanism to use (block)
contained_in rather than block equality to discard unwanted
breakpoint locations. For instance, if the user tries to break
on line "foo.adb:5" and the compiler generated 2 entries for that
line, the second being inside a lexical block nested inside the
lexical block associated to the first entry, then we should only
break on the first line entry.
gdb/ChangeLog:
* symtab.c (expand_line_sal): Use contained_in rather than
plain block equality to filter out duplicate sals.
Tested on x86_64-linux. No regression. OK to commit?
---
gdb/symtab.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a6023b9..9eb3784 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4633,7 +4633,8 @@ expand_line_sal (struct symtab_and_line sal)
in two PC ranges. In this case, we don't want to set breakpoint
on first PC of each range. To filter such cases, we use containing
blocks -- for each PC found above we see if there are other PCs
- that are in the same block. If yes, the other PCs are filtered out. */
+ that are in the same or contained block. If yes, the other PCs
+ are filtered out. */
old_chain = save_current_program_space ();
filter = alloca (ret.nelts * sizeof (int));
@@ -4648,12 +4649,23 @@ expand_line_sal (struct symtab_and_line sal)
}
do_cleanups (old_chain);
- for (i = 0; i < ret.nelts; ++i)
+ /* To do the filtering of extraneous PCs, we go over all entries
+ in our list of PCs and see if its associated block is contained by
+ the block of another entry. If it is, then eliminate that contained
+ block.
+
+ We start from last to first in our list of PCs, in order to take
+ care of the case where 2 entries are associated to the same block:
+ When we have one or more lines in the same block, we want to stop
+ at the first instruction of that line, hence we want to eliminate
+ the highest address. */
+
+ for (i = ret.nelts - 1; i >= 0; i--)
if (blocks[i] != NULL)
- for (j = i+1; j < ret.nelts; ++j)
- if (blocks[j] == blocks[i])
+ for (j = 0; j < ret.nelts; ++j)
+ if (j != i && filter[j] && contained_in (blocks[i], blocks[j]))
{
- filter[j] = 0;
+ filter[i] = 0;
++deleted;
break;
}
--
1.7.1