public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH ver3] Fix the gdb.ada/inline-section-gc.exp test
@ 2023-11-08 18:02 Carl Love
  2023-11-11 16:15 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Carl Love @ 2023-11-08 18:02 UTC (permalink / raw)
  To: Luis Machado, gdb-patches, Tom Tromey; +Cc: blarsen, cel, Ulrich Weigand


GDB maintainers, Luis, Tom, Guinevere:

Version 3, Fixed typos noted by Luis.  Used gdb_get_line_number to
get the line number for the callee breakpoint where it ends up
after being inlined into caller, per Tom's comments.  Retested on Power
10 with no regressions.

Version 2, fixed the name of the test the patch fixes in the email. 
Mixed it up with another patch I am working on sorry about that.

Here is the patch to fix test gdb.ada/inline-section-gc.exp on
PowerPC as discussed on IRC.  Per that discussion with Tom and Luis,
the point of the test is to look for an error where a breakpoint in an
inlined ada function was reported as being set in multiple places. 
There should only be one location reported for the test and the
breakpoint address should not be at address 0x0. The test also fails on
aarch64 but passes on X86-64.  The issue is the location of the
inserted breakpoint in function callee may be reported as being in file
callee.adb or in file caller.adb.  The location reported by the ada
compiler for inlined functions seems to be a function of either the ada
compiler version or target dependent.

The following patch will accept the reported breakpoint location as
being correctly set in either file callee.adb or caller.adb.  In either
case the address of the breakpoint must not be zero.  The test checks
that the file line number matches the requested line number in file
calleeadb or one less if the reported location is in caller.adb.  The
key thing is we want to make sure we have a reasonable line number and
the breakpoint address is not zero.

The patch fixes the single test failure on PowerPC.  It does not
introduce any additional errors on the X86-84 platform on which it was
tested.

Please let me know if the patch looks OK for gdb mainline.  Thanks.

                Carl 


--------------------------------------
Fix the gdb.ada/inline-section-gc.exp test

The original intention of the test appears to be checking to make sure
setting a breakpoint in an inlined function didn't set multiple
breakpoints where one of them was at address 0.

The gdb.ada/inline-section-gc.exp test may pass or fail depending on the
version of gnat.  Per the discussion on IRC, the ada inlining appears to
have some target dependencies.  In this test there are two functions,
callee and caller. Function calee is inlined into caller.  The test sets
a breakpoint in function callee.  The reported location where the
breakpoint is set may be at the requested location in callee or the
location in caller after callee has been inlined.  The test needs to
accept either location as correct provided the breakpoint address is not
zero.

This patch checks to see if the reported breakpoint is in function callee
or function caller and fails if the breakpoint address is 0x0.  The line
number where the breakpoint is set will match the requested line if the
breakpoint location is reported is callee.adb.  If the breakpoint is
reported in caller.adb, the line number in caller is the breakpoint
location in callee where it is inlined into caller.

This patch fixes the single regression failure for the test on PowerPC.
It does not introduce any failures on X86-64.
---
 gdb/testsuite/gdb.ada/inline-section-gc.exp   | 21 ++++++++++++++++---
 .../gdb.ada/inline-section-gc/caller.adb      |  3 ++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/inline-section-gc.exp b/gdb/testsuite/gdb.ada/inline-section-gc.exp
index b707335eb04..4f8b8c95395 100644
--- a/gdb/testsuite/gdb.ada/inline-section-gc.exp
+++ b/gdb/testsuite/gdb.ada/inline-section-gc.exp
@@ -34,8 +34,23 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $options] != ""} {
 
 clean_restart ${testfile}
 
-set bp_location [gdb_get_line_number "BREAK" ${testdir}/callee.adb]
+
+# Depending on the version of gnat, the location of the set breakpoint may
+# be reported as being at the requested location in file callee.adb or in
+# file caller.adb where the callee function was inlined.  Either way, only
+# one breakpoint should be reported and its address should not be at 0x0.
+set bp_location1 [gdb_get_line_number "BREAK" ${testdir}/callee.adb]
+set bp_location2 [gdb_get_line_number "CALLEE_LOC" ${testdir}/caller.adb]
+set test "break callee.adb:$bp_location1"
+set message "Breakpoint set"
+
 # The bug here was that gdb would set a breakpoint with two locations,
 # one of them at 0x0.
-gdb_test "break callee.adb:$bp_location" \
-    "Breakpoint $decimal at $hex: file .*callee.adb, line $bp_location."
+gdb_test_multiple $test $message {
+    -re "Breakpoint $decimal at $hex: file .*callee.adb, line $bp_location1." {
+	pass $test
+    }
+    -re "Breakpoint $decimal at $hex: file .*caller.adb, line $bp_location2." {
+	pass $test
+    }
+}
diff --git a/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb b/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
index 66eb2d9a910..161f3e85542 100644
--- a/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
+++ b/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
@@ -18,4 +18,5 @@ with Callee;
 procedure Caller is
 begin
    Callee;
-end Caller;
+end Caller;    -- CALLEE_LOC, this is where the inlined callee breakpoint
+               -- is located.
-- 
2.37.2



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

* Re: [PATCH ver3] Fix the gdb.ada/inline-section-gc.exp test
  2023-11-08 18:02 [PATCH ver3] Fix the gdb.ada/inline-section-gc.exp test Carl Love
@ 2023-11-11 16:15 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-11-11 16:15 UTC (permalink / raw)
  To: Carl Love; +Cc: Luis Machado, gdb-patches, Tom Tromey, blarsen, Ulrich Weigand

>>>>> "Carl" == Carl Love <cel@linux.ibm.com> writes:

Carl> Version 3, Fixed typos noted by Luis.  Used gdb_get_line_number to
Carl> get the line number for the callee breakpoint where it ends up
Carl> after being inlined into caller, per Tom's comments.  Retested on Power
Carl> 10 with no regressions.

Thank you for doing this.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

end of thread, other threads:[~2023-11-11 16:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 18:02 [PATCH ver3] Fix the gdb.ada/inline-section-gc.exp test Carl Love
2023-11-11 16:15 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).