public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Avoid FAILs in gdb.compile
@ 2023-02-08 17:20 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-08 17:20 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cdeb7b7de286078a1a0733a5cc9672c566917d61

commit cdeb7b7de286078a1a0733a5cc9672c566917d61
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Jan 19 14:01:27 2023 -0700

    Avoid FAILs in gdb.compile
    
    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.

Diff:
---
 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 489236a8b49..4e887daeb29 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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-08 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 17:20 [binutils-gdb] Avoid FAILs in gdb.compile 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).