From efe4f93c563a0c84c72e1c753389d0c52c4723ec Mon Sep 17 00:00:00 2001 From: Lucian Grijincu Date: Tue, 23 Feb 2016 01:50:18 -0800 Subject: [PATCH] folly: symbolizer: dwarf: don't fallback to linear scan if address missing from .debug_aranges Summary:Presence of .debug_aranges implies user expects fast address lookup. Some addresses might not be avaialble in .debug_aranges. Don't do slow lookup in .debug_info, as it can lead to unexpected slowdowns. override-unit-failures Reviewed By: philippv Differential Revision: D2965323 fb-gh-sync-id: 405daefd57cdff4344fd231c5f5b7ff4dcd9df8c shipit-source-id: 405daefd57cdff4344fd231c5f5b7ff4dcd9df8c --- folly/experimental/symbolizer/Dwarf.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/folly/experimental/symbolizer/Dwarf.cpp b/folly/experimental/symbolizer/Dwarf.cpp index c13420ca..f9e9709d 100644 --- a/folly/experimental/symbolizer/Dwarf.cpp +++ b/folly/experimental/symbolizer/Dwarf.cpp @@ -573,19 +573,22 @@ bool Dwarf::findAddress(uintptr_t address, LocationInfo& locationInfo) const { // Fast path: find the right .debug_info entry by looking up the // address in .debug_aranges. uint64_t offset = 0; - if (findDebugInfoOffset(address, aranges_, offset)) { - // Read compilation unit header from .debug_info - folly::StringPiece infoEntry(info_); - infoEntry.advance(offset); - findLocation(address, infoEntry, locationInfo); - return true; + if (!findDebugInfoOffset(address, aranges_, offset)) { + // NOTE: clang doesn't generate entries in .debug_aranges for + // some functions, but always generates .debug_info entries. + // We could read them from .debug_info but that's too slow. + // If .debug_aranges is present fast address lookup is assumed. + return false; } + // Read compilation unit header from .debug_info + folly::StringPiece infoEntry(info_); + infoEntry.advance(offset); + findLocation(address, infoEntry, locationInfo); + return true; } // Slow path (linear scan): Iterate over all .debug_info entries // and look for the address in each compilation unit. - // NOTE: clang doesn't generate entries in .debug_aranges for some - // functions, but always generates .debug_info entries. folly::StringPiece infoEntry(info_); while (!infoEntry.empty() && !locationInfo.hasFileAndLine) { findLocation(address, infoEntry, locationInfo); -- 2.34.1