summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stubbs <andrew.stubbs@st.com>2006-04-07 13:31:15 +0000
committerAndrew Stubbs <andrew.stubbs@st.com>2006-04-07 13:31:15 +0000
commit2f9ca6265081d6d207460013bae57f98a2556761 (patch)
tree10bc0e72f28f861b92aa608e156a8a07e05bc445
parentfc66faf75d09028a81005fb76c6a4ad12974df4c (diff)
downloadgdb-2f9ca6265081d6d207460013bae57f98a2556761.tar.gz
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.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/cli/cli-script.c6
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/commands.exp36
4 files changed, 51 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1895257a13a..ab11981d707 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-07 Andrew Stubbs <andrew.stubbs@st.com>
+
+ * 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.
+
2006-04-06 Joel Brobecker <brobecker@adacore.com>
* breakpoint.c (_initialize_breakpoint): Add "del" as an alias
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index b447b4444f1..4f444771520 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -54,6 +54,9 @@ static int control_level;
struct user_args
{
struct user_args *next;
+ /* It is necessary to store a malloced copy of the command line to
+ ensure that the arguments are not overwritten before they are used. */
+ char *command;
struct
{
char *arg;
@@ -483,6 +486,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 +511,8 @@ setup_user_args (char *p)
if (p == NULL)
return old_chain;
+ user_args->command = p = xstrdup (p);
+
while (*p)
{
char *start_arg;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a52e53e44dd..738ee69270f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2006-04-07 Andrew Stubbs <andrew.stubbs@st.com>
+
+ * gdb.base/commands.exp (recursive_source_test): New test.
+
2006-04-04 David S. Miller <davem@sunset.davemloft.net>
* gdb.base/float.exp: Add pattern for sparc targets.
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 893c98c1ba2..e981f81079c 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -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