diff options
author | Doug Evans <dje@google.com> | 2012-11-16 19:43:39 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2012-11-16 19:43:39 +0000 |
commit | e64e03922ca4da2d3da887a467076eda615c62bd (patch) | |
tree | c3042b366b8557853d7fe30243bd05fd26047bfa /gdb | |
parent | 79f080079c7ea480a8b16b6d600536e628e558b4 (diff) | |
download | gdb-e64e03922ca4da2d3da887a467076eda615c62bd.zip gdb-e64e03922ca4da2d3da887a467076eda615c62bd.tar.gz gdb-e64e03922ca4da2d3da887a467076eda615c62bd.tar.bz2 |
* main.c (gdb_datadir_provided): New static global.
(get_init_files): If --data-directory is provided,
and SYSTEM_GDBINIT lives in data-directory, look for it there.
* NEWS: Mention it.
doc/
* gdb.texinfo (System-wide configuration): If the system-wide init
file lives in the data-directory, and --data-directory is provided,
look for it there.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/NEWS | 7 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 11 | ||||
-rw-r--r-- | gdb/main.c | 39 |
5 files changed, 66 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1aeafec..0b79e91 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2012-11-16 Doug Evans <dje@google.com> + + * main.c (gdb_datadir_provided): New static global. + (get_init_files): If --data-directory is provided, + and SYSTEM_GDBINIT lives in data-directory, look for it there. + * NEWS: Mention it. + 2012-11-15 Pierre Muller <muller@sourceware.org> ARI fixes: move gdb_wait and gdb_stat headers to common subdirectory. @@ -3,6 +3,13 @@ *** Changes since GDB 7.5 +* If the configured location of system.gdbinit file (as given by the + --with-system-gdbinit option at configure time) is in the + data-directory (as specified by --with-gdb-datadir at configure + time) or in one of its subdirectories, then GDB will look for the + system-wide init file in the directory specified by the + --data-directory command-line option. + * New command line options: -nh Disables auto-loading of ~/.gdbinit, but still executes all the diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index a774681..8fda5d5 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2012-11-16 Doug Evans <dje@google.com> + + * gdb.texinfo (System-wide configuration): If the system-wide init + file lives in the data-directory, and --data-directory is provided, + look for it there. + 2012-11-15 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Signaling): Fix typo. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 945a66b..80148f7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -34765,6 +34765,17 @@ then @value{GDBN} will always look for @file{/usr/share/gdb/gdbinit}, wherever @value{GDBN} is installed. @end itemize +If the configured location of the system-wide init file (as given by the +@option{--with-system-gdbinit} option at configure time) is in the +data-directory (as specified by @option{--with-gdb-datadir} at configure +time) or in one of its subdirectories, then @value{GDBN} will look for the +system-wide init file in the directory specified by the +@option{--data-directory} command-line option. +Note that the system-wide init file is only read once, during @value{GDBN} +initialization. If the data-directory is changed after @value{GDBN} has +started with the @code{set data-directory} command, the file will not be +reread. + @node Maintenance Commands @appendix Maintenance Commands @cindex maintenance commands @@ -60,6 +60,11 @@ char *gdb_sysroot = 0; /* GDB datadir, used to store data files. */ char *gdb_datadir = 0; +/* Non-zero if GDB_DATADIR was provided on the command line. + This doesn't track whether data-directory is set later from the + command line, but we don't reread system.gdbinit when that happens. */ +static int gdb_datadir_provided = 0; + /* If gdb was configured with --with-python=/path, the possibly relocated path to python's lib directory. */ char *python_libdir = 0; @@ -163,13 +168,38 @@ get_init_files (char **system_gdbinit, if (!initialized) { struct stat homebuf, cwdbuf, s; - char *homedir, *relocated_sysgdbinit; + char *homedir; if (SYSTEM_GDBINIT[0]) { - relocated_sysgdbinit = relocate_path (gdb_program_name, - SYSTEM_GDBINIT, - SYSTEM_GDBINIT_RELOCATABLE); + int datadir_len = strlen (GDB_DATADIR); + int sys_gdbinit_len = strlen (SYSTEM_GDBINIT); + char *relocated_sysgdbinit; + + /* If SYSTEM_GDBINIT lives in data-directory, and data-directory + has been provided, search for SYSTEM_GDBINIT there. */ + if (gdb_datadir_provided + && datadir_len < sys_gdbinit_len + && strncmp (SYSTEM_GDBINIT, GDB_DATADIR, datadir_len) == 0 + && strchr (SLASH_STRING, SYSTEM_GDBINIT[datadir_len]) != NULL) + { + /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR + to gdb_datadir. */ + char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len); + char *p; + + for (p = tmp_sys_gdbinit; strchr (SLASH_STRING, *p); ++p) + continue; + relocated_sysgdbinit = concat (gdb_datadir, SLASH_STRING, p, + NULL); + xfree (tmp_sys_gdbinit); + } + else + { + relocated_sysgdbinit = relocate_path (gdb_program_name, + SYSTEM_GDBINIT, + SYSTEM_GDBINIT_RELOCATABLE); + } if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0) sysgdbinit = relocated_sysgdbinit; else @@ -591,6 +621,7 @@ captured_main (void *data) case 'D': xfree (gdb_datadir); gdb_datadir = xstrdup (optarg); + gdb_datadir_provided = 1; break; #ifdef GDBTK case 'z': |