[committed][gdb/testsuite] Fix use of fail in gdb_cmd_file

Tom de Vries
2020-06-04T14:18:41Z

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

[ was: Re: [PATCH][gdb/testsuite] Fix PATH error in gdb_file_cmd ]

On 04-06-2020 15:22, Pedro Alves wrote:
> On 6/4/20 2:05 PM, Tom de Vries wrote:
>
>> OK, I see your point, I'll prepare a patch for this, so let's settle on
>> the error message. How about:
>> ...
>> - fail "($arg) (GDB internal error)"
>> + perror "Couldn't load $arg into $GDB (GDB internal error)."
>> ...
>> ?
>
> LGTM, since it's what the other -re's use.
>

OK, committed as attached.

> (That leaves the open question of whether we want to include the
> full paths in the ERROR, but that can be seen as an orthogonal issue
> if you'd like.)

Yes, I'd prefer that.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Fix-use-of-fail-in-gdb_cmd_file.patch --]
[-- Type: text/x-patch, Size: 2018 bytes --]

[gdb/testsuite] Fix use of fail in gdb_cmd_file

When building gdb using this patch:
...
static void
file_command (const char *arg, int from_tty)
{
+ gdb_assert (0);
...
and running the testsuite, we run into:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
FAIL: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
PATH: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
FAIL: gdb.ada/O2_float_param.exp: frame
...

The FAIL detecting the GDB internal error is generated by this clause in
gdb_file_cmd:
...
-re "A problem internal to GDB has been detected" {
fail "($arg) (GDB internal error)"
gdb_internal_error_resync
return -1
}
...

The fail message has no text outside parenthesis, and could be considered
empty. Also, it's the only clause in the gdb_expect that uses fail, the
rest uses perror.

Fix this by replacing the fail by perror, such that we have:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
ERROR: Couldn't load outputs/gdb.ada/O2_float_param/foo into \
gdb (GDB internal error).
UNRESOLVED: gdb.ada/O2_float_param.exp: frame
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-06-04 Tom de Vries <tdevries@suse.de>

* lib/gdb.exp (gdb_file_cmd): Use perror instead of fail.

---
gdb/testsuite/lib/gdb.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 444cea01c3..63a9e3da53 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1800,7 +1800,7 @@ proc gdb_file_cmd { arg } {
return -1
}
-re "A problem internal to GDB has been detected" {
- fail "($arg) (GDB internal error)"
+ perror "Couldn't load $arg into $GDB (GDB internal error)."
gdb_internal_error_resync
return -1
}