summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stubbs <andrew.stubbs@st.com>2005-11-07 13:56:48 +0000
committerAndrew Stubbs <andrew.stubbs@st.com>2005-11-07 13:56:48 +0000
commit2c9d222049d51d4c5e8f7b7d94d394b957a99183 (patch)
tree21596a37359d803795221030b067f402c865c429
parent0acb0fc026f688bdfda965b5c9d3d0af04c04a8a (diff)
downloadgdb-2c9d222049d51d4c5e8f7b7d94d394b957a99183.tar.gz
2005-11-07 Andrew Stubbs <andrew.stubbs@st.com>
* main.c (captured_main): Define struct cmdarg. Change type of cmdarg. Add new options --eval-command and alias -ex. Adjust --command to use the new struct cmdarg. Execute commands given with --eval-command. (print_gdb_help): Add new options --eval-command, -ex and mention -x. docs/ * gdb.texinfo (Choosing files): Add --eval-command.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo14
-rw-r--r--gdb/main.c42
4 files changed, 61 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0baf6b55d7a..c5d7d29d551 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2005-11-07 Andrew Stubbs <andrew.stubbs@st.com>
+ * main.c (captured_main): Define struct cmdarg. Change type of cmdarg.
+ Add new options --eval-command and alias -ex.
+ Adjust --command to use the new struct cmdarg.
+ Execute commands given with --eval-command.
+ (print_gdb_help): Add new options --eval-command, -ex and mention -x.
+
+2005-11-07 Andrew Stubbs <andrew.stubbs@st.com>
+
* main.c (main): Use INTERP_TUI instead of "tui".
Set interpreter to INTERP_INSIGHT when '-w' given.
* interps.h (INTERP_INSIGHT): New define.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 9f4234fdb16..7345080d3c5 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-07 Andrew Stubbs <andrew.stubbs@st.com>
+
+ * gdb.texinfo (Choosing files): Add --eval-command.
+
2005-11-04 Andrew Stubbs <andrew.stubbs@st.com>
* gdb.texinfo (Choosing modes): Add --return-child-result.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5402d6a697a..a837d169921 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -932,6 +932,20 @@ file named @var{number}.
Execute @value{GDBN} commands from file @var{file}. @xref{Command
Files,, Command files}.
+@item -eval-command @var{command}
+@itemx -ex @var{command}
+@cindex @code{--eval-command}
+@cindex @code{-ex}
+Execute a single @value{GDBN} command.
+
+This option may be used multiple times to call multiple commands. It may
+also be interleaved with @samp{-command} as required.
+
+@smallexample
+@value{GDBP} -ex 'target sim' -ex 'load' \
+ -x setbreakpoints -ex 'run' a.out
+@end smallexample
+
@item -directory @var{directory}
@itemx -d @var{directory}
@cindex @code{--directory}
diff --git a/gdb/main.c b/gdb/main.c
index 05d1d5fff90..3c9c26894c0 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -138,7 +138,13 @@ captured_main (void *data)
static int print_version;
/* Pointers to all arguments of --command option. */
- char **cmdarg;
+ struct cmdarg {
+ enum {
+ CMDARG_FILE,
+ CMDARG_COMMAND
+ } type;
+ char *string;
+ } *cmdarg;
/* Allocated size of cmdarg. */
int cmdsize;
/* Number of elements of cmdarg used. */
@@ -178,7 +184,7 @@ captured_main (void *data)
#endif
cmdsize = 1;
- cmdarg = (char **) xmalloc (cmdsize * sizeof (*cmdarg));
+ cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg));
ncmd = 0;
dirsize = 1;
dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
@@ -285,8 +291,10 @@ captured_main (void *data)
{"pid", required_argument, 0, 'p'},
{"p", required_argument, 0, 'p'},
{"command", required_argument, 0, 'x'},
+ {"eval-command", required_argument, 0, 'X'},
{"version", no_argument, &print_version, 1},
{"x", required_argument, 0, 'x'},
+ {"ex", required_argument, 0, 'X'},
#ifdef GDBTK
{"tclcommand", required_argument, 0, 'z'},
{"enable-external-editor", no_argument, 0, 'y'},
@@ -387,12 +395,23 @@ captured_main (void *data)
corearg = optarg;
break;
case 'x':
- cmdarg[ncmd++] = optarg;
+ cmdarg[ncmd].type = CMDARG_FILE;
+ cmdarg[ncmd++].string = optarg;
+ if (ncmd >= cmdsize)
+ {
+ cmdsize *= 2;
+ cmdarg = xrealloc ((char *) cmdarg,
+ cmdsize * sizeof (*cmdarg));
+ }
+ break;
+ case 'X':
+ cmdarg[ncmd].type = CMDARG_COMMAND;
+ cmdarg[ncmd++].string = optarg;
if (ncmd >= cmdsize)
{
cmdsize *= 2;
- cmdarg = (char **) xrealloc ((char *) cmdarg,
- cmdsize * sizeof (*cmdarg));
+ cmdarg = xrealloc ((char *) cmdarg,
+ cmdsize * sizeof (*cmdarg));
}
break;
case 'B':
@@ -733,7 +752,12 @@ extern int gdbtk_test (char *);
do_cleanups (ALL_CLEANUPS);
}
#endif
- catch_command_errors (source_command, cmdarg[i], !batch, RETURN_MASK_ALL);
+ if (cmdarg[i].type == CMDARG_FILE)
+ catch_command_errors (source_command, cmdarg[i].string,
+ !batch, RETURN_MASK_ALL);
+ else /* cmdarg[i].type == CMDARG_COMMAND */
+ catch_command_errors (execute_command, cmdarg[i].string,
+ !batch, RETURN_MASK_ALL);
}
xfree (cmdarg);
@@ -846,7 +870,11 @@ Options:\n\n\
--return-child-result\n\
GDB exit code will be the child's exit code.\n\
--cd=DIR Change current directory to DIR.\n\
- --command=FILE Execute GDB commands from FILE.\n\
+ --command=FILE, -x Execute GDB commands from FILE.\n\
+ --eval-command=COMMAND, -ex\n\
+ Execute a single GDB command.\n\
+ May be used multiple times and in conjunction\n\
+ with --command.\n\
--core=COREFILE Analyze the core dump COREFILE.\n\
--pid=PID Attach to running process PID.\n\
"), stream);