From e87bb1b3b480d1e44e6a742b8cc0a1698b98494e Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Tue, 31 Aug 2021 10:50:11 -0700 Subject: [PATCH] Make INLINE_ORIGIN positions not important in symbol file This allows INLINE_ORIGIN records appears in after FUNC records. Change-Id: I69b8b5948ed91453e15c7f4c3888dfbe38e7bc5c Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3132381 Reviewed-by: Joshua Peraza --- src/processor/basic_source_line_resolver.cc | 19 +++++++++---------- .../source_line_resolver_base_types.h | 14 +++++--------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/processor/basic_source_line_resolver.cc b/src/processor/basic_source_line_resolver.cc index 79ae9965..bbaa1331 100644 --- a/src/processor/basic_source_line_resolver.cc +++ b/src/processor/basic_source_line_resolver.cc @@ -246,12 +246,15 @@ int BasicSourceLineResolver::Module::ConstructInlineFrames( MemAddr inline_base; if (!inlines.RetrieveRange(address, &in, &inline_base, nullptr, nullptr)) return -1; + auto origin = inline_origins_.find(in->origin_id); + if (origin == inline_origins_.end()) + return -1; StackFrame new_frame = StackFrame(*frame); - new_frame.function_name = in->name; + new_frame.function_name = origin->second->name; // Use the starting adress of the inlined range as inlined function base. new_frame.function_base = new_frame.module->base_address() + inline_base; - auto it = files_.find(in->source_file_id); + auto it = files_.find(origin->second->source_file_id); if (it != files_.end()) new_frame.source_file_name = it->second; @@ -417,8 +420,8 @@ bool BasicSourceLineResolver::Module::ParseInlineOrigin( char* origin_name; if (SymbolParseHelper::ParseInlineOrigin(inline_origin_line, &origin_id, &source_file_id, &origin_name)) { - inline_origins_.insert(make_pair( - origin_id, new InlineOrigin(origin_id, source_file_id, origin_name))); + inline_origins_.insert( + make_pair(origin_id, new InlineOrigin(source_file_id, origin_name))); return true; } return false; @@ -432,12 +435,8 @@ BasicSourceLineResolver::Module::ParseInline(char* inline_line) { vector> ranges; if (SymbolParseHelper::ParseInline(inline_line, &inline_nest_level, &call_site_line, &origin_id, &ranges)) { - auto origin = inline_origins_.find(origin_id); - if (origin != inline_origins_.end()) { - return linked_ptr( - new Inline(inline_nest_level, call_site_line, origin->second->name, - origin->second->source_file_id, ranges)); - } + return linked_ptr( + new Inline(inline_nest_level, call_site_line, origin_id, ranges)); } return linked_ptr(); } diff --git a/src/processor/source_line_resolver_base_types.h b/src/processor/source_line_resolver_base_types.h index 64cd86e0..3e3afd0e 100644 --- a/src/processor/source_line_resolver_base_types.h +++ b/src/processor/source_line_resolver_base_types.h @@ -70,10 +70,9 @@ class SourceLineResolverBase::AutoFileCloser { }; struct SourceLineResolverBase::InlineOrigin { - InlineOrigin(int32_t origin_id, int32_t source_file_id, const string& name) - : origin_id(origin_id), source_file_id(source_file_id), name(name) {} + InlineOrigin(int32_t source_file_id, const string& name) + : source_file_id(source_file_id), name(name) {} - int32_t origin_id; int32_t source_file_id; string name; }; @@ -83,19 +82,16 @@ struct SourceLineResolverBase::Inline { using InlineRanges = std::vector>; Inline(int32_t inline_nest_level, int32_t call_site_line, - const string& name, - int32_t source_file_id, + int32_t origin_id, InlineRanges inline_ranges) : inline_nest_level(inline_nest_level), call_site_line(call_site_line), - name(name), - source_file_id(source_file_id), + origin_id(origin_id), inline_ranges(inline_ranges) {} int32_t inline_nest_level; int32_t call_site_line; - string name; - int32_t source_file_id; + int32_t origin_id; InlineRanges inline_ranges; RangeMap> child_inlines; };