Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] unexpected multiple location for breakpoint
@ 2010-11-23  1:10 Joel Brobecker
  2010-11-26 17:29 ` Joel Brobecker
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Brobecker @ 2010-11-23  1:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

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


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

end of thread, other threads:[~2010-12-30 23:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-23  1:10 [RFA] unexpected multiple location for breakpoint Joel Brobecker
2010-11-26 17:29 ` Joel Brobecker
2010-11-27 18:35   ` Daniel Jacobowitz
2010-12-10 12:23     ` Joel Brobecker
2010-12-28 11:50       ` Joel Brobecker
2010-12-28 20:15         ` Eli Zaretskii
2010-12-29  6:08           ` Joel Brobecker
2010-12-29  8:08             ` Joel Brobecker
2010-12-29 19:30             ` Eli Zaretskii
2010-12-30 20:40               ` Joel Brobecker
2010-12-30 21:03                 ` Eli Zaretskii
2010-12-31  6:35                 ` Michael Snyder

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