public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/testsuite: Fix libc_has_debug_info when there's no libc
Date: Fri, 26 Apr 2024 07:09:01 +0200	[thread overview]
Message-ID: <AS8P193MB12858AB25516164BCB8E2191E4162@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240426025251.1679310-1-thiago.bauermann@linaro.org>

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

  reply	other threads:[~2024-04-26  5:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26  2:52 Thiago Jung Bauermann
2024-04-26  5:09 ` Bernd Edlinger [this message]
2024-04-26 16:37 ` Tom Tromey
2024-04-30  2:07   ` Thiago Jung Bauermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P193MB12858AB25516164BCB8E2191E4162@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM \
    --to=bernd.edlinger@hotmail.de \
    --cc=gdb-patches@sourceware.org \
    --cc=thiago.bauermann@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).