gdb/testsuite: Fix libc_has_debug_info when there's no libc
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
Bernd reported a Tcl error when running gdb.base/relativedebug.exp with
a riscv-unknown-elf target with newlib (so there is no libc) because of
commit f5ef12c3f1af ("gdb/testsuite: Add libc_has_debug_info require
helper"):
Running /home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp ...
FAIL: gdb.base/relativedebug.exp: info sharedlibrary libc.so
ERROR: tcl error sourcing /home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp.
ERROR: tcl error code TCL READ VARNAME
ERROR: can't read "libc_has_debug_info": no such variable
while executing
"verbose "$me: returning $libc_has_debug_info" 2"
(procedure "gdb_real__libc_has_debug_info" line 47)
invoked from within
"gdb_real__libc_has_debug_info"
("uplevel" body line 1)
invoked from within
"uplevel 2 [list $real_name {*}$args]"
invoked from within
"gdb_do_cache_wrap $real_name {*}$args"
(procedure "gdb_do_cache" line 48)
invoked from within
"gdb_do_cache libc_has_debug_info"
(procedure "libc_has_debug_info" line 1)
invoked from within
"libc_has_debug_info"
("uplevel" body line 1)
invoked from within
"uplevel 1 $fn"
(procedure "require" line 11)
invoked from within
"require {!target_info exists gdb,nosignals} libc_has_debug_info"
(file "/home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp" line 16)
The problem is that when there's no libc.so in the inferior,
"info sharedlibrary libc.so" responds with an output that doesn't match
any of the patterns provided in libc_has_debug_info so gdb_test_multiple
matches an internal pattern for the GDB prompt and thus the
$libc_has_debug_info variable doesn't get set in the default pattern.
Fix by:
- always defining libc_has_debug_info and message with a default
value,
- adding a pattern for the case where there's no libc.so in the
inferior, and
- removing the default pattern, which doesn't serve a purpose anymore.
Also, remove a couple of verbose messages which aren't really useful
because they're redundant with the $message variable.
---
gdb/testsuite/lib/gdb.exp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
base-commit: cd0dbe767775fdbfdc875a14f9080fdea0841c92
Comments
On 4/26/24 04:52, Thiago Jung Bauermann wrote:
> Bernd reported a Tcl error when running gdb.base/relativedebug.exp with
> a riscv-unknown-elf target with newlib (so there is no libc) because of
> commit f5ef12c3f1af ("gdb/testsuite: Add libc_has_debug_info require
> helper"):
>
> Running /home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp ...
> FAIL: gdb.base/relativedebug.exp: info sharedlibrary libc.so
> ERROR: tcl error sourcing /home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp.
> ERROR: tcl error code TCL READ VARNAME
> ERROR: can't read "libc_has_debug_info": no such variable
> while executing
> "verbose "$me: returning $libc_has_debug_info" 2"
> (procedure "gdb_real__libc_has_debug_info" line 47)
> invoked from within
> "gdb_real__libc_has_debug_info"
> ("uplevel" body line 1)
> invoked from within
> "uplevel 2 [list $real_name {*}$args]"
> invoked from within
> "gdb_do_cache_wrap $real_name {*}$args"
> (procedure "gdb_do_cache" line 48)
> invoked from within
> "gdb_do_cache libc_has_debug_info"
> (procedure "libc_has_debug_info" line 1)
> invoked from within
> "libc_has_debug_info"
> ("uplevel" body line 1)
> invoked from within
> "uplevel 1 $fn"
> (procedure "require" line 11)
> invoked from within
> "require {!target_info exists gdb,nosignals} libc_has_debug_info"
> (file "/home/ed/gnu/binutils-build-riscv64/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/relativedebug.exp" line 16)
>
> The problem is that when there's no libc.so in the inferior,
> "info sharedlibrary libc.so" responds with an output that doesn't match
> any of the patterns provided in libc_has_debug_info so gdb_test_multiple
> matches an internal pattern for the GDB prompt and thus the
> $libc_has_debug_info variable doesn't get set in the default pattern.
>
> Fix by:
>
> - always defining libc_has_debug_info and message with a default
> value,
> - adding a pattern for the case where there's no libc.so in the
> inferior, and
> - removing the default pattern, which doesn't serve a purpose anymore.
>
> Also, remove a couple of verbose messages which aren't really useful
> because they're redundant with the $message variable.
Tested-By: Bernd Edlinger <bernd.edlinger@hotmail.de>
Thanks
Bernd.
> ---
> gdb/testsuite/lib/gdb.exp | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 1e26937c0dcf..35e4de9e3b9d 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -3726,20 +3726,20 @@ gdb_caching_proc libc_has_debug_info {} {
> gdb_reinitialize_dir $srcdir/$subdir
> gdb_load "$obj"
> runto_main
> + set libc_has_debug_info 0
> + set message "unable to get information on libc.so"
> set test "info sharedlibrary libc.so"
> gdb_test_multiple $test $test {
> -re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
> # Matched the "(*)" in the "Syms Read" columns which means:
> # "(*): Shared library is missing debugging information."
> - verbose -log "$me: libc doesn't have debug info"
> set libc_has_debug_info 0
> set message "libc doesn't have debug info"
> }
> -re ".*Yes\[ \t\]+\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
> - verbose -log "$me: libc has debug info"
> set libc_has_debug_info 1
> }
> - default {
> + -re -wrap "No shared libraries matched." {
> set libc_has_debug_info 0
> set message "libc not found in the inferior"
> }
>
> base-commit: cd0dbe767775fdbfdc875a14f9080fdea0841c92
>>>>> "Thiago" == Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
Thiago> Fix by:
Thiago> - always defining libc_has_debug_info and message with a default
Thiago> value,
Thiago> - adding a pattern for the case where there's no libc.so in the
Thiago> inferior, and
Thiago> - removing the default pattern, which doesn't serve a purpose anymore.
Thiago> Also, remove a couple of verbose messages which aren't really useful
Thiago> because they're redundant with the $message variable.
Thanks. This looks reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
Hello Tom,
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Thiago" == Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
>
> Thiago> Fix by:
>
> Thiago> - always defining libc_has_debug_info and message with a default
> Thiago> value,
> Thiago> - adding a pattern for the case where there's no libc.so in the
> Thiago> inferior, and
> Thiago> - removing the default pattern, which doesn't serve a purpose anymore.
>
> Thiago> Also, remove a couple of verbose messages which aren't really useful
> Thiago> because they're redundant with the $message variable.
>
> Thanks. This looks reasonable to me.
> Approved-By: Tom Tromey <tom@tromey.com>
Thank you.
And thank you Bernd for testing the patch.
Though Pedro raised concerns about libc_has_debug_info:
https://inbox.sourceware.org/gdb-patches/b0409c48-7f9c-4430-91d9-dc7cfa86a9c7@palves.net/
So I just sent a new patch which is an alternative to this one:
https://inbox.sourceware.org/gdb-patches/20240430015325.89780-1-thiago.bauermann@linaro.org/
which restores the original behaviour and also fixes Bernd's reported
Tcl error.
@@ -3726,20 +3726,20 @@ gdb_caching_proc libc_has_debug_info {} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load "$obj"
runto_main
+ set libc_has_debug_info 0
+ set message "unable to get information on libc.so"
set test "info sharedlibrary libc.so"
gdb_test_multiple $test $test {
-re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
# Matched the "(*)" in the "Syms Read" columns which means:
# "(*): Shared library is missing debugging information."
- verbose -log "$me: libc doesn't have debug info"
set libc_has_debug_info 0
set message "libc doesn't have debug info"
}
-re ".*Yes\[ \t\]+\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
- verbose -log "$me: libc has debug info"
set libc_has_debug_info 1
}
- default {
+ -re -wrap "No shared libraries matched." {
set libc_has_debug_info 0
set message "libc not found in the inferior"
}