Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [RFC][gdb/testsuite] Handle -line and -non-empty-line in gdb_test_multiple
Date: Thu, 20 Feb 2020 13:28:00 -0000	[thread overview]
Message-ID: <883bfb0f-c8e7-ae6c-aa94-2486b3c76362@redhat.com> (raw)
In-Reply-To: <0208e698-e2e1-c13f-486f-caa3f7766d6a@suse.de>

On 2/19/20 9:30 PM, Tom de Vries wrote:
> [ was: Re: [PATCH][gdb/testsuite] Fix corefile-buildid.exp with

> Committed.
> 
>> If this pattern appears in more places it may be worth it to
>> think about some abstraction to make it easier to write.
>> Like e.g., a new "-lbl" (line-by-line) option switch to
>> gdb_test_multiple that auto-appends the "match one line" regexp.
> 
> How about this?

Oh, by "pattern", I meant the design pattern, the higher-level
thing of expecting a string while at the same time consuming
input a line at a time.  Something like:

~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git c/gdb/testsuite/lib/gdb.exp w/gdb/testsuite/lib/gdb.exp
index d8ebddf63ce..6eaebc7710d 100644
--- c/gdb/testsuite/lib/gdb.exp
+++ w/gdb/testsuite/lib/gdb.exp
@@ -858,6 +858,7 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
     set expecting_action 0
     set expecting_arg 0
     set wrap_pattern 0
+    set line_by_line 0
     foreach item $user_code subst_item $subst_code {
        if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } {
            lappend $current_list $item
@@ -880,6 +881,10 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
            set wrap_pattern 1
            continue
        }
+       if {$item == "-lbl"} {
+           set line_by_line 1
+           continue
+       }
        if { $expecting_arg } {
            set expecting_arg 0
            lappend $current_list $subst_item
@@ -1070,6 +1075,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
        }
     }
 
+    if {$line_by_line} {
+       append code {
+           -re "^\[^\r\n\]*\r\n" {
+               exp_continue
+           }
+       }
+    }
+
     # Now patterns that apply to any spawn id specified.
     append code {
        -i $any_spawn_id
~~~~~~~~~~~~~~~~~~~~~~~~~~~

That should mean we could drop the $gdb_prompt matches too.
But maybe a new gdb_test_lbl procedure that wraps gdb_test_multiple
would be preferred.

The way you have it doesn't look very different from
creating a couple globals, like:

 set line_re "^\[^\r\n\]*\r\n"
 set non_empty_line_re "^\[^\r\n\]+\r\n"

and the using them like:

 -re "$line_re" {

Maybe removing the leading "^" anchor from the variables
would make them usable in more places.

Anyway, I don't object to your patch if you like it.  It just
wasn't what I was suggesting.

Thanks,
Pedro Alves


  reply	other threads:[~2020-02-20 13:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 17:40 [PATCH][gdb/testsuite] Fix corefile-buildid.exp with check-read1 Tom de Vries
2020-02-19 20:09 ` Pedro Alves
2020-02-19 21:30   ` [RFC][gdb/testsuite] Handle -line and -non-empty-line in gdb_test_multiple Tom de Vries
2020-02-20 13:28     ` Pedro Alves [this message]
2020-02-21 15:35       ` [RFC][gdb/testsuite] Add -lbl option " Tom de Vries
2020-02-27 16:03         ` Pedro Alves
2020-03-01  9:08           ` Tom de Vries
2020-03-02 13:34             ` Pedro Alves

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=883bfb0f-c8e7-ae6c-aa94-2486b3c76362@redhat.com \
    --to=palves@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