Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test
Date: Thu, 10 Apr 2025 09:43:17 -0300	[thread overview]
Message-ID: <2959e0a5-c97d-4335-92cc-2d5157d44b3c@redhat.com> (raw)
In-Reply-To: <27d87d8d-2bf9-45db-87b3-6e2d5a843eb9@suse.de>

On 4/10/25 5:11 AM, Tom de Vries wrote:
> On 4/10/25 06:40, Tom de Vries wrote:
>> On 4/9/25 20:25, Guinevere Larsen wrote:
>>> * using exp_continue caused the value of ns to be overwritten, 
>>> returning
>>>    the last SO_NS, instead of the first
>>
>> Hi Gwen,
>>
>> my guess is that this is the right solution, and that you can just 
>> check for $ns == -1 to make sure only the first value is picked.
>
> I tried this out, and got it working, after fixing the following.
>
> There is a problem with the gdb_test_multiple.
>
> It uses -lbl, which is the style of processing one line at a time, 
> with \r\n at the start, and (?=\r\n) at the end, which matches but not 
> consumes it (lookahead), always leaving an \r\n at the start of the 
> next line.
>
> This matches what -wrap (which is based on gdb_test) does which 
> requires an \r\n before the prompt.
>
> I got the test-case working using:
> ...
> diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp 
> b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> index 03b7a527af5..d3584a0a402 100644
> --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
> @@ -42,17 +42,17 @@ if { [build_executable "failed to build" $testfile 
> $srcfile \
>  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" {
> +    -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]+${::binfile_lib}(?=\r\n
> )" {
> +        if { $ns == -1 } {
> +        set ns $expect_out(1,string)
> +        }
>          exp_continue
>      }
> +    -re -wrap "" {
> +    }
>      }
>      return $ns
>  }
> ...
>
Ah, ok. I guess there's quite a bit I still need to learn about -lbl.

I was thinking that this could be quite a bit slower, but I noticed that 
this also fixes issues with using the lib name in the "info 
sharedlibrary" command, so I'll add this to a v2

> I also think that binfile_lib needs to be wrapped in string_to_regexp.
Will also do this for v2.

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>
> Thanks,
> - Tom
>


  reply	other threads:[~2025-04-10 12:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 18:25 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 [this message]
2025-04-10 13:01 ` [PATCH v2] " Guinevere Larsen
2025-04-11 10:26   ` Tom de Vries
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=2959e0a5-c97d-4335-92cc-2d5157d44b3c@redhat.com \
    --to=guinevere@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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