This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[prelim patch] Add the notion of a global init file to gdb.


So, in some work that I've been doing on GDB, it's been very useful to
have a global init file, that gets sourced before $(HOME)/.gdbinit or
./.gdbinit, to set up "site"-specific things such as user-defined
commands that all users of the tools will want.  (Basically, to extend
GDB in a way that's not really noticeable to random users.)

Below is a preliminary, and incomplete, patch to add such a global
init file to gdb, enabled by a configure option,
"--enable-global-gdbinit=FILENAME".


It is _not_ ready for approval.  At minimum, it requires updates to
the documentation, etc.

I'm mostly looking for feedback on:

(1) Is this a generally useful feature, a "good idea"?, and

(2) the names of the various added pieces.

If this feature is deemed worht having, I'll update the patch to
include doc changes and any changes caused by the feedback itself and
resubmit it for inclusion.


Comments?



chris
===================================================================
Index: gdb/config.in
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gdb/gdb/config.in,v
retrieving revision 1.3
diff -c -r1.3 config.in
*** config.in	2000/10/26 17:52:27	1.3
--- config.in	2000/11/21 20:15:19
***************
*** 156,161 ****
--- 156,164 ----
  /* nativefile */
  #undef GDB_NM_FILE
  
+ /* global GDB init file */
+ #undef GLOBAL_GDBINIT
+ 
  /* Define if you have the __argz_count function.  */
  #undef HAVE___ARGZ_COUNT
  
Index: gdb/configure.in
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gdb/gdb/configure.in,v
retrieving revision 1.3
diff -c -r1.3 configure.in
*** configure.in	2000/10/26 17:52:28	1.3
--- configure.in	2000/11/21 20:15:20
***************
*** 908,913 ****
--- 908,922 ----
  AC_SUBST(IGNORE_SIM)
  AC_SUBST(IGNORE_SIM_OBS)
  
+ AC_ARG_ENABLE(global-gdbinit,
+ [  --enable-global-gdbinit=FILE
+                           Source a global init file when starting],
+ [case "${enableval}" in
+   yes) ;;
+   no)  ;;
+   *)   AC_DEFINE_UNQUOTED(GLOBAL_GDBINIT, "${enableval}") ;;
+  esac])
+ 
  AC_SUBST(ENABLE_CFLAGS)
  
  AC_SUBST(CONFIG_OBS)
Index: gdb/main.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gdb/gdb/main.c,v
retrieving revision 1.3
diff -c -r1.3 main.c
*** main.c	2000/10/26 17:53:02	1.3
--- main.c	2000/11/21 20:15:20
***************
*** 530,539 ****
    /* We may get more than one warning, don't double space all of them... */
    warning_pre_print = "\nwarning: ";
  
!   /* Read and execute $HOME/.gdbinit file, if it exists.  This is done
!      *before* all the command line arguments are processed; it sets
!      global parameters, which are independent of what file you are
!      debugging or what directory you are in.  */
  #ifdef __CYGWIN32__
    {
      char *tmp = getenv ("HOME");
--- 530,546 ----
    /* We may get more than one warning, don't double space all of them... */
    warning_pre_print = "\nwarning: ";
  
!   /* Read and execute the GLOBAL_GDBINIT file (if any) and the
!      $HOME/.gdbinit file, if they exist.  This is done *before* all
!      the command line arguments are processed; it sets global
!      parameters, which are independent of what file you are debugging
!      or what directory you are in.  */
! #ifdef GLOBAL_GDBINIT
!   if (!inhibit_gdbinit)
!     {
!       catch_command_errors (source_command, GLOBAL_GDBINIT, 0, RETURN_MASK_ALL);
!     }
! #endif
  #ifdef __CYGWIN32__
    {
      char *tmp = getenv ("HOME");
Index: gdb/top.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gdb/gdb/top.c,v
retrieving revision 1.4
diff -c -r1.4 top.c
*** top.c	2000/10/31 01:20:27	1.4
--- top.c	2000/11/21 20:15:20
***************
*** 4116,4125 ****
  #ifdef __STDC__
    c = add_cmd ("source", class_support, source_command,
  	       "Read commands from a file named FILE.\n\
! Note that the file \"" GDBINIT_FILENAME "\" is read automatically in this way\n\
  when gdb is started.", &cmdlist);
  #else
!   /* Punt file name, we can't help it easily.  */
    c = add_cmd ("source", class_support, source_command,
  	       "Read commands from a file named FILE.\n\
  Note that the file \".gdbinit\" is read automatically in this way\n\
--- 4116,4131 ----
  #ifdef __STDC__
    c = add_cmd ("source", class_support, source_command,
  	       "Read commands from a file named FILE.\n\
! Note that the "
! #ifdef GLOBAL_GDBINIT
! "files \"" GLOBAL_GDBINIT "\" and \"" GDBINIT_FILENAME "\" are"
! #else
! "file \"" GDBINIT_FILENAME "\" is"
! #endif
! " read automatically in this way\n\
  when gdb is started.", &cmdlist);
  #else
!   /* Punt file names, we can't help it easily.  */
    c = add_cmd ("source", class_support, source_command,
  	       "Read commands from a file named FILE.\n\
  Note that the file \".gdbinit\" is read automatically in this way\n\

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]