1diff -ur a/gdb/main.c b/gdb/main.c
2--- a/gdb/main.c 2020-02-08 13:50:14.000000000 +0100
3+++ b/gdb/main.c 2020-02-24 10:02:07.731806739 +0100
4@@ -567,9 +567,17 @@
5 gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
6 }
7
8- debug_file_directory
9- = xstrdup (relocate_gdb_directory (DEBUGDIR,
10- DEBUGDIR_RELOCATABLE).c_str ());
11+ debug_file_directory = getenv ("NIX_DEBUG_INFO_DIRS");
12+ if (debug_file_directory != NULL)
13+ // This might be updated later using
14+ // $ set debug-file-directory /to/some/path
15+ // which will use xfree. We must then have a xmallocated
16+ // copy of the string that can be xfeed later.
17+ debug_file_directory = xstrdup (debug_file_directory);
18+ else
19+ debug_file_directory
20+ = xstrdup (relocate_gdb_directory (DEBUGDIR,
21+ DEBUGDIR_RELOCATABLE).c_str ());
22
23 gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
24 GDB_DATADIR_RELOCATABLE);