-
Notifications
You must be signed in to change notification settings - Fork 5
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
[PROF-9088] Fix symbolization for binaries with compressed debug information #395
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,24 +103,34 @@ class Symbolizer { | |
}; | ||
|
||
struct BlazeSymbolizerWrapper { | ||
static blaze_symbolizer_opts create_opts(bool inlined_fns) { | ||
static blaze_symbolizer_opts create_opts_with_debug(bool inlined_fns) { | ||
return blaze_symbolizer_opts{.type_size = sizeof(blaze_symbolizer_opts), | ||
.auto_reload = false, | ||
.code_info = true, | ||
.inlined_fns = inlined_fns, | ||
.demangle = false, | ||
.reserved = {}}; | ||
} | ||
|
||
explicit BlazeSymbolizerWrapper(std::string elf_src, bool inlined_fns) | ||
: opts(create_opts(inlined_fns)), | ||
static blaze_symbolizer_opts create_opts_no_debug() { | ||
return blaze_symbolizer_opts{.type_size = sizeof(blaze_symbolizer_opts), | ||
.auto_reload = false, | ||
.code_info = false, | ||
.inlined_fns = false, | ||
.demangle = false, | ||
.reserved = {}}; | ||
} | ||
explicit BlazeSymbolizerWrapper(std::string elf_src, bool inlined_fns, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consecutive bool arguments are error prone |
||
bool use_debug = true) | ||
: opts(use_debug ? create_opts_with_debug(inlined_fns) | ||
: create_opts_no_debug()), | ||
_symbolizer(blaze_symbolizer_new_opts(&opts)), | ||
_elf_src(std::move(elf_src)) {} | ||
_elf_src(std::move(elf_src)), _use_debug(use_debug) {} | ||
blaze_symbolizer_opts opts; | ||
std::unique_ptr<blaze_symbolizer, BlazeSymbolizerDeleter> _symbolizer; | ||
ddprof::HeterogeneousLookupStringMap<std::string> _demangled_names; | ||
std::string _elf_src; | ||
bool _visited{true}; | ||
bool _use_debug; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public members don't need an underscore prefix |
||
}; | ||
|
||
std::unordered_map<FileInfoId_t, BlazeSymbolizerWrapper> _symbolizer_map; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,29 +54,34 @@ DDRes Symbolizer::symbolize_pprof(std::span<ElfAddress_t> elf_addrs, | |
return ddres_warn(DD_WHAT_PPROF); // or some other error handling | ||
} | ||
ddprof::HeterogeneousLookupStringMap<std::string> *demangled_names = nullptr; | ||
const auto it = _symbolizer_map.find(file_id); | ||
const char *resolved_src = elf_src.c_str(); | ||
// This is to avoid we change the path at every call (for different pids) | ||
// The cache takes into account the first path given | ||
if (it != _symbolizer_map.end()) { | ||
resolved_src = it->second._elf_src.c_str(); | ||
symbolizer = it->second._symbolizer.get(); | ||
it->second._visited = true; | ||
demangled_names = &(it->second._demangled_names); | ||
} else { | ||
auto pair = _symbolizer_map.emplace( | ||
file_id, BlazeSymbolizerWrapper(elf_src, inlined_functions)); | ||
DDPROF_DCHECK_FATAL(pair.second, "Unable to insert symbolizer object"); | ||
symbolizer = pair.first->second._symbolizer.get(); | ||
demangled_names = &(pair.first->second._demangled_names); | ||
} | ||
bool retry_symbolization = true; | ||
bool use_debug = true; | ||
const blaze_result *blaze_res = nullptr; | ||
if (!_disable_symbolization) { | ||
while (retry_symbolization && !_disable_symbolization) { | ||
const auto it = _symbolizer_map.find(file_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the inner loop could be refactored into another function |
||
const char *resolved_src = elf_src.c_str(); | ||
// This is to avoid we change the path at every call (for different pids) | ||
// The cache takes into account the first path given | ||
if (it != _symbolizer_map.end()) { | ||
resolved_src = it->second._elf_src.c_str(); | ||
symbolizer = it->second._symbolizer.get(); | ||
it->second._visited = true; | ||
demangled_names = &(it->second._demangled_names); | ||
retry_symbolization = false; | ||
use_debug = it->second._use_debug; | ||
} else { | ||
auto pair = _symbolizer_map.emplace( | ||
file_id, | ||
BlazeSymbolizerWrapper(elf_src, inlined_functions, use_debug)); | ||
DDPROF_DCHECK_FATAL(pair.second, "Unable to insert symbolizer object"); | ||
symbolizer = pair.first->second._symbolizer.get(); | ||
demangled_names = &(pair.first->second._demangled_names); | ||
} | ||
// Initialize the src_elf structure | ||
const blaze_symbolize_src_elf src_elf{ | ||
.type_size = sizeof(blaze_symbolize_src_elf), | ||
.path = resolved_src, | ||
.debug_syms = true, | ||
.debug_syms = use_debug, | ||
.reserved = {}, | ||
}; | ||
|
||
|
@@ -97,7 +102,14 @@ DDRes Symbolizer::symbolize_pprof(std::span<ElfAddress_t> elf_addrs, | |
_reported_addr_format == k_elf ? elf_addrs[i] : process_addrs[i], | ||
(*demangled_names), map_info, *cur_sym, write_index, locations)); | ||
} | ||
} else if (retry_symbolization && use_debug) { | ||
LG_NTC("Unable to symbolize with debug symbols, retrying for %s", | ||
elf_src.c_str()); | ||
_symbolizer_map.erase(file_id); | ||
use_debug = false; | ||
continue; | ||
} | ||
retry_symbolization = false; | ||
} | ||
// Handle the case of no blaze result | ||
// This can happen when file descriptors are exhausted | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to change
blaze_symbolizer_opts
, callingblaze_symbolize_elf_virt_offsets
withblaze_symbolize_src_elf.debug_syms
set to false should be enough.