public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location
@ 2022-04-14 16:26 Simon Marchi
  2022-04-15 15:14 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2022-04-14 16:26 UTC (permalink / raw)
  To: gdb-patches

This test attempts to run until the line marked "STOP", which is at
prot.adb:34.  It first runs until the "main" symbol, then tries to place
a breakpoint by line at line 34, without specifying the source file.  When looking at the logs:

    -break-insert -t 34^M
    ^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0000555555558a6c",func="adafinal",file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_pro    t/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",thread-groups=["i1"],times="0",original-location="/home/simark/b    uild/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb:34"}^M
    ... continues ...
     *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x0000555555558a6c",func="adafinal",args=[],file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/    mi_prot/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",arch="i386:x86-64"},thread-id="1",stopped-threads="all",co    re="8"^M

... we see that the breakpoint is placed in some generated file, not in
the test source file as we expect.  The problem is that "b main" in Ada
does not place a breakpoint on the "Ada main", but on some symbol in a
generated source file.  So when stopped at the "main" symbol, we are not
stopped in the file that contains the STOP marker at line 34.

The test passes anyway today, so it doesn't seem to matter that we are
stopped at an unexpected location.  But it starts failing with this
patch [1], because b~prot.adb:34 happens to be between two functions, so
the breakpoint doesn't resolve.

Fix this by placing the breakpoint at "$srcfile:$line", which works
regardless of what is the current source file.

However, this ends up introducing a path in the test name.  Modify
mi_tbreak and mi_continue_to_line to avoid that.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187686.html

Change-Id: I742e2a9993046dcb5e30c64fe2ad920a363baf75
---
 gdb/testsuite/gdb.ada/mi_prot.exp |  2 +-
 gdb/testsuite/lib/mi-support.exp  | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/mi_prot.exp b/gdb/testsuite/gdb.ada/mi_prot.exp
index b68dcb532b4b..5ec7f8ddc6db 100644
--- a/gdb/testsuite/gdb.ada/mi_prot.exp
+++ b/gdb/testsuite/gdb.ada/mi_prot.exp
@@ -41,7 +41,7 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
 set line [gdb_get_line_number "STOP" ${testdir}/prot.adb]
-mi_continue_to_line $line "continue to protected method"
+mi_continue_to_line "$srcfile:$line" "continue to protected method"
 
 # The bug was that this crashed.
 mi_gdb_test "-stack-list-arguments --no-frame-filters 1" \
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 857a04519cff..701c53f13212 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1802,13 +1802,13 @@ proc mi_get_inline_test {testcase} {
 }
 
 # Sets temporary breakpoint at LOCATION.
-proc mi_tbreak {location} {
+proc mi_tbreak {location test} {
 
     global mi_gdb_prompt
 
     mi_gdb_test "-break-insert -t $location" \
 	{\^done,bkpt=.*} \
-	"run to $location (set breakpoint)"
+	$test
 }
 
 # Send COMMAND that must be a command that resumes
@@ -1864,10 +1864,10 @@ proc mi_send_resuming_command {command test} {
 # be determined.
 # Does not check that the line is the same as requested.
 # The caller can check itself if required.
-proc mi_continue_to_line {location test} {
+proc_with_prefix mi_continue_to_line {location test} {
 
-    mi_tbreak $location
-    mi_send_resuming_command "exec-continue" "run to $location (exec-continue)"
+    mi_tbreak $location "set temporary breakpoint"
+    mi_send_resuming_command "exec-continue" "continue to breakpoint"
     return [mi_get_stop_line $test]
 }
 
@@ -1954,7 +1954,7 @@ proc mi_run_inline_test { testcase } {
 
 	if {$first==1} {
 	    # Start the program afresh.
-	    mi_tbreak "$mi_autotest_source:$line"
+	    mi_tbreak "$mi_autotest_source:$line" "set temporary breakpoint"
 	    if { [mi_run_cmd] < 0 } {
 		return -1
 	    }

base-commit: df4397e378fa6813301e80c08fd1358aa07697df
prerequisite-patch-id: 3811c59b5bd47f967708be6423ac8caf49d4cca3
-- 
2.35.2


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

* Re: [PATCH] gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location
  2022-04-14 16:26 [PATCH] gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location Simon Marchi
@ 2022-04-15 15:14 ` Tom Tromey
  2022-04-18 14:28   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-04-15 15:14 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> Fix this by placing the breakpoint at "$srcfile:$line", which works
Simon> regardless of what is the current source file.

Simon> However, this ends up introducing a path in the test name.  Modify
Simon> mi_tbreak and mi_continue_to_line to avoid that.

Thanks for doing this.  This looks good to me.

Tom

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

* Re: [PATCH] gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location
  2022-04-15 15:14 ` Tom Tromey
@ 2022-04-18 14:28   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2022-04-18 14:28 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches



On 2022-04-15 11:14, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> Fix this by placing the breakpoint at "$srcfile:$line", which works
> Simon> regardless of what is the current source file.
> 
> Simon> However, this ends up introducing a path in the test name.  Modify
> Simon> mi_tbreak and mi_continue_to_line to avoid that.
> 
> Thanks for doing this.  This looks good to me.
> 
> Tom

Pushed, thanks.

Simon

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

end of thread, other threads:[~2022-04-18 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 16:26 [PATCH] gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location Simon Marchi
2022-04-15 15:14 ` Tom Tromey
2022-04-18 14:28   ` Simon Marchi

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).