Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Avoid crash when calling warning too early
Date: Fri, 16 Nov 2018 13:31:00 -0000	[thread overview]
Message-ID: <37033fcd-ce27-ecc9-3bb6-7ac7d062fdd8@redhat.com> (raw)
In-Reply-To: <87zhuasziq.fsf@tromey.com>

On 11/15/2018 11:15 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> On 10/31/2018 06:18 PM, Tom Tromey wrote:
>>> +set save $INTERNAL_GDBFLAGS
>>> +set INTERNAL_GDBFLAGS "-nw -nx -data-directory $tname"
>>> +
>>> +gdb_start
>>> +
>>> +# Make sure gdb started up.
>>> +gdb_test "echo 23\\n" "23"
> 
> Pedro> I guess this could also check that the warning was emitted?
> 
> I didn't know how to do that.
> Modify gdb_start maybe?
Hmm, by using gdb_spawn directly, or better, gdb_spawn_with_cmdline_opts
instead of gdb_start?

See patch below; it works here.

Also, looking further into the INTERNAL_GDBFLAGS issue,
it turns out we don't really need to frob INTERNAL_GDBFLAGS.
Each passed -data-directory option leads to a call to the warning:

 $ ./gdb -data-directory=foo -data-directory=bar
 Warning: foo: No such file or directory.
 Warning: bar: No such file or directory.
 [...]

(And if it didn't, I'd think we'd just have to make sure to put
our -data-directory last, leaving the original one in place.
I.e., just passing it in gdb_spawn_with_cmdline_opts should work
even in that case.)

So, WDYT of this version?

From 7f3e6bf1b75e049c0abbab2a9cbf3d6e28f855ac Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 16 Nov 2018 13:13:56 +0000
Subject: [PATCH] warning

---
 gdb/testsuite/gdb.base/warning.exp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.base/warning.exp b/gdb/testsuite/gdb.base/warning.exp
index 53067f48d5..134218acb9 100644
--- a/gdb/testsuite/gdb.base/warning.exp
+++ b/gdb/testsuite/gdb.base/warning.exp
@@ -25,12 +25,12 @@ set fd [open $tname w]
 puts $fd "anything"
 close $fd
 
-set save $INTERNAL_GDBFLAGS
-set INTERNAL_GDBFLAGS "-nw -nx -data-directory $tname"
+gdb_spawn_with_cmdline_opts \
+    "-iex \"set pagination off\" -data-directory $tname"
 
-gdb_start
+# Make sure we see the warning.
+gdb_test "" "warning: $tname is not a directory.*" \
+    "got warning"
 
 # Make sure gdb started up.
 gdb_test "echo 23\\n" "23"
-
-set INTERNAL_GDBFLAGS $save
-- 
2.14.4


  reply	other threads:[~2018-11-16 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 18:18 Tom Tromey
2018-10-31 18:44 ` Sergio Durigan Junior
2018-10-31 20:27   ` Tom Tromey
2018-10-31 20:37     ` Sergio Durigan Junior
2018-11-08 23:10       ` Tom Tromey
2018-11-09 19:41 ` Pedro Alves
2018-11-15 23:22   ` Tom Tromey
2018-11-16 13:31     ` Pedro Alves [this message]
2018-11-18 18:46       ` Tom Tromey
2018-11-19 15:27         ` Pedro Alves
2018-11-15 23:25   ` 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=37033fcd-ce27-ecc9-3bb6-7ac7d062fdd8@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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