New option -nh: inhibit loading of ~/.gdbinit.
authorDoug Evans <dje@google.com>
Mon, 15 Oct 2012 21:45:04 +0000 (21:45 +0000)
committerDoug Evans <dje@google.com>
Mon, 15 Oct 2012 21:45:04 +0000 (21:45 +0000)
* NEWS: Mention -nh.
* main.c (captured_main): Recognize and process -nh.
(print_gdb_help): Mention -nh.
* gdb.1: Mention -nh.  Remove erroneous docs on -nx behavior.

doc/
* gdb.texinfo (Mode Options): Document -nh.
Elaborate on docs for -nx.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/gdb.1
gdb/main.c

index a2c457e..8e5c37c 100644 (file)
@@ -1,3 +1,11 @@
+2012-10-15  Doug Evans  <dje@google.com>
+
+       New option -nh: inhibit loading of ~/.gdbinit.
+       * NEWS: Mention -nh.
+       * main.c (captured_main): Recognize and process -nh.
+       (print_gdb_help): Mention -nh.
+       * gdb.1: Mention -nh.  Remove erroneous docs on -nx behavior.
+
 2012-10-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR backtrace/14646
index abd0932..81d5f76 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.5
 
+* New command line options:
+
+-nh   Disables auto-loading of ~/.gdbinit, but still executes all the
+      other initialization files, unlike -nx which disables all of them.
+
 * Python scripting
 
   ** Vectors can be created with gdb.Type.vector.
index 05ac406..c33445a 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-15  Doug Evans  <dje@google.com>
+
+       * gdb.texinfo (Mode Options): Document -nh.
+       Elaborate on docs for -nx.
+
 2012-09-26  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * observer.texi (memory_changed): Expand parameter LEN to ssize_t.
index 5fcbada..aed2556 100644 (file)
@@ -1043,10 +1043,37 @@ batch mode or quiet mode.
 @itemx -n
 @cindex @code{--nx}
 @cindex @code{-n}
-Do not execute commands found in any initialization files.  Normally,
-@value{GDBN} executes the commands in these files after all the command
-options and arguments have been processed.  @xref{Command Files,,Command
-Files}.
+Do not execute commands found in any initialization file.
+There are three init files, loaded in the following order:
+
+@table @code
+@item @file{system.gdbinit}
+This is the system-wide init file.
+Its location is specified with the @code{--with-system-gdbinit}
+configure option (@pxref{System-wide configuration}).
+It is loaded first when @value{GDBN} starts, before command line options
+have been processed.
+@item @file{~/.gdbinit}
+This is the init file in your home directory.
+It is loaded next, after @file{system.gdbinit}, and before
+command options have been processed.
+@item @file{./.gdbinit}
+This is the init file in the current directory.
+It is loaded last, after command line options other than @code{-x} and
+@code{-ex} have been processed.  Command line options @code{-x} and
+@code{-ex} are processed last, after @file{./.gdbinit} has been loaded.
+@end table
+
+For further documentation on startup processing, @xref{Startup}.
+For documentation on how to write command files,
+@xref{Command Files,,Command Files}.
+
+@anchor{-nh}
+@item -nh
+@cindex @code{--nh}
+Do not execute commands found in @file{~/.gdbinit}, the init file
+in your home directory.
+@xref{Startup}.
 
 @item -quiet
 @itemx -silent
index 7a54f85..68a5e42 100644 (file)
--- a/gdb/gdb.1
+++ b/gdb/gdb.1
@@ -9,6 +9,7 @@ gdb \- The GNU Debugger
 .TP
 .B gdb
 .RB "[\|" \-help "\|]"
+.RB "[\|" \-nh "\|]"
 .RB "[\|" \-nx "\|]"
 .RB "[\|" \-q "\|]"
 .RB "[\|" \-batch "\|]"
@@ -283,14 +284,16 @@ Add \c
 .PP
 
 .TP
+.B \-nh
+Do not execute commands from ~/.gdbinit.
+
+.TP
 .B \-nx
 .TP
 .B \-n
 Do not execute commands from any `\|\c
 .B .gdbinit\c
 \&\|' initialization files.
-Normally, the commands in these files are executed after all the
-command options and arguments have been processed.
 
 
 .TP
index 155b609..923a7fe 100644 (file)
@@ -273,6 +273,7 @@ captured_main (void *data)
   char **argv = context->argv;
   static int quiet = 0;
   static int set_args = 0;
+  static int inhibit_home_gdbinit = 0;
 
   /* Pointers to various arguments from command line.  */
   char *symarg = NULL;
@@ -415,6 +416,7 @@ captured_main (void *data)
       {"quiet", no_argument, &quiet, 1},
       {"q", no_argument, &quiet, 1},
       {"silent", no_argument, &quiet, 1},
+      {"nh", no_argument, &inhibit_home_gdbinit, 1},
       {"nx", no_argument, &inhibit_gdbinit, 1},
       {"n", no_argument, &inhibit_gdbinit, 1},
       {"batch-silent", no_argument, 0, 'B'},
@@ -845,7 +847,7 @@ captured_main (void *data)
      global parameters, which are independent of what file you are
      debugging or what directory you are in.  */
 
-  if (home_gdbinit && !inhibit_gdbinit)
+  if (home_gdbinit && !inhibit_gdbinit && !inhibit_home_gdbinit)
     catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL);
 
   /* Process '-ix' and '-iex' options early.  */
@@ -1066,9 +1068,12 @@ Options:\n\n\
   fputs_unfiltered (_("\
   -l TIMEOUT         Set timeout in seconds for remote debugging.\n\
   --nw              Do not use a window interface.\n\
-  --nx               Do not read "), stream);
+  --nx               Do not read any "), stream);
   fputs_unfiltered (gdbinit, stream);
-  fputs_unfiltered (_(" file.\n\
+  fputs_unfiltered (_(" files.\n\
+  --nh               Do not read "), stream);
+  fputs_unfiltered (gdbinit, stream);
+  fputs_unfiltered (_(" file from home directory.\n\
   --quiet            Do not print version number on startup.\n\
   --readnow          Fully read symbol files on first access.\n\
 "), stream);