In the failure seen by Philippe here:
https://inbox.sourceware.org/gdb-patches/
20221120173024.
3647464-1-philippe.waroquiers@skynet.be/
gdb_unload crashed GDB, leaving no trace in the test results. Change it
to use gdb_test_multiple, so that it leaves an UNRESOLVED result. I
think it is good practice anyway.
Make it return the result of gdb_test_multiple directly, change
gdb.python/py-objfile.exp accordingly.
Change gdb.base/endian.exp as well to avoid duplicate test names.
Change gdb.base/gnu-debugdata.exp to avoid recording a test result,
since gdb_unload does it already now.
Change-Id: I59a1e4947691330797e6ce23277942547c437a48
Approved-By: Tom de Vries <tdevries@suse.de>
# Now check that the automatic endianness is updated
# according to the executable selected.
-gdb_unload
+gdb_unload "unload 1"
gdb_test "set endian big" "$en_set big endian\\." \
"override target endianness big"
gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously big default executable endianness"
-gdb_unload
+gdb_unload "unload 2"
gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously big default no executable endianness"
gdb_test "set endian little" "$en_set little endian\\." \
gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously little default executable endianness"
-gdb_unload
+gdb_unload "unload 3"
gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously little default no executable endianness"
}
# Be sure to test the 'close' method on the MiniDebugInfo BFD.
-if {[gdb_unload]} {
- fail "unload MiniDebugInfo"
-} else {
- pass "unload MiniDebugInfo"
-}
+# gdb_unload records a pass/fail.
+gdb_unload
gdb_exit
"Get objfile program space"
gdb_test "python print (objfile.is_valid())" "True" \
"Get objfile validity"
-gdb_unload
+
+gdb_unload "unload 1"
+
gdb_test "python print (objfile.is_valid())" "False" \
"Get objfile validity after unload"
# Verify invalid objfile handling.
-if { [gdb_unload] < 0 } {
- fail "unload all files"
- return -1
+if { [gdb_unload "unload 2"] != 0 } {
+ return
}
gdb_test "python print(objfile.filename)" "None" \
return [default_gdb_version]
}
-#
# gdb_unload -- unload a file if one is loaded
-# Return 0 on success, -1 on error.
#
+# Returns the same as gdb_test_multiple.
-proc gdb_unload {} {
+proc gdb_unload { {msg "file"} } {
global GDB
global gdb_prompt
- send_gdb "file\n"
- gdb_expect 60 {
- -re "No executable file now\[^\r\n\]*\[\r\n\]" { exp_continue }
- -re "No symbol file now\[^\r\n\]*\[\r\n\]" { exp_continue }
- -re "A program is being debugged already.*Are you sure you want to change the file.*y or n. $" {
+ return [gdb_test_multiple "file" $msg {
+ -re "A program is being debugged already.\r\nAre you sure you want to change the file. .y or n. $" {
send_gdb "y\n" answer
exp_continue
}
- -re "Discard symbol table from .*y or n.*$" {
- send_gdb "y\n" answer
+
+ -re "No executable file now\\.\r\n" {
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
+
+ -re "Discard symbol table from `.*'. .y or n. $" {
+ send_gdb "y\n" answer
+ exp_continue
}
- timeout {
- perror "couldn't unload file in $GDB (timeout)."
- return -1
+
+ -re -wrap "No symbol file now\\." {
+ pass $gdb_test_name
}
- }
- return 0
+ }]
}
# Many of the tests depend on setting breakpoints at various places and