Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew STUBBS <andrew.stubbs@st.com>
To: Michael Snyder <msnyder@redhat.com>,
	        GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] allow nested sourced commands
Date: Fri, 07 Apr 2006 11:17:00 -0000	[thread overview]
Message-ID: <443649B8.6030909@st.com> (raw)
In-Reply-To: <20060406134012.GA25478@nevyn.them.org>

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

Daniel Jacobowitz wrote:
>> Yes, I have the test case I posted before. Where would be the correct 
>> place to add the test? Just add a new file under gdb.base?
> 
> Yes, please.

On closer inspection it would appear that there are already similar 
tests in commands.exp, so I have added it there.

Here is the entire patch. I have tested the testcase with and without my 
fix - it seems to work correctly.

OK?

Andrew Stubbs

[-- Attachment #2: reentrant-commands.patch --]
[-- Type: text/plain, Size: 2410 bytes --]

2006-04-07  Andrew Stubbs  <andrew.stubbs@st.com>

gdb/
	* cli/cli-script.c (struct user_args): Add command field.
	(arg_cleanup): Free command string.
	(setup_user_args): Copy the command line before relying on it.

gdb/testsuite/
	* gdb.base/commands.exp (recursive_source_test): New test.

Index: src/gdb/cli/cli-script.c
===================================================================
--- src.orig/gdb/cli/cli-script.c	2006-04-07 12:01:55.000000000 +0100
+++ src/gdb/cli/cli-script.c	2006-04-07 12:12:03.000000000 +0100
@@ -54,6 +54,7 @@ static int control_level;
 struct user_args
   {
     struct user_args *next;
+    char *command;
     struct
       {
 	char *arg;
@@ -483,6 +484,7 @@ arg_cleanup (void *ignore)
 		    _("arg_cleanup called with no user args.\n"));
 
   user_args = user_args->next;
+  xfree (oargs->command);
   xfree (oargs);
 }
 
@@ -507,6 +509,8 @@ setup_user_args (char *p)
   if (p == NULL)
     return old_chain;
 
+  user_args->command = p = xstrdup (p);
+
   while (*p)
     {
       char *start_arg;
Index: src/gdb/testsuite/gdb.base/commands.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/commands.exp	2006-04-07 12:11:50.000000000 +0100
+++ src/gdb/testsuite/gdb.base/commands.exp	2006-04-07 12:10:02.000000000 +0100
@@ -583,7 +583,40 @@ proc stray_arg0_test { } {
 	"\\\$\[0-9\]* = 1" \
 	"stray_arg0_test #4"
 }
-  
+
+# Test that GDB can handle arguments when sourcing files recursively.
+# If the arguments are overwritten with ####### then the test has failed.
+proc recursive_source_test {} {
+    set fd [open "file1" w]
+    puts $fd \
+{source file2
+abcdef qwerty}
+    close $fd
+
+    set fd [open "file2" w]
+    puts $fd \
+{define abcdef
+  echo 1: <<<$arg0>>>\n
+  source file3
+  echo 2: <<<$arg0>>>\n
+end}
+    close $fd
+
+    set fd [open "file3" w]
+    puts $fd \
+"echo in file3\\n
+#################################################################"
+    close $fd
+
+    gdb_test "source file1" \
+	"1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
+	"recursive source test"
+
+    file delete file1
+    file delete file2
+    file delete file3
+}
+
 gdbvar_simple_if_test
 gdbvar_simple_while_test
 gdbvar_complex_if_while_test
@@ -600,3 +633,4 @@ deprecated_command_test
 bp_deleted_in_command_test
 temporary_breakpoint_commands
 stray_arg0_test
+recursive_source_test

  reply	other threads:[~2006-04-07 11:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30 14:29 command_line_input() not re-entrant Andrew STUBBS
2006-04-04 10:27 ` [PATCH] allow nested sourced commands Andrew STUBBS
2006-04-04 10:34   ` Andrew STUBBS
2006-04-04 19:58     ` Michael Snyder
2006-04-05 10:05       ` Andrew STUBBS
2006-04-05 18:48         ` Michael Snyder
2006-04-06  9:49           ` Andrew STUBBS
2006-04-06 13:40             ` Daniel Jacobowitz
2006-04-07 11:17               ` Andrew STUBBS [this message]
2006-04-07 13:18                 ` Daniel Jacobowitz
2006-04-07 13:33                   ` Andrew STUBBS

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=443649B8.6030909@st.com \
    --to=andrew.stubbs@st.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@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