aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-03-19 18:19:26 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-03-19 18:19:26 +0000
commit8320cc4fa3784dc5296745898de5357559f8125a (patch)
tree0e1f2bded27be2397ac4a559118b7e25b34a1352 /gdb
parent26743505e35f0442b8db1848140d2e3d475fa736 (diff)
downloadgdb-8320cc4fa3784dc5296745898de5357559f8125a.zip
gdb-8320cc4fa3784dc5296745898de5357559f8125a.tar.gz
gdb-8320cc4fa3784dc5296745898de5357559f8125a.tar.bz2
gdb/
* NEWS: Describe new options --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and CMDARG_INIT_COMMAND. (captured_main): New enum items OPT_IX and OPT_IEX. Add "init-command", "init-eval-command", "ix" and "iex" to the variable long_options. Handle OPT_IX and OPT_IEX. Process them from CMDARG_VEC. New comment for CMDARG_FILE and CMDARG_COMMAND processing. (print_gdb_help): Describe --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. gdb/doc/ * gdb.texinfo (File Options): Describe --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. (Startup): Describe -iex and -ix. Simplify the example for "set auto-load-scripts off". gdb/testsuite/ * gdb.gdb/selftest.exp (do_steps_and_nexts): New entry for cmdarg_vec = NULL. Remove entries for cmdsize = 1, cmdarg = and ncmd = 0. New entry for VEC_cleanup cmdarg_s.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/NEWS7
-rw-r--r--gdb/doc/ChangeLog7
-rw-r--r--gdb/doc/gdb.texinfo32
-rw-r--r--gdb/main.c46
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.gdb/selftest.exp20
7 files changed, 111 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 31ecb29..d9b07b0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
2012-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * NEWS: Describe new options --init-command=FILE, -ix and
+ --init-eval-command=COMMAND, -iex.
+ * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and
+ CMDARG_INIT_COMMAND.
+ (captured_main): New enum items OPT_IX and OPT_IEX. Add
+ "init-command", "init-eval-command", "ix" and "iex" to the variable
+ long_options. Handle OPT_IX and OPT_IEX. Process them from CMDARG_VEC.
+ New comment for CMDARG_FILE and CMDARG_COMMAND processing.
+ (print_gdb_help): Describe --init-command=FILE, -ix and
+ --init-eval-command=COMMAND, -iex.
+
+2012-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
+
Code cleanup.
* main.c (struct cmdarg): Move it here from main. Add more comments.
(cmdarg_s, VEC (cmdarg_s)): New.
diff --git a/gdb/NEWS b/gdb/NEWS
index e6bf59c..d23a773 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -118,6 +118,13 @@ QProgramSignals:
Specify the signals which the remote stub may pass to the debugged
program without GDB involvement.
+* New command line options
+
+--init-command=FILE, -ix Like --command, -x but execute it
+ before loading inferior.
+--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but
+ execute it before loading inferior.
+
*** Changes in GDB 7.4
* GDB now handles ambiguous linespecs more consistently; the existing
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index cb6d0e9..92e3e1b 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (File Options): Describe --init-command=FILE, -ix and
+ --init-eval-command=COMMAND, -iex.
+ (Startup): Describe -iex and -ix. Simplify the example
+ for "set auto-load-scripts off".
+
2012-03-16 Gary Benson <gbenson@redhat.com>
PR breakpoints/10738
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 56bf5d5..677af3b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -990,6 +990,22 @@ also be interleaved with @samp{-command} as required.
-x setbreakpoints -ex 'run' a.out
@end smallexample
+@item -init-command @var{file}
+@itemx -ix @var{file}
+@cindex @code{--init-command}
+@cindex @code{-ix}
+Execute commands from file @var{file} before loading gdbinit files or the
+inferior.
+@xref{Startup}.
+
+@item -init-eval-command @var{command}
+@itemx -iex @var{command}
+@cindex @code{--init-eval-command}
+@cindex @code{-iex}
+Execute a single @value{GDBN} command before loading gdbinit files or the
+inferior.
+@xref{Startup}.
+
@item -directory @var{directory}
@itemx -d @var{directory}
@cindex @code{--directory}
@@ -1242,6 +1258,13 @@ Sets up the command interpreter as specified by the command line
(@pxref{Mode Options, interpreter}).
@item
+Executes commands and command files specified by the @samp{-iex} and
+@samp{-ix} options in their specified order. Usually you should use the
+@samp{-ex} and @samp{-x} options instead, but this way you can apply
+settings before @value{GDBN} init files get executed and before inferior
+gets loaded.
+
+@item
@cindex init file
Reads the system-wide @dfn{init file} (if @option{--with-system-gdbinit} was
used when building @value{GDBN}; @pxref{System-wide configuration,
@@ -1275,14 +1298,11 @@ If you wish to disable the auto-loading during startup,
you must do something like the following:
@smallexample
-$ gdb -ex "set auto-load-scripts off" -ex "file myprogram"
+$ gdb -iex "set auto-load-scripts off" myprogram
@end smallexample
-The following does not work because the auto-loading is turned off too late:
-
-@smallexample
-$ gdb -ex "set auto-load-scripts off" myprogram
-@end smallexample
+Option @samp{-ex} does not work because the auto-loading is then turned
+off too late.
@item
Executes commands and command files specified by the @samp{-ex} and
diff --git a/gdb/main.c b/gdb/main.c
index f564fec..e528cd1 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -247,7 +247,13 @@ typedef struct cmdarg {
CMDARG_FILE,
/* Option type -ex. */
- CMDARG_COMMAND
+ CMDARG_COMMAND,
+
+ /* Option type -ix. */
+ CMDARG_INIT_FILE,
+
+ /* Option type -iex. */
+ CMDARG_INIT_COMMAND
} type;
/* Value of this option - filename or the GDB command itself. String memory
@@ -394,7 +400,9 @@ captured_main (void *data)
OPT_STATISTICS,
OPT_TUI,
OPT_NOWINDOWS,
- OPT_WINDOWS
+ OPT_WINDOWS,
+ OPT_IX,
+ OPT_IEX
};
static struct option long_options[] =
{
@@ -434,6 +442,10 @@ captured_main (void *data)
{"version", no_argument, &print_version, 1},
{"x", required_argument, 0, 'x'},
{"ex", required_argument, 0, 'X'},
+ {"init-command", required_argument, 0, OPT_IX},
+ {"init-eval-command", required_argument, 0, OPT_IEX},
+ {"ix", required_argument, 0, OPT_IX},
+ {"iex", required_argument, 0, OPT_IEX},
#ifdef GDBTK
{"tclcommand", required_argument, 0, 'z'},
{"enable-external-editor", no_argument, 0, 'y'},
@@ -557,6 +569,19 @@ captured_main (void *data)
VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
}
break;
+ case OPT_IX:
+ {
+ struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg };
+
+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
+ }
+ break;
+ case OPT_IEX:
+ {
+ struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg };
+
+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
+ }
break;
case 'B':
batch_flag = batch_silent = 1;
@@ -809,6 +834,20 @@ captured_main (void *data)
quit_pre_print = error_pre_print;
warning_pre_print = _("\nwarning: ");
+ /* Process '-ix' and '-iex' options early. */
+ for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++)
+ switch (cmdarg_p->type)
+ {
+ case CMDARG_INIT_FILE:
+ catch_command_errors (source_script, cmdarg_p->string,
+ !batch_flag, RETURN_MASK_ALL);
+ break;
+ case CMDARG_INIT_COMMAND:
+ catch_command_errors (execute_command, cmdarg_p->string,
+ !batch_flag, RETURN_MASK_ALL);
+ break;
+ }
+
/* Read and execute the system-wide gdbinit file, if it exists.
This is done *before* all the command line arguments are
processed; it sets global parameters, which are independent of
@@ -911,6 +950,7 @@ captured_main (void *data)
ALL_OBJFILES (objfile)
load_auto_scripts_for_objfile (objfile);
+ /* Process '-x' and '-ex' options. */
for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++)
switch (cmdarg_p->type)
{
@@ -993,6 +1033,8 @@ Options:\n\n\
Execute a single GDB command.\n\
May be used multiple times and in conjunction\n\
with --command.\n\
+ --init-command=FILE, -ix Like -x but execute it before loading inferior.\n\
+ --init-eval-command=COMMAND, -iex Like -ex but before loading inferior.\n\
--core=COREFILE Analyze the core dump COREFILE.\n\
--pid=PID Attach to running process PID.\n\
"), stream);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f2ea686..2a8bf9d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.gdb/selftest.exp (do_steps_and_nexts): New entry
+ for cmdarg_vec = NULL. Remove entries for cmdsize = 1, cmdarg = and
+ ncmd = 0. New entry for VEC_cleanup cmdarg_s.
+
2012-03-19 Siddhesh Poyarekar <siddhesh@redhat.com>
* gdb.base/cond-eval-mode.exp: Fix the anticipated warning string.
diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index 1ffa945..7645caf 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -88,6 +88,10 @@ proc do_steps_and_nexts {} {
set description "step over ttyarg initialization"
set command "step"
}
+ -re ".*cmdarg_vec = NULL.*$gdb_prompt $" {
+ set description "step over cmdarg_vec initialization"
+ set command "step"
+ }
-re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" {
set description "next over make_command_stats_cleanup and everything it calls"
set command "next"
@@ -124,18 +128,6 @@ proc do_steps_and_nexts {} {
set description "next over conditional stack alignment alloca"
set command "next"
}
- -re ".*cmdsize = 1.*$gdb_prompt $" {
- set description "step over cmdsize initialization"
- set command "next"
- }
- -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" {
- set description "next over cmdarg initialization via xmalloc"
- set command "next"
- }
- -re ".*ncmd = 0.*$gdb_prompt $" {
- set description "next over ncmd initialization"
- set command "next"
- }
-re ".*dirsize = 1.*$gdb_prompt $" {
set description "next over dirsize initialization"
set command "next"
@@ -159,6 +151,10 @@ proc do_steps_and_nexts {} {
set description "next over textdomain PACKAGE"
set command "next"
}
+ -re ".*VEC_cleanup .cmdarg_s.*$gdb_prompt $" {
+ set description "next over cmdarg_s VEC_cleanup"
+ set command "next"
+ }
-re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" {
set description "step over initial brace"
set command "step"