Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/testsuite] Add untested case in selftest_setup
@ 2021-09-02  6:13 Tom de Vries via Gdb-patches
  2021-09-03 12:24 ` Simon Marchi via Gdb-patches
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries via Gdb-patches @ 2021-09-02  6:13 UTC (permalink / raw)
  To: gdb-patches

Hi,

When building gdb with "-Wall -O2 -g -flto=auto", I run into:
...
FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
  (got interactive prompt)
FAIL: gdb.gdb/python-helper.exp: run until breakpoint at captured_main
WARNING: Couldn't test self
...
and similar in gdb.gdb/selftest.exp.

The first FAIL in more detail:
...
(gdb) break captured_main^M
Function "captured_main" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
  (got interactive prompt)
...

The problem is that lto has optimized away the captured_main function
and consequently the selftests dependent on that cannot run.

Fix this by:
- using gdb_breakpoint to detect failure to set the breakpoint
- handling the failure to set a breakpoint by calling untested
- not emitting the warning if we've already got untested
such that we have:
...
(gdb) UNTESTED: gdb.gdb/python-helper.exp: Cannot set breakpoint at \
  captured_main, skipping testcase.
...

Any comments?

Thanks,
- Tom

[gdb/testsuite] Add untested case in selftest_setup

gdb/testsuite/ChangeLog:

2021-09-02  Tom de Vries  <tdevries@suse.de>

	* lib/selftest-support.exp: Emit untested when not being able to set
	breakpoint.

---
 gdb/testsuite/lib/selftest-support.exp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 4b96bf4f5f6..325ea997d5e 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -40,6 +40,8 @@ proc find_gdb { arg } {
 # EXECUTABLE is the gdb to use.
 # FUNCTION is the function to break in, either captured_main
 # or captured_command_loop.
+# Return 0 in case of success, -1 in case of failure, and -2 in case of
+# skipping the test-case.
 
 proc selftest_setup { executable function } {
     global gdb_prompt
@@ -73,14 +75,14 @@ proc selftest_setup { executable function } {
 
     if { $gdb_file_cmd_debug_info != "debug" } then {
 	untested "no debug information, skipping testcase."
-	return -1
+	return -2
     }
 
-    # Set a breakpoint at main.  Allow more than one location, as
-    # workaround for PR26096 - "gdb sets breakpoint at cold clone".
-    gdb_test "break $function" \
-            "Breakpoint.*at.* (file.*, line|locations).*" \
-            "breakpoint in $function"
+    # Set a breakpoint at $function.
+    if { [gdb_breakpoint $function "no-message"] != 1 } {
+	untested "Cannot set breakpoint at $function, skipping testcase."
+	return -2
+    }
 
     # run yourself
     # It may take a very long time for the inferior gdb to start (lynx),
@@ -165,7 +167,7 @@ proc do_self_tests {function body} {
     gdb_exit
     catch "remote_file host delete $file"
 
-    if {$result < 0} then {
+    if {$result == -1} then {
 	warning "Couldn't test self"
     }
 }

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

* Re: [PATCH][gdb/testsuite] Add untested case in selftest_setup
  2021-09-02  6:13 [PATCH][gdb/testsuite] Add untested case in selftest_setup Tom de Vries via Gdb-patches
@ 2021-09-03 12:24 ` Simon Marchi via Gdb-patches
  2021-09-03 14:40   ` [committed][gdb/testsuite] Add untested case in gdb.gdb/complaints.exp Tom de Vries via Gdb-patches
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi via Gdb-patches @ 2021-09-03 12:24 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 2021-09-02 2:13 a.m., Tom de Vries via Gdb-patches wrote:
> Hi,
> 
> When building gdb with "-Wall -O2 -g -flto=auto", I run into:
> ...
> FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
>   (got interactive prompt)
> FAIL: gdb.gdb/python-helper.exp: run until breakpoint at captured_main
> WARNING: Couldn't test self
> ...
> and similar in gdb.gdb/selftest.exp.
> 
> The first FAIL in more detail:
> ...
> (gdb) break captured_main^M
> Function "captured_main" not defined.^M
> Make breakpoint pending on future shared library load? (y or [n]) n^M
> (gdb) FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
>   (got interactive prompt)
> ...
> 
> The problem is that lto has optimized away the captured_main function
> and consequently the selftests dependent on that cannot run.
> 
> Fix this by:
> - using gdb_breakpoint to detect failure to set the breakpoint
> - handling the failure to set a breakpoint by calling untested
> - not emitting the warning if we've already got untested
> such that we have:
> ...
> (gdb) UNTESTED: gdb.gdb/python-helper.exp: Cannot set breakpoint at \
>   captured_main, skipping testcase.
> ...
> 
> Any comments?

I don't see what else we could do in this case, so LGTM.

Simon

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

* [committed][gdb/testsuite] Add untested case in gdb.gdb/complaints.exp
  2021-09-03 12:24 ` Simon Marchi via Gdb-patches
@ 2021-09-03 14:40   ` Tom de Vries via Gdb-patches
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries via Gdb-patches @ 2021-09-03 14:40 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

[ was: re: [PATCH][gdb/testsuite] Add untested case in selftest_setup ]

On 9/3/21 2:24 PM, Simon Marchi wrote:
> On 2021-09-02 2:13 a.m., Tom de Vries via Gdb-patches wrote:
>> Any comments?
> 
> I don't see what else we could do in this case, so LGTM.
> 

Thanks for the review, pushed.

Also pushed a similar fix for a similar problem in gdb.gdb/complaints.exp.

Thanks,
- Tom


[-- Attachment #2: 0001-gdb-testsuite-Add-untested-case-in-gdb.gdb-complaints.exp.patch --]
[-- Type: text/x-patch, Size: 1729 bytes --]

[gdb/testsuite] Add untested case in gdb.gdb/complaints.exp

When building gdb with "-Wall -O2 -g -flto=auto", I run into:
...
(gdb) call clear_complaints()^M
No symbol "clear_complaints" in current context.^M
(gdb) FAIL: gdb.gdb/complaints.exp: clear complaints
...

The problem is that lto has optimized away clear_complaints, and consequently
the selftests cannot run.

Fix this by:
- using info function to detect presence of clear_complaints
- handling the absence of clear_complaints by calling untested
...
(gdb) UNTESTED: gdb.gdb/complaints.exp: \
  Cannot find clear_complaints, skipping test
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-03  Tom de Vries  <tdevries@suse.de>

	* gdb.gdb/complaints.exp: Use untested if clear_complaints cannot
	be found.

---
 gdb/testsuite/gdb.gdb/complaints.exp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gdb/testsuite/gdb.gdb/complaints.exp b/gdb/testsuite/gdb.gdb/complaints.exp
index c70825b6623..2391d661250 100644
--- a/gdb/testsuite/gdb.gdb/complaints.exp
+++ b/gdb/testsuite/gdb.gdb/complaints.exp
@@ -104,6 +104,26 @@ proc test_empty_complaint { cmd msg } {
 }
 
 proc test_empty_complaints { } {
+    global decimal
+
+    set re [multi_line \
+		"All functions matching regular expression \[^:\]*:" \
+		"" \
+		"File \[^\r\n\]*/complaints\\.c:" \
+		"$decimal:\tvoid clear_complaints\\(\\);"]
+
+    set found 0
+    gdb_test_multiple "info function ^clear_complaints()$" "" {
+	-re -wrap $re {
+	    set found 1
+	}
+	-re -wrap "" {
+	}
+    }
+    if { ! $found } {
+	untested "Cannot find clear_complaints, skipping test"
+	return 0
+    }
 
     test_empty_complaint "call clear_complaints()" \
 	    "clear complaints"

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

end of thread, other threads:[~2021-09-03 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02  6:13 [PATCH][gdb/testsuite] Add untested case in selftest_setup Tom de Vries via Gdb-patches
2021-09-03 12:24 ` Simon Marchi via Gdb-patches
2021-09-03 14:40   ` [committed][gdb/testsuite] Add untested case in gdb.gdb/complaints.exp Tom de Vries via Gdb-patches

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