From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 3EDE83858024; Thu, 1 Dec 2022 15:39:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EDE83858024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669909196; bh=HyGU/Za0Rajaxm9p80cYC5JxSOtNY9Fwj1iLotQH60g=; h=From:To:Subject:Date:From; b=TzPDqW5hTGx1iIFwqDMFaC4P0thfDqo01vk12pbav4KA+nNqwwUIZSR2jQQaBmudb tSeG/ELCIU33P++nFpaqMDFl1ZaFTvATJY4/xQ5VQmZiGQsMTor99VFDQY+Lt4zHUw eYL3i2d+lLOEHllRpKCq38pT9kwgCSo2dO+zrLFc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Avoid timeouts in gdb.compile X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5b92bbd934059eb06cf531c268627deef53886aa X-Git-Newrev: 9a7fde04ca4232d4b2efed61486fff65e83ab3a2 Message-Id: <20221201153956.3EDE83858024@sourceware.org> Date: Thu, 1 Dec 2022 15:39:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9a7fde04ca42= 32d4b2efed61486fff65e83ab3a2 commit 9a7fde04ca4232d4b2efed61486fff65e83ab3a2 Author: Tom Tromey Date: Wed Nov 30 11:27:10 2022 -0700 Avoid timeouts in gdb.compile =20 PR compile/29541 points out that some of the C++ tests in gdb.compile will time out when the glibc debuginfo is installed. This was interfering with my hacking on gdb by making test runs extremely long, so I looked into it. =20 Internally the bug seems to be that gdb tries to convert multiple symbols named "var" via the compiler interface; one such symbol (I didn't track it down too far) causes the C++ compiler plugin to crash. =20 Unfortunately, the crash is reported as a timeout, as the gdb side of the plugin simply hangs. This seems like a bug in the plugin RPC mechanism and, worse, apparently when I wrote this stuff I didn't really consider error reporting very much at all, so gdb can't really detect failures in the first place. =20 Anyway... this patch works around the timeout by compiling a simple test that should provoke this bug, and then using "untested" if it notices a GCC crash. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29541 Diff: --- .../gdb.compile/compile-cplus-anonymous.exp | 10 ++--- .../gdb.compile/compile-cplus-array-decay.exp | 4 +- .../gdb.compile/compile-cplus-inherit.exp | 10 ++--- gdb/testsuite/gdb.compile/compile-cplus-member.exp | 10 ++--- gdb/testsuite/gdb.compile/compile-cplus-method.exp | 10 ++--- .../gdb.compile/compile-cplus-namespace.exp | 10 ++--- gdb/testsuite/gdb.compile/compile-cplus-nested.exp | 10 ++--- gdb/testsuite/gdb.compile/compile-cplus-print.exp | 3 +- .../gdb.compile/compile-cplus-virtual.exp | 10 ++--- gdb/testsuite/gdb.compile/compile-cplus.exp | 9 ++-- gdb/testsuite/gdb.compile/compile-ifunc.exp | 3 +- gdb/testsuite/gdb.compile/compile-ops.exp | 3 +- gdb/testsuite/gdb.compile/compile-print.exp | 3 +- gdb/testsuite/gdb.compile/compile-setjmp.exp | 3 +- gdb/testsuite/gdb.compile/compile-tls.exp | 3 +- gdb/testsuite/gdb.compile/compile.exp | 3 +- gdb/testsuite/lib/compile-support.exp | 48 ++++++++++++++++++= +--- 17 files changed, 82 insertions(+), 70 deletions(-) diff --git a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp b/gdb/te= stsuite/gdb.compile/compile-cplus-anonymous.exp index 26a331a2ac8..c3ffeeb93fd 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + # Reminder, "var" is an integer; all these types get converted to `int'. CompileExpression::new "var" CompileExpression::test "anon_e" {(3|GHI)} diff --git a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp b/gdb/= testsuite/gdb.compile/compile-cplus-array-decay.exp index 18062a31b9c..2892d2415be 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp @@ -33,9 +33,7 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp b/gdb/test= suite/gdb.compile/compile-cplus-inherit.exp index 8f3d282cd49..536a5a45fc2 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "d.a_" 1 CompileExpression::test "d.b_" 2 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-member.exp b/gdb/tests= uite/gdb.compile/compile-cplus-member.exp index 9325863a3bb..c18f965c9f3 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-member.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-member.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "a.public_" 1 CompileExpression::test "a.protected_" {(21|N::NB)} diff --git a/gdb/testsuite/gdb.compile/compile-cplus-method.exp b/gdb/tests= uite/gdb.compile/compile-cplus-method.exp index 07e4a59bb36..2f96f5fb147 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-method.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-method.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "a->get_var ()" 21 CompileExpression::test "a->get_var (static_cast (1))" 100 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp b/gdb/te= stsuite/gdb.compile/compile-cplus-namespace.exp index 4fc626beb22..ec4d0099846 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "N1::N2::N3::N4::n4static" 400 CompileExpression::test "N1::N2::N3::N4::S4::s4static" 40 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp b/gdb/tests= uite/gdb.compile/compile-cplus-nested.exp index 1d28e3471cb..a5ad87e49f9 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-nested.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "i1.a_" 2 CompileExpression::test "i2.a_" 3 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-print.exp b/gdb/testsu= ite/gdb.compile/compile-cplus-print.exp index 67b39518b74..38dd922d27e 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-print.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-print.exp @@ -36,8 +36,7 @@ if ![runto_main] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp b/gdb/test= suite/gdb.compile/compile-cplus-virtual.exp index ee1a4d92e38..3ccd681ea46 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp @@ -33,15 +33,13 @@ if {![runto_main]} { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested \ - "compile command not supported (could not find libcc1 shared library?)" - return -1 -} - gdb_breakpoint [gdb_get_line_number "break here" $srcfile] gdb_continue_to_breakpoint "testing location" =20 +if {[skip_compile_feature_untested "var =3D 0"]} { + return -1 +} + CompileExpression::new "var" CompileExpression::test "b.doit ()" 2 CompileExpression::test "c.doit ()" 3 diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gd= b.compile/compile-cplus.exp index dbdae5f8bf4..10e70e4a8e6 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp @@ -52,8 +52,10 @@ if ![runto_main] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +gdb_breakpoint [gdb_get_line_number "break-here"] +gdb_continue_to_breakpoint "break-here" ".* break-here .*" + +if {[skip_compile_feature_untested "var =3D 0"]} { return -1 } =20 @@ -132,9 +134,6 @@ gdb_test "compile code *(volatile int *) 0 =3D 0;" \ "The program being debugged was signaled while in a function called fr= om GDB\\.\r\nGDB has restored the context to what it was before the call\\.= \r\n.*" \ "compile code segfault second" =20 -gdb_breakpoint [gdb_get_line_number "break-here"] -gdb_continue_to_breakpoint "break-here" ".* break-here .*" - # C++ Specific tests. ## Public methods and members =20 diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gd= b.compile/compile-ifunc.exp index 07de52c3f67..5c51dd173c5 100644 --- a/gdb/testsuite/gdb.compile/compile-ifunc.exp +++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp @@ -43,8 +43,7 @@ with_test_prefix "nodebug" { # feature check below will work. gdb_test_no_output "set language c" "" =20 - if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared lib= rary?)" + if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.= compile/compile-ops.exp index cff2f946c93..e18f92eaa39 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.exp +++ b/gdb/testsuite/gdb.compile/compile-ops.exp @@ -418,8 +418,7 @@ if ![runto func] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-print.exp b/gdb/testsuite/gd= b.compile/compile-print.exp index 5d01c1a53d0..61d13312e3a 100644 --- a/gdb/testsuite/gdb.compile/compile-print.exp +++ b/gdb/testsuite/gdb.compile/compile-print.exp @@ -25,8 +25,7 @@ if ![runto_main] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-setjmp.exp b/gdb/testsuite/g= db.compile/compile-setjmp.exp index c883b2bd570..2f9d844c89b 100644 --- a/gdb/testsuite/gdb.compile/compile-setjmp.exp +++ b/gdb/testsuite/gdb.compile/compile-setjmp.exp @@ -25,8 +25,7 @@ if ![runto_main] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile-tls.exp b/gdb/testsuite/gdb.= compile/compile-tls.exp index beffe7fd5be..6b349069ec7 100644 --- a/gdb/testsuite/gdb.compile/compile-tls.exp +++ b/gdb/testsuite/gdb.compile/compile-tls.exp @@ -27,8 +27,7 @@ if {![runto_main]} { return 0 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.comp= ile/compile.exp index c712070872a..b75ec4bd485 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -57,8 +57,7 @@ if ![runto_main] { return -1 } =20 -if {[skip_compile_feature_tests]} { - untested "compile command not supported (could not find libcc1 shared = library?)" +if {[skip_compile_feature_untested]} { return -1 } =20 diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/comp= ile-support.exp index 16b7c5dbc0d..b6427337c5b 100644 --- a/gdb/testsuite/lib/compile-support.exp +++ b/gdb/testsuite/lib/compile-support.exp @@ -15,16 +15,31 @@ =20 # Generic/oft used support routines for testing GDB's compile feature. =20 -# Return 1 if we should skip tests of the "compile" feature. -# This must be invoked after the inferior has been started. +# Helper function for skip_compile_feature_tests. This does the real +# work, but should not be called directly. Returns a failure reason +# (a string) on failure, or the empty string on success. =20 -proc skip_compile_feature_tests {} { +proc _do_check_compile {expr} { global gdb_prompt =20 - set result 0 - gdb_test_multiple "compile code -- ;" "check for working compile comma= nd" { + set result "" + gdb_test_multiple "compile code -- $expr;" "check for working compile = command" { "Could not load libcc1.*\r\n$gdb_prompt $" { - set result 1 + set result "could not find libcc1" + } + "Could not load libcp1.*\r\n$gdb_prompt $" { + set result "could not find libcp1" + } + -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. + set result "GCC crashed" + } + -re "confused by earlier errors, bailing out" { + # This scenario can happen when either GCC or GDB is + # confused by some other debuginfo. + # See PR compile/29541. + set result "confused by glibc debuginfo" } -re "\r\n$gdb_prompt $" { } @@ -32,6 +47,27 @@ proc skip_compile_feature_tests {} { return $result } =20 +# Return 1 if we should skip tests of the "compile" feature. +# This must be invoked after the inferior has been started. +# EXPR is the expression to test, if any (using the default empty EXPR +# works fine in most cases). + +proc skip_compile_feature_tests {{expr ""}} { + return [expr {[string length [_do_check_compile $expr]] > 0}] +} + +# Like skip_compile_feature_tests, but also issue an "untested" when +# skipping. + +proc skip_compile_feature_untested {{expr ""}} { + set output [_do_check_compile $expr] + if {[string length $output] > 0} { + untested "compile command not supported ($output)" + return 1 + } + return 0 +} + # This namespace provides some convenience functions for running # "compile code" and "compile print" tests. #