Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Guinevere Larsen <guinevere@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test
Date: Fri, 11 Apr 2025 12:26:28 +0200	[thread overview]
Message-ID: <f2dff8ed-67b1-400a-9901-3fe9c6ae5326@suse.de> (raw)
In-Reply-To: <20250410130148.1880139-1-guinevere@redhat.com>

On 4/10/25 15:01, Guinevere Larsen wrote:
> The recently included gdb.base/dlmopen-ns-ids.exp test can sometimes
> fail the call to get_integer_valueof when trying to check the namespace
> ID of the fourth dlopened SO, for apparently no reason.
> 
> What's happening is that the call to get_first_so_ns doesn't necessarily
> consume the GDB prompt, and so get_integer_valueof will see the prompt
> immediately and not find the value the test is looking for.
> 
> To fix this, the test was changed so that we consume all of the output
> of the command "info sharedlibrary", but only set the namespace ID for
> the first occurence of the SO we're looking for.  The command now also
> gets the solib name as a parameter, to reduce the amount of output.
> 

Hi Gwen,

LGTM.

I've also ran it through make-check-all.sh, and found no issues.

I did notice a typo, and indeed, the proposed codespell-log check 
confirmed it ( 
https://sourceware.org/pipermail/gdb-patches/2025-April/217118.html ):
...
codespell-log............................................................Passed
- hook id: codespell-log
- duration: 0.19s

codespell-log-internal...................................................Failed
- hook id: codespell
- exit code: 65

.git/COMMIT_EDITMSG:13: occurence ==> occurrence

...

OK with that fixed.

Approved-By: Tom de Vries <tdevries@suse.de>

FWIW, I don't much like the style of regexp used, I find it hard to parse.

I prefer something more spaced out and less escape-heavy, like:
...
     set re1 [list "From" "To" "(NS" ")?Syms" "Read" "Shared Object 
Library"]
     set re1 [join $re1 {\s+}]

     set re_ns [list {\[\[} ($::decimal) {\]\]}]
     set re_ns [join $re_ns ""]
     set re2 [list "$::hex" "$::hex" $re_ns "\[^\r\n]+${lib_regexp}"]
     set re2 [join $re2 {\s+}]
...

But that's a pre-exising style issue, so I suppose it's better to not 
address this in this bug-fix commit.

Thanks,
- Tom

> Co-Authored-By: tdevries@suse.de
> ---
>   gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 20 +++++++++++---------
>   1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> index 03b7a527af5..3ddc07e7773 100644
> --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> @@ -24,7 +24,8 @@ require allow_dlmopen_tests
>   standard_testfile -main.c -lib.c
>   
>   set srcfile_lib $srcfile2
> -set binfile_lib [standard_output_file dlmopen-lib.so]
> +set so_name dlmopen-lib.so
> +set binfile_lib [standard_output_file $so_name]
>   
>   if { [build_executable "build shlib" $binfile_lib $srcfile_lib \
>   	  [list debug shlib]] == -1 } {
> @@ -41,18 +42,19 @@ if { [build_executable "failed to build" $testfile $srcfile \
>   # for the so
>   proc get_first_so_ns {} {
>       set ns -1
> -    gdb_test_multiple "info sharedlibrary" "get SO namespace" -lbl {
> -	-re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" {
> +    set lib_regexp [string_to_regexp ${::binfile_lib}]
> +    gdb_test_multiple "info sharedlibrary $::so_name" "get SO namespace" -lbl {
> +	-re "\r\nFrom\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library(?=\r\n)" {
>   	    exp_continue
>   	}
> -	-re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib.*" {
> -	    set ns $expect_out(1,string)
> -	}
> -	-re "^$::gdb_prompt $" {
> -	}
> -	-re "^\[^\r\n\]+\r\n" {
> +	-re "\r\n$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+${lib_regexp}(?=\r\n)" {
> +	    if {$ns == -1} {
> +		set ns $expect_out(1,string)
> +	    }
>   	    exp_continue
>   	}
> +	-re -wrap "" {
> +	}
>       }
>       return $ns
>   }
> 
> base-commit: d1458933830456e54223d9fc61f0d9b3a19256f5


  reply	other threads:[~2025-04-11 10:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 18:25 [PATCH] " Guinevere Larsen
2025-04-10  4:40 ` Tom de Vries
2025-04-10  8:11   ` Tom de Vries
2025-04-10 12:43     ` Guinevere Larsen
2025-04-10 13:01 ` [PATCH v2] " Guinevere Larsen
2025-04-11 10:26   ` Tom de Vries [this message]
2025-04-11 12:32     ` Guinevere Larsen

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=f2dff8ed-67b1-400a-9901-3fe9c6ae5326@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.com \
    /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