aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-09-25 14:50:56 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-11-02 17:42:11 +0000
commit64aaad6349d2b2c45063a5383f877ce9a3a0c354 (patch)
tree80261e6099c2421820a8e8a8f025a13cd9995c27 /gdb/main.c
parent8768c3e3629657d9728487c680b173868baeee7f (diff)
downloadfsf-binutils-gdb-64aaad6349d2b2c45063a5383f877ce9a3a0c354.zip
fsf-binutils-gdb-64aaad6349d2b2c45063a5383f877ce9a3a0c354.tar.gz
fsf-binutils-gdb-64aaad6349d2b2c45063a5383f877ce9a3a0c354.tar.bz2
gdb: use get_standard_config_dir when looking for .gdbinit
This commit effectively changes the default location of the .gdbinit file, while maintaining backward compatibility. For non Apple hosts the .gdbinit file will now be looked for in the following locations: $XDG_CONFIG_HOME/gdb/gdbinit $HOME/.config/gdb/gdbinit $HOME/.gdbinit On Apple hosts the search order is instead: $HOME/Library/Preferences/gdb/gdbinit $HOME/.gdbinit I've performed an extensive rewrite of the documentation, moving all information about initialization files and where to find them into a new @node, text from other areas has been moved into this one location, and other areas cross-reference to this new @node as much as possible. gdb/ChangeLog: * NEWS: Mention changes to config file search path. * main.c gdb/doc/ChangeLog: * gdb.texinfo (Mode Options): Descriptions of initialization files has been moved to 'Initialization Files'. (Startup): Likewise. (Initialization Files): New node. (gdb man): Update to mention alternative file paths. (gdbinit man): Likewise.
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/gdb/main.c b/gdb/main.c
index 7b44bfe..6232ea3 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -301,8 +301,6 @@ get_init_files (std::vector<std::string> *system_gdbinit,
}
}
- const char *homedir = getenv ("HOME");
-
/* If the .gdbinit file in the current directory is the same as
the $HOME/.gdbinit file, it should not be sourced. homebuf
and cwdbuf are used in that purpose. Make sure that the stats
@@ -312,14 +310,7 @@ get_init_files (std::vector<std::string> *system_gdbinit,
memset (&homebuf, 0, sizeof (struct stat));
memset (&cwdbuf, 0, sizeof (struct stat));
- if (homedir)
- {
- homeinit = std::string (homedir) + SLASH_STRING + GDBINIT;
- if (stat (homeinit.c_str (), &homebuf) != 0)
- {
- homeinit = "";
- }
- }
+ homeinit = find_gdb_home_config_file (GDBINIT, &homebuf);
if (stat (GDBINIT, &cwdbuf) == 0)
{
@@ -328,7 +319,7 @@ get_init_files (std::vector<std::string> *system_gdbinit,
sizeof (struct stat)))
localinit = GDBINIT;
}
-
+
initialized = 1;
}