Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] -iex and -ix: Execute them _after_ gdbinits
Date: Sat, 16 Jun 2012 19:54:00 -0000	[thread overview]
Message-ID: <20120616195417.GA6368@host2.jankratochvil.net> (raw)

Hi,

[patch 2/2] [+doc] New -iex and -ix: -ex and -x before inferior load
http://sourceware.org/ml/gdb-patches/2012-02/msg00606.html

Before 7.5 gets branched/released I would like to yet change behavior of this
new feature.  The current order is:
 1. -iex and -ix
 2. /etc/gdbinit, ~/.gdbinit
 2. inferior load
 3. -ex and -x etc.

I would like to swap 1 <-> 2:
 1. /etc/gdbinit, ~/.gdbinit
 2. -iex and -ix
 2. inferior load
 3. -ex and -x etc.

In practice I found I need to override 'set auto-load safe-path ...' pre-set
by ~/.gdbinit for specific GDB runs by -iex.  There is no other way to do it.

Contrary to it I cannot imagine why one would want to get -iex commands
overriden by /etc/gdbinit and ~/.gdbinit.

I do not think this change can cause any negative change, only the positive
one.  Moreover the behavior of 7.4.50.* snapshots should not be too binding.

I chose the current FSF GDB HEAD behavior more randomly, if it is "init" then
it should be really the very first thing.  But that was wrong idea I think.

No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.


Thanks,
Jan


gdb/
2012-06-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Execute -ix and -iex only after system and user gdbinit files.
	* main.c (captured_main): Move CMDARG_INIT_FILE and CMDARG_INIT_COMMAND
	processing down after gdbinit files.

gdb/doc/
2012-06-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (File Options): Change -ix and -iex commands that apply
	only after gdbinit files.
	(Startup): Move -iex and -iex commands down after gdbinit files.

diff --git a/gdb/main.c b/gdb/main.c
index 3148d72..025bbe0 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -835,20 +835,6 @@ 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
@@ -864,6 +850,20 @@ captured_main (void *data)
   if (home_gdbinit && !inhibit_gdbinit)
     catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL);
 
+  /* 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;
+    }
+
   /* Now perform all the actions indicated by the arguments.  */
   if (cdarg != NULL)
     {
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a14e322..e0f8469 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -997,16 +997,16 @@ also be interleaved with @samp{-command} as required.
 @itemx -ix @var{file}
 @cindex @code{--init-command}
 @cindex @code{-ix}
-Execute commands from file @var{file} before loading gdbinit files or the
-inferior.
+Execute commands from file @var{file} before loading the inferior (but
+after loading gdbinit files).
 @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.
+Execute a single @value{GDBN} command before loading the inferior (but
+after loading gdbinit files).
 @xref{Startup}.
 
 @item -directory @var{directory}
@@ -1261,14 +1261,6 @@ Here's the description of what @value{GDBN} does during session startup:
 Sets up the command interpreter as specified by the command line
 (@pxref{Mode Options, interpreter}).
 
-@anchor{Option -init-eval-command}
-@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
@@ -1283,6 +1275,14 @@ DOS/Windows systems, the home directory is the one pointed to by the
 @code{HOME} environment variable.} and executes all the commands in
 that file.
 
+@anchor{Option -init-eval-command}
+@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
 Processes command line options and operands.
 


             reply	other threads:[~2012-06-16 19:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-16 19:54 Jan Kratochvil [this message]
2012-06-16 20:05 ` Eli Zaretskii
2012-06-16 20:13   ` Jan Kratochvil
2012-06-16 21:14     ` Eli Zaretskii
2012-06-16 21:32       ` Jan Kratochvil
2012-06-17  2:52         ` Eli Zaretskii
2012-06-17  6:50           ` Jan Kratochvil
2012-06-20 19:01             ` Jan Kratochvil
2012-06-20 19:38               ` Eli Zaretskii
2012-06-22  7:51                 ` Jan Kratochvil
2012-06-22  9:44                   ` Eli Zaretskii
2012-06-22 11:32                     ` Jan Kratochvil
2012-06-22 13:26                       ` Eli Zaretskii
2012-06-22 13:48                         ` Jan Kratochvil
2012-06-22 14:19                         ` Tom Tromey
2012-06-22 14:41                           ` Eli Zaretskii
2012-07-02 12:05                         ` [commit] " Jan Kratochvil
2012-06-22 14:18           ` Tom Tromey
2012-06-19  7:59         ` Doug Evans
2012-06-22 14:17   ` Tom Tromey
2012-06-18 16:45 ` Joel Brobecker
2012-06-22 14:17 ` Tom Tromey
2012-06-22 16:12   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120616195417.GA6368@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox