Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Avoid crash when calling warning too early
Date: Thu, 15 Nov 2018 23:25:00 -0000	[thread overview]
Message-ID: <87va4xudmu.fsf@tromey.com> (raw)
In-Reply-To: <5993d96c-afe2-99b1-af8d-56173ea73e08@redhat.com> (Pedro Alves's	message of "Fri, 9 Nov 2018 19:41:36 +0000")

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

[ ... save_vars and... ]
Pedro> I think that the test should instead be replacing/sed'ing
Pedro> the existing -data-directory option, instead of overriding
Pedro> INTERNAL_GDBFLAGS completely.
Pedro> That's what gdb.base/gdbinit-history.exp does.

I didn't address checking the warning output, but here's a patch for the
rest.  Let me know what you think.

Tom

commit 42cbd945dddcc019af24b75aa353fd42d06b17a6
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Nov 15 16:23:25 2018 -0700

    Use save_vars in gdb.base/warning.exp
    
    This changes gdb.base/warning.exp per Pedro's comments: it now uses
    save_vars and it rewrites INTERNAL_GDBFLAGS in place, rather than
    replcing it entirely.
    
    gdb/testsuite/ChangeLog
    2018-11-15  Tom Tromey  <tom@tromey.com>
    
            * gdb.base/warning.exp: Use save_vars.  Rewrite INTERNAL_GDBFLAGS
            rather than replacing it.

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 90faeda261..8ad17ca5c5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-15  Tom Tromey  <tom@tromey.com>
+
+	* gdb.base/warning.exp: Use save_vars.  Rewrite INTERNAL_GDBFLAGS
+	rather than replacing it.
+
 2018-11-12  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* gdb.base/skip.exp: Add standard_testfile.  Add "skip delete"
diff --git a/gdb/testsuite/gdb.base/warning.exp b/gdb/testsuite/gdb.base/warning.exp
index 53067f48d5..975d994e30 100644
--- a/gdb/testsuite/gdb.base/warning.exp
+++ b/gdb/testsuite/gdb.base/warning.exp
@@ -25,12 +25,28 @@ set fd [open $tname w]
 puts $fd "anything"
 close $fd
 
-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"
-
-set INTERNAL_GDBFLAGS $save
+save_vars { INTERNAL_GDBFLAGS } {
+    set last_was_dd 0
+    set new_list {}
+    foreach opt [split $INTERNAL_GDBFLAGS] {
+	if {$last_was_dd} {
+	    # Just drop it.
+	    set last_was_dd 0
+	} elseif {[regexp -- "^--?data-directory\$" $opt]} {
+	    set last_was_dd 1
+	} elseif {[regexp -- "^--?data-directory=" $opt]} {
+	    # Drop but don't drop the next argument.
+	} else {
+	    lappend new_list $opt
+	}
+    }
+    lappend new_list -data-directory
+    lappend new_list $tname
+
+    set INTERNAL_GDBFLAGS [join $new_list]
+
+    gdb_start
+
+    # Make sure gdb started up.
+    gdb_test "echo 23\\n" "23"
+}


      parent reply	other threads:[~2018-11-15 23:25 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
2018-11-18 18:46       ` Tom Tromey
2018-11-19 15:27         ` Pedro Alves
2018-11-15 23:25   ` Tom Tromey [this message]

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=87va4xudmu.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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