From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/2] Avoid FAILs in gdb.compile
Date: Mon, 23 Jan 2023 15:02:57 -0700 [thread overview]
Message-ID: <20230123220257.3773828-3-tromey@adacore.com> (raw)
In-Reply-To: <20230123220257.3773828-1-tromey@adacore.com>
Many gdb.compile C++ tests fail for me on Fedora 36. I think these
are largely bugs in the plugin, though I didn't investigate too
deeply. Once one failure is seen, this often cascades and sometimes
there are many timeouts.
For example, this can happen:
(gdb) compile code var = a->get_var ()
warning: Could not find symbol "_ZZ9_gdb_exprP10__gdb_regsE1a" for compiled module "/tmp/gdbobj-0xdI6U/out2.o".
1 symbols were missing, cannot continue.
I think this is probably a plugin bug because, IIRC, in theory these
symbols should be exempt from a lookup via gdb.
This patch arranges to catch any catastrophic failure and then simply
exit the entire .exp file.
---
gdb/testsuite/gdb.compile/compile-cplus.exp | 4 +-
gdb/testsuite/lib/compile-support.exp | 59 ++++++++++++++++++---
2 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp
index 0b7cb59727a..1b926844f06 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus.exp
@@ -113,7 +113,7 @@ gdb_test "compile code *(volatile int *) 0 = 0;" \
"The program being debugged was signaled while in a function called from GDB\\.\r\nGDB remains in the frame where the signal was received\\.\r\n.*" \
"compile code segfault first"
gdb_test "bt" \
- "\r\n#0 \[^\r\n\]* in _gdb_expr \[^\r\n\]*\r\n#1 <function called from gdb>\r\n.*"
+ "\r\n#0 \[^\r\n\]*_gdb_expr \[^\r\n\]*\r\n#1 <function called from gdb>.*"
set test "p/x \$pc"
set infcall_pc 0
@@ -242,7 +242,9 @@ gdb_test "print globalvar" " = 20" "print unresolved value"
gdb_test_no_output "compile code globalshadow += 1;"
gdb_test "print globalshadow" " = 101"
+setup_kfail {no bug filed} *-*-*
gdb_test_no_output "compile code extern int globalshadow; globalshadow += 5;"
+setup_kfail {fails due to previous test} *-*-*
gdb_test "print 'compile-cplus.c'::globalshadow" " = 15"
gdb_test "print globalshadow" " = 101" "print globalshadow second time"
gdb_test_no_output "compile code staticshadow += 2;"
diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp
index 64fda8c58a2..a8cf52f1f00 100644
--- a/gdb/testsuite/lib/compile-support.exp
+++ b/gdb/testsuite/lib/compile-support.exp
@@ -41,6 +41,10 @@ proc _do_check_compile {expr} {
# See PR compile/29541.
set result "confused by glibc debuginfo"
}
+ -re "$::decimal symbols were missing, cannot continue" {
+ # This appears to be a bug in the compiler plugin.
+ set result "apparent compiler plugin bug"
+ }
-re "\r\n$gdb_prompt $" {
}
}
@@ -189,17 +193,55 @@ namespace eval ::CompileExpression {
set value $l
}
+ set ok 1
if {!$nocode} {
- do_test_ code $exp $result $explicit $name \
- [list $compile $value $print]
+ if {![do_test_ code $exp $result $explicit $name \
+ [list $compile $value $print]]} {
+ set ok 0
+ }
+ }
+ if {$ok && !$noprint} {
+ if {![do_test_ print $exp $result $explicit $name \
+ [list $compile $value $print]]} {
+ set ok 0
+ }
}
- if {!$noprint} {
- do_test_ print $exp $result $explicit $name \
- [list $compile $value $print]
+ if {!$ok} {
+ return -code return 0
}
}
+ # Invoke a 'compile' command of some form. COMMAND is the
+ # command, RESULT is the expected output, and NAME is the test
+ # name. Issues a pass or fail. Returns 1 on success, 0 if there
+ # is a failure that should result in the entire remaining .exp
+ # being stopped; in this case an 'unsupported' is issued.
+
+ proc compile_command_ {command result name} {
+ global gdb_prompt
+ set this_result 1
+ gdb_test_multiple $command $name {
+ -re "WARNING .* there are active plugins, do not report this" {
+ # Note that the regexp above does not check for the
+ # prompt. This avoids a gratuitous timeout.
+ unsupported "GCC compiler plugin crashed"
+ set this_result 0
+ }
+ -re "$::decimal symbols were missing, cannot continue" {
+ # This appears to be a bug in the compiler plugin.
+ unsupported "GCC compiler plugin bug"
+ set this_result 0
+ }
+ -re -wrap "$result" {
+ pass $name
+ }
+ }
+ return $this_result
+ }
+
# Run a compile test for CMD ("print" or "code").
+ # Return 1 on success, 0 if there is some kind of catastrophic
+ # error.
proc do_test_ {cmd exp result is_explicit tst fail_list} {
variable varName_
@@ -221,7 +263,7 @@ namespace eval ::CompileExpression {
if {[string match $cmd "print"]} {
if {!$is_explicit} {
eval setup_failures_ $fail_print
- gdb_test "compile print $exp" $result $tst
+ return [compile_command_ "compile print $exp" $result $tst]
}
} else {
if {$is_explicit} {
@@ -230,10 +272,13 @@ namespace eval ::CompileExpression {
set command "compile code $varName_ = $exp"
}
eval setup_failures_ $fail_compile
- gdb_test_no_output $command $tst
+ if {![compile_command_ $command "" $tst]} {
+ return 0
+ }
eval setup_failures_ $fail_value
gdb_test "p $varName_" "= $result" "result of $tst"
}
+ return 1
}
# A convenience proc used to set up xfail and kfail tests.
--
2.38.1
next prev parent reply other threads:[~2023-01-23 22:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 22:02 [PATCH 0/2] Suppress some FAILs Tom Tromey
2023-01-23 22:02 ` [PATCH 1/2] Don't let .gdb_history file cause failures Tom Tromey
2023-01-23 22:02 ` Tom Tromey [this message]
2023-01-24 15:41 ` [PATCH 2/2] Avoid FAILs in gdb.compile Alexandra Petlanova Hajkova
2023-02-08 17:18 ` [PATCH 0/2] Suppress some FAILs Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230123220257.3773828-3-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).