public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Bruno Larsen <blarsen@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 5/5] Make gdb_test's question non-optional if specified
Date: Fri, 8 Apr 2022 13:18:31 +0100	[thread overview]
Message-ID: <b8e31549-79a4-6c0e-3eb2-0dc427326e3e@palves.net> (raw)
In-Reply-To: <b1c717fa-c032-2845-cdd0-4b30517e45aa@redhat.com>

On 2022-04-07 21:31, Bruno Larsen wrote:
> On 3/30/22 16:29, Pedro Alves wrote:
>> gdb_test supports handling scenarios where GDB asks a question before
>> finishing handling some command.  The full prototype of gdb_test is:
>>
>>    # gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE
>>
>> However, QUESTION is a question that GDB _may_ ask, not one that GDB
>> _must_ ask:
>>
>>   # QUESTION is a question GDB may ask in response to COMMAND, like
>>   #   "are you sure?"
>>   # RESPONSE is the response to send if QUESTION appears.
>>
>> If GDB doesn't raise the question, the test still passes.
>>
>> I think that this is a misfeature.  If GDB regresses and stops asking
>> a question, the testsuite won't notice.  So I think that if a QUESTION
>> is specified, gdb_test should ensure it comes out of GDB.
> 
> I just ran into a neat use of this, or possibly a mis-use, depending on how much you like it. gdb.base/skip.exp uses:
> 
> gdb_test "step" "desired spot" "go to desired spot" "undesirable spot" "step"
> 
> as a simple way to handle a gcc 9.2.0 bug (misfeature) where gdb could stop in an undesirable spot without actually causing a failure in the test. This feels like a neat way to deal with compiler problems, as it would introduce a simple way to deal with clang's lack of epilogue, for instance.

This is:

    # With gcc 9.2.0 we jump once back to main before entering foo here.
    # If that happens try to step a second time.
    gdb_test "step" "foo \\(\\) at.*" "step 3" \
	"main \\(\\) at .*\r\n$gdb_prompt " "step"

I think this is a misuse.  That case doesn't really handle a GDB confirmation question.
What if you need to issue more steps, or the program may stop elsewhere for
different ports, and thus you need more than one regexp?  For the latter you can
use (REGEX1|REGEX1), but it isn't as nice as separate -re entries, IMHO.

IMHO, writing it with gdb_test_multiple in these cases is OK:

gdb_test_multiple "step" "step 3" {
  -re -wrap "foo \\(\\) at.*" {
     pass $gdb_test_multiple
  }
  -re -wrap "main \\(\\) at .*" {
    # With gcc 9.2.0 we jump once back to main before entering foo.
    # If that happens try another step.
    send_gdb "step\n"
    exp_continue
  }
}

It's a standard pattern we use in many places, I don't think it's bad enough that we need
to hide it.

> 
> I'm not suggesting that this patch be scrapped, but maybe this could be implemented on purpose, something like gdb_test_optional. The code itself LGTM, but I am not able to approve patches.
> 


  reply	other threads:[~2022-04-08 12:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 19:29 [PATCH 0/5] " Pedro Alves
2022-03-30 19:29 ` [PATCH 1/5] Remove gdb_test questions that GDB doesn't ask Pedro Alves
2022-03-30 19:29 ` [PATCH 2/5] gdb.base/scope.exp: Remove bogus gdb_test questions Pedro Alves
2022-03-30 19:29 ` [PATCH 3/5] Fix bogus gdb_test invocations Pedro Alves
2022-03-30 19:29 ` [PATCH 4/5] Avoid having to unload file in gdb.server/connect-with-no-symbol-file.exp Pedro Alves
2022-03-30 19:29 ` [PATCH 5/5] Make gdb_test's question non-optional if specified Pedro Alves
2022-04-07 20:31   ` Bruno Larsen
2022-04-08 12:18     ` Pedro Alves [this message]
2022-05-17 10:13       ` [PATCH 5/6] gdb.base/skip.exp: Don't abuse gdb_test's question support (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-16 16:01   ` [PATCH 5/5] Make gdb_test's question non-optional if specified Tom Tromey
2022-05-17 11:25     ` Pedro Alves
2022-05-17 22:48       ` Tom Tromey
2022-05-18 11:01         ` [pushed] Support -prompt and -lbl in gdb_test (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-18 12:15           ` Tom de Vries
2022-05-18 12:36             ` Pedro Alves
2022-05-18 14:13               ` Pedro Alves
2022-05-18 14:49                 ` Tom de Vries
2022-05-18 20:34                 ` Tom Tromey
2022-05-19 12:42                   ` Pedro Alves
2022-05-23 10:48           ` Tom de Vries
2022-05-23 12:01             ` Tom de Vries
2022-05-23 12:50               ` [committed][gdb/testsuite] Fix -prompt handling in gdb_test Tom de Vries
2022-05-23 12:53               ` [pushed] Support -prompt and -lbl in gdb_test (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-17 11:41   ` [PATCH 5/5] Make gdb_test's question non-optional if specified Simon Marchi
2022-05-17 12:04     ` Pedro Alves
2022-05-16 16:02 ` [PATCH 0/5] " Tom Tromey

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=b8e31549-79a4-6c0e-3eb2-0dc427326e3e@palves.net \
    --to=pedro@palves.net \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.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).