]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/
authorDaniel Jacobowitz <drow@false.org>
Thu, 30 Mar 2006 16:51:20 +0000 (16:51 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 30 Mar 2006 16:51:20 +0000 (16:51 +0000)
* cli/cli-script.c (insert_args): Handle NULL user_args.
gdb/testsuite/
* gdb.base/commands.exp (stray_arg0_test): New test.

gdb/ChangeLog
gdb/cli/cli-script.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/commands.exp

index 8253c23e9fc81f84902e0a7d81b4e7f642c6ebac..45a83e0e56dd9e464bde9ea062b338b3c9e88c61 100644 (file)
@@ -1,3 +1,7 @@
+2006-03-30  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * cli/cli-script.c (insert_args): Handle NULL user_args.
+
 2006-03-30  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * arm-tdep.c (thumb_scan_prologue): Don't try to analyze
index b8e9d4f03f42998340dc5e250e52d483e655338b..b447b4444f19ccaf91f20a861245dba6df3ed680 100644 (file)
@@ -593,6 +593,11 @@ insert_args (char *line)
   char *p, *save_line, *new_line;
   unsigned len, i;
 
+  /* If we are not in a user-defined function, treat $argc, $arg0, et
+     cetera as normal convenience variables.  */
+  if (user_args == NULL)
+    return xstrdup (line);
+
   /* First we need to know how much memory to allocate for the new line.  */
   save_line = line;
   len = 0;
index 83471893b844377b3268d8574d702a6a9a8fa926..1b4a79426d71a14c4b10d22e97748f034de429c8 100644 (file)
@@ -1,3 +1,7 @@
+2006-03-30  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb.base/commands.exp (stray_arg0_test): New test.
+
 2006-03-30  Paul Brook  <paul@codesourcery.com>
 
        * gdb.mi/mi-until.exp: kfail broken until command.
index eabf85e442bbb2fa88760b0f0dc7535a97f2ca42..893c98c1ba2ee970af274bbc22bf4d8d2305aa42 100644 (file)
@@ -1,5 +1,5 @@
 #   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1997, 1998, 1999, 2000,
-#   2001, 2002, 2003 Free Software Foundation, Inc.
+#   2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -563,6 +563,26 @@ proc temporary_breakpoint_commands {} {
        timeout { fail "(timeout) run factorial until temporary breakpoint" }
     }
 }
+
+# Test that GDB can handle $arg0 outside of user functions without
+# crashing.
+proc stray_arg0_test { } {
+    gdb_test "print \$arg0" \
+       "\\\$\[0-9\]* = void" \
+       "stray_arg0_test #1"
+
+    gdb_test "if 1 == 1\nprint \$arg0\nend" \
+       "\\\$\[0-9\]* = void" \
+       "stray_arg0_test #2"
+
+    gdb_test "print \$arg0 = 1" \
+       "\\\$\[0-9\]* = 1" \
+       "stray_arg0_test #3"
+
+    gdb_test "print \$arg0" \
+       "\\\$\[0-9\]* = 1" \
+       "stray_arg0_test #4"
+}
   
 gdbvar_simple_if_test
 gdbvar_simple_while_test
@@ -579,3 +599,4 @@ test_command_prompt_position
 deprecated_command_test
 bp_deleted_in_command_test
 temporary_breakpoint_commands
+stray_arg0_test