* [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
@ 2012-02-25 13:55 Jan Kratochvil
2012-02-25 16:54 ` Eli Zaretskii
2012-03-19 18:20 ` [commit] " Jan Kratochvil
0 siblings, 2 replies; 8+ messages in thread
From: Jan Kratochvil @ 2012-02-25 13:55 UTC (permalink / raw)
To: gdb-patches
Hi,
I also wanted to write this patch for years and for auto-load patch being
prepared it gets handy a lot.
# mv /usr/lib/debug /usr/lib/debug-x
# oops
$ ./gdb -q /usr/bin/gdb gdb.core
Reading symbols from /usr/bin/gdb...(no debugging symbols found)...done.
# naively - not working
$ ./gdb -q -ex 'set debug-file-directory /usr/lib/debug-x' /usr/bin/gdb gdb.core
Reading symbols from /usr/bin/gdb...(no debugging symbols found)...done.
# old way
$ ./gdb -q -ex 'set debug-file-directory /usr/lib/debug-x' -ex 'file /usr/bin/gdb' -ex 'core-file gdb.core'
Reading symbols from /usr/bin/gdb...Reading symbols from /usr/lib/debug-x/usr/bin/gdb.debug...done.done.
->
# new way
$ ./gdb -q -iex 'set debug-file-directory /usr/lib/debug-x' /usr/bin/gdb gdb.core
Reading symbols from /usr/bin/gdb...Reading symbols from /usr/lib/debug-x/usr/bin/gdb.debug...done.done.
I have always difficult time explaining people how to adjust the commandline
to apply 'set debug-file-directory', morevoer if you also load a core file or
attach to an executable.
Another use case is to apply 'set complaints' for the inferior loading.
No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.
Thanks,
Jan
gdb/
2012-02-25 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.
gdb/doc/
2012-02-25 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".
gdb/testsuite/
2012-02-25 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.
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -78,6 +78,13 @@ show breakpoint condition-evaluation
condition evaluation mode. The use of this extension can be controlled
via the "set remote conditional-breakpoints-packet" command.
+* New command line options
+
+--init-command=FILE, -ix Like --init-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
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -989,6 +989,20 @@ 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 gdbinit files or inferior loading.
+@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 gdbinit files or inferior loading.
+@xref{Startup}.
+
@item -directory @var{directory}
@itemx -d @var{directory}
@cindex @code{--directory}
@@ -1234,6 +1248,13 @@ Sets up the command interpreter as specified by the command line
(@pxref{Mode Options, interpreter}).
@item
+Execute 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,
@@ -1267,14 +1288,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
Reads command files specified by the @samp{-x} option. @xref{Command
--- 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'},
@@ -555,6 +567,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;
@@ -807,6 +832,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
@@ -909,6 +948,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)
{
@@ -991,6 +1031,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);
--- 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"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-25 13:55 [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load Jan Kratochvil
@ 2012-02-25 16:54 ` Eli Zaretskii
2012-02-25 17:06 ` Jan Kratochvil
2012-02-28 16:28 ` Doug Evans
2012-03-19 18:20 ` [commit] " Jan Kratochvil
1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2012-02-25 16:54 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
> Date: Sat, 25 Feb 2012 14:49:40 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -78,6 +78,13 @@ show breakpoint condition-evaluation
> condition evaluation mode. The use of this extension can be controlled
> via the "set remote conditional-breakpoints-packet" command.
>
> +* New command line options
> +
> +--init-command=FILE, -ix Like --init-command, -x but execute it
^^^^^^^^^^^^^^
You meant "--command", I believe.
> + before loading inferior.
> +--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but
> + execute it before loading inferior.
Is it really a good idea to have 2- or 3-letter short options? It
started with -nw and -nx, which might make sense, then we added -ex,
and now -ix and -iex? If noting else, this will prevent us from ever
having -e and -i.
How about if we don't have short versions of these at all?
> +@cindex @code{-ix}
> +Execute commands from file @var{file} before gdbinit files or inferior loading.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"before loading gdbinit files or the inferior" is better.
> +@cindex @code{-iex}
> +Execute a single @value{GDBN} command before gdbinit files or inferior loading.
Likewise.
> +Execute 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
^
A comma is missing before "but".
OK with those changes.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-25 16:54 ` Eli Zaretskii
@ 2012-02-25 17:06 ` Jan Kratochvil
2012-02-28 16:34 ` Doug Evans
2012-02-28 16:28 ` Doug Evans
1 sibling, 1 reply; 8+ messages in thread
From: Jan Kratochvil @ 2012-02-25 17:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Sat, 25 Feb 2012 16:59:43 +0100, Eli Zaretskii wrote:
> > +--init-command=FILE, -ix Like --init-command, -x but execute it
> > + before loading inferior.
> > +--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but
> > + execute it before loading inferior.
>
> Is it really a good idea to have 2- or 3-letter short options? It
> started with -nw and -nx, which might make sense, then we added -ex,
> and now -ix and -iex? If noting else, this will prevent us from ever
> having -e and -i.
>
> How about if we don't have short versions of these at all?
Originally I had -initx and -initex, if it would be OK for you.
These options are just for convenience, which contradicts me the long options
--init-eval-command. Still even --init-eval-command is better than nothing.
> OK with those changes.
I will change those.
Thanks,
Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-25 16:54 ` Eli Zaretskii
2012-02-25 17:06 ` Jan Kratochvil
@ 2012-02-28 16:28 ` Doug Evans
1 sibling, 0 replies; 8+ messages in thread
From: Doug Evans @ 2012-02-28 16:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Jan Kratochvil, gdb-patches
On Sat, Feb 25, 2012 at 7:59 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sat, 25 Feb 2012 14:49:40 +0100
>> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>>
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -78,6 +78,13 @@ show breakpoint condition-evaluation
>> condition evaluation mode. The use of this extension can be controlled
>> via the "set remote conditional-breakpoints-packet" command.
>>
>> +* New command line options
>> +
>> +--init-command=FILE, -ix Like --init-command, -x but execute it
> ^^^^^^^^^^^^^^
> You meant "--command", I believe.
>
>> + before loading inferior.
>> +--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but
>> + execute it before loading inferior.
>
> Is it really a good idea to have 2- or 3-letter short options? It
> started with -nw and -nx, which might make sense, then we added -ex,
> and now -ix and -iex? If noting else, this will prevent us from ever
> having -e and -i.
I don't understand.
We already have gdb -i=mi2 (for example).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-25 17:06 ` Jan Kratochvil
@ 2012-02-28 16:34 ` Doug Evans
2012-03-16 20:39 ` ping: " Jan Kratochvil
0 siblings, 1 reply; 8+ messages in thread
From: Doug Evans @ 2012-02-28 16:34 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Eli Zaretskii, gdb-patches
On Sat, Feb 25, 2012 at 8:53 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Originally I had -initx and -initex, if it would be OK for you.
I like -ix, -iex. [If we're going to have short versions, let's not
wimp out with something quasi-short.]
^ permalink raw reply [flat|nested] 8+ messages in thread
* ping: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-28 16:34 ` Doug Evans
@ 2012-03-16 20:39 ` Jan Kratochvil
2012-03-16 20:51 ` Tom Tromey
0 siblings, 1 reply; 8+ messages in thread
From: Jan Kratochvil @ 2012-03-16 20:39 UTC (permalink / raw)
To: gdb-patches; +Cc: Eli Zaretskii, Doug Evans
On Tue, 28 Feb 2012 17:27:46 +0100, Doug Evans wrote:
> On Sat, Feb 25, 2012 at 8:53 AM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
> > Originally I had -initx and -initex, if it would be OK for you.
>
> I like -ix, -iex. [If we're going to have short versions, let's not
> wimp out with something quasi-short.]
Going to check it in after a few days unless there are more comments.
I hope it is considered generally useful not only by me.
Thanks,
Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ping: [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-03-16 20:39 ` ping: " Jan Kratochvil
@ 2012-03-16 20:51 ` Tom Tromey
0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2012-03-16 20:51 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Eli Zaretskii, Doug Evans
Jan> Going to check it in after a few days unless there are more comments.
Jan> I hope it is considered generally useful not only by me.
Yes.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* [commit] [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
2012-02-25 13:55 [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load Jan Kratochvil
2012-02-25 16:54 ` Eli Zaretskii
@ 2012-03-19 18:20 ` Jan Kratochvil
1 sibling, 0 replies; 8+ messages in thread
From: Jan Kratochvil @ 2012-03-19 18:20 UTC (permalink / raw)
To: gdb-patches
On Sat, 25 Feb 2012 14:49:40 +0100, Jan Kratochvil wrote:
> gdb/
> 2012-02-25 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.
>
> gdb/doc/
> 2012-02-25 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".
>
> gdb/testsuite/
> 2012-02-25 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.
Checked in:
http://sourceware.org/ml/gdb-cvs/2012-03/msg00235.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-03-19 18:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-25 13:55 [patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load Jan Kratochvil
2012-02-25 16:54 ` Eli Zaretskii
2012-02-25 17:06 ` Jan Kratochvil
2012-02-28 16:34 ` Doug Evans
2012-03-16 20:39 ` ping: " Jan Kratochvil
2012-03-16 20:51 ` Tom Tromey
2012-02-28 16:28 ` Doug Evans
2012-03-19 18:20 ` [commit] " Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox