Skip to content

rr sources: expose loaded elves #3954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/SourcesCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const char* DWP = "dwp";
/// Prints JSON containing
/// "relevant_binaries": an array of strings, trace-relative binary file names (or build-ids, for explicit-sources).
/// These are ELF files in the trace that our collected data is relevant to.
/// "loaded_elves": an array of strings of absolute paths.
/// These are the paths to all the loaded ELF objects mapped at any point in the trace, including both shared libraries and executables.
/// "external_debug_info": an array of objects, {"path":<path>, "build_id":<build-id>, "type":<type>}
/// These are ELF files in the filesystem that contain separate debuginfo. "build-id" is the
/// build-id of the file from whence it originated, as a string. "type" is the type of
Expand Down Expand Up @@ -1055,6 +1057,7 @@ static int sources(const iterable& binary_file_names,
unique_ptr<DebugDirManager>& debug_dirs,
bool is_explicit) {
vector<string> relevant_binary_names;
set<string> original_loaded_elf_names;
// Must be absolute.
set<string> file_names;
set<ExternalDebugInfo> external_debug_info;
Expand All @@ -1080,9 +1083,11 @@ static int sources(const iterable& binary_file_names,
LOG(info) << "Probably not an ELF file, skipping";
continue;
}

if (!is_explicit) {
base_name(trace_relative_name);
}
original_loaded_elf_names.insert(original_name);
base_name(original_name);
Debugaltlink debugaltlink = reader.read_debugaltlink();

Expand Down Expand Up @@ -1205,6 +1210,15 @@ static int sources(const iterable& binary_file_names,
i == relevant_binary_names.size() - 1 ? "" : ",");
}
printf(" ],\n");

printf(" \"loaded_elves\": [\n");
for (auto it = original_loaded_elf_names.begin(); it != original_loaded_elf_names.end(); ++it) {
printf(" \"%s\"%s\n",
json_escape(*it).c_str(),
std::next(it) == original_loaded_elf_names.end() ? "" : ",");
}
printf(" ],\n");

printf(" \"comp_dir_substitutions\":{\n");
for (size_t i = 0; i < output_comp_dir_substitutions.size(); ++i) {
auto& sub = output_comp_dir_substitutions[i];
Expand Down