[committed,gdb/testsuite] Handle internal-error in gdb_unload

Message ID b28ed132-8a19-b6c3-17f6-3ab1564ac079@suse.de
State New
Headers show
Series
  • [committed,gdb/testsuite] Handle internal-error in gdb_unload
Related show

Commit Message

Tom de Vries via Gdb-patches Sept. 7, 2021, 8:21 a.m.
[ was: Re: [PATCH][gdb/testsuite] Simplify
gdb.dwarf2/locexpr-data-member-location.exp ]

On 9/5/21 8:39 AM, Tom de Vries wrote:
> +# Avoid questions from the file command about:

> +# - Are you sure you want to change the file (y or n) ?

> +# - Discard symbol table from <file> (y or n) ?

> +gdb_test_no_output "set confirm off"

> +

> +# Tell internal-error how to behave, otherwise "set confirm off" will trigger

> +# generation of core file.

> +gdb_test_no_output "maint set internal-error quit no"

> +gdb_test_no_output "maint set internal-error corefile no"

> +

> +setup_kfail gdb/28030 *-*-*

> +gdb_test "file" "No executable file now\\." "Discard file"


I realized that we have gdb_unload for this, which handles the file
command questions.  But it's missing the internal-error handling.

I've fixed this in a separate patch.

Thanks,
- Tom

Patch

[gdb/testsuite] Handle internal-error in gdb_unload

When reverting commit 5a20fadc841 and using gdb_unload instead of runto "bar"
to trigger the internal-error in test-case
gdb.dwarf2/locexpr-data-member-location.exp, we run into:
...
ERROR: couldn't unload file in $gdb (timeout).
...
and the test-case takes about 1 minute.

Fix this by handling internal-error in gdb_unload, such that we have:
...
ERROR: Couldn't unload file in $gdb (GDB internal error).
ERROR: Could not resync from internal error (eof)
...
within 2 seconds.

Tested on x86_64-linux.

---
 gdb/testsuite/lib/gdb.exp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d99e8360808..ff19760bac4 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -235,6 +235,11 @@  proc gdb_unload {} {
 	    exp_continue
 	}
 	-re "$gdb_prompt $" {}
+	-re "A problem internal to GDB has been detected" {
+	    perror "Couldn't unload file in $GDB (GDB internal error)."
+	    gdb_internal_error_resync
+	    return -1
+	}
 	timeout {
 	    perror "couldn't unload file in $GDB (timeout)."
 	    return -1