Skip to content

Commit 18258fa

Browse files
committed
Teach rr sources about NIX_DEBUG_INFO_DIRS.
Rather than using the usual global paths under /usr, Nix systems use a special environment variable to point to the various locations in the Nix store that contain separate debug info. When we're not running a custom gdb script use the paths in that environment variable when it's present.
1 parent 1c1c88d commit 18258fa

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/SourcesCommand.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ class DebugDirManager {
157157
~DebugDirManager();
158158

159159
DebugDirs initial_directories() {
160+
if (!input_pipe_fd.is_open()) {
161+
// Try known alternatives.
162+
if (char* nix_debug_info_dirs = getenv("NIX_DEBUG_INFO_DIRS")) {
163+
// NIX_DEBUG_INFO_DIRS is a colon separated list of paths to search for debug info.
164+
DebugDirs result;
165+
166+
// Make a copy that we can run strtok on.
167+
nix_debug_info_dirs = strdup(nix_debug_info_dirs);
168+
char* token = strtok(nix_debug_info_dirs, ":");
169+
while (token != nullptr) {
170+
string s(token);
171+
s = real_path(s);
172+
result.debug_file_directories.push_back(s);
173+
LOG(debug) << "NIX_DEBUG_INFO_DIRS added debug dir '" << s << "'";
174+
token = strtok(nullptr, ":");
175+
}
176+
free(nix_debug_info_dirs);
177+
return result;
178+
}
179+
}
180+
160181
return read_result();
161182
}
162183
DebugDirs process_one_binary(const string& binary_path);

0 commit comments

Comments
 (0)