aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2025-05-26 15:15:31 +0200
committerTom de Vries <tdevries@suse.de>2025-05-26 15:15:31 +0200
commit6b4f72a01e60c854654a46f4faa555e258fa98b0 (patch)
tree30558df1eb809cd2ea390ab66837ee1bd606b0d4
parent8dd54de0a83dcf57fdaef68902c73e35e0ea274d (diff)
downloadbinutils-6b4f72a01e60c854654a46f4faa555e258fa98b0.zip
binutils-6b4f72a01e60c854654a46f4faa555e258fa98b0.tar.gz
binutils-6b4f72a01e60c854654a46f4faa555e258fa98b0.tar.bz2
[gdb/breakpoints] Stabilize info breakpoints output
With test-case gdb.multi/pending-bp-del-inferior.exp, occasionally I run into: ... (gdb) info breakpoints^M Num Type Disp Enb Address What^M 3 dprintf keep y <MULTIPLE> ^M printf "in foo"^M 3.1 y 0x004004dc in foo at $c:21 inf 2^M 3.2 y 0x004004dc in foo at $c:21 inf 1^M (gdb) FAIL: $exp: bp_pending=false: info breakpoints before inferior removal ... The FAIL happens because the test-case expects: - breakpoint location 3.1 to be in inferior 1, and - breakpoint location 3.2 to be in inferior 2 but it's the other way around. I managed to reproduce this with a trigger patch in compare_symbols from gdb/linespec.c: ... uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace (); uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace (); - if (uia < uib) + if (uia > uib) return true; - if (uia > uib) + if (uia < uib) return false; ... The order enforced by compare_symbols shows up in the "info breakpoints" output because breakpoint::add_location doesn't enforce an ordering for equal addresses: ... auto ub = std::upper_bound (m_locations.begin (), m_locations.end (), loc, [] (const bp_location &left, const bp_location &right) { return left.address < right.address; }); m_locations.insert (ub, loc); ... Fix this by using new function bp_location_is_less_than (forwarding to bp_location_ptr_is_less_than) in breakpoint::add_location. Tested on x86_64-linux. Reviewed-By: Guinevere Larsen <guinevere@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com> PR gdb/32202 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32202
-rw-r--r--gdb/breakpoint.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bbafa09..abae16f 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11254,6 +11254,15 @@ bp_location_ptr_is_less_than (const bp_location *a, const bp_location *b)
return a < b;
}
+/* A comparison function for bp_locations A and B being interfaced to
+ std::sort, for instance to sort an std::vector<bp_location>. */
+
+static bool
+bp_location_is_less_than (const bp_location &a, const bp_location &b)
+{
+ return bp_location_ptr_is_less_than (&a, &b);
+}
+
/* Set bp_locations_placed_address_before_address_max and
bp_locations_shadow_len_after_address_max according to the current
content of the bp_locations array. */
@@ -11907,9 +11916,7 @@ breakpoint::add_location (bp_location &loc)
auto ub = std::upper_bound (m_locations.begin (), m_locations.end (),
loc,
- [] (const bp_location &left,
- const bp_location &right)
- { return left.address < right.address; });
+ bp_location_is_less_than);
m_locations.insert (ub, loc);
}