mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-24 08:15:01 +01:00
Revert "Fix incorrect source file name for inlined frames"
This reverts commit54d878abcb.54d878abcbchanged the dump_syms format incompatibly. This must be redone in a multi-step process: the processor must be made to understand the old and new formats simultaneously and the processor service must be rebuilt and run with that update before dump_syms output can change to use the new format. Bug: chromium:1263390 Change-Id: I5b6f8aff8ea2916b2c07ac6a74b569fa27db51b9 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3244775 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
076073c96b
commit
dfcb7b6799
18 changed files with 214 additions and 223 deletions
|
|
@ -50,11 +50,10 @@
|
|||
|
||||
#include "processor/tokenize.h"
|
||||
|
||||
using std::deque;
|
||||
using std::make_pair;
|
||||
using std::map;
|
||||
using std::unique_ptr;
|
||||
using std::vector;
|
||||
using std::make_pair;
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace google_breakpad {
|
||||
|
||||
|
|
@ -238,43 +237,42 @@ bool BasicSourceLineResolver::Module::LoadMapFromMemory(
|
|||
return true;
|
||||
}
|
||||
|
||||
void BasicSourceLineResolver::Module::ConstructInlineFrames(
|
||||
int BasicSourceLineResolver::Module::ConstructInlineFrames(
|
||||
StackFrame* frame,
|
||||
MemAddr address,
|
||||
const RangeMap<uint64_t, linked_ptr<Inline>>& inlines,
|
||||
deque<unique_ptr<StackFrame>>* inlined_frames) const {
|
||||
vector<unique_ptr<StackFrame>>* inlined_frames) const {
|
||||
linked_ptr<Inline> in;
|
||||
MemAddr inline_base;
|
||||
if (!inlines.RetrieveRange(address, &in, &inline_base, nullptr, nullptr))
|
||||
return;
|
||||
return -1;
|
||||
auto origin = inline_origins_.find(in->origin_id);
|
||||
if (origin == inline_origins_.end())
|
||||
return;
|
||||
return -1;
|
||||
|
||||
// Update parent frame's source line and source file.
|
||||
frame->source_line = in->call_site_line;
|
||||
auto file = files_.find(in->call_site_file_id);
|
||||
if (file != files_.end()) {
|
||||
frame->source_file_name = file->second;
|
||||
}
|
||||
|
||||
// Create a child frame of `frame`.
|
||||
StackFrame child_frame = StackFrame(*frame);
|
||||
child_frame.function_name = origin->second->name;
|
||||
StackFrame new_frame = StackFrame(*frame);
|
||||
new_frame.function_name = origin->second->name;
|
||||
// Use the starting adress of the inlined range as inlined function base.
|
||||
child_frame.function_base = child_frame.module->base_address() + inline_base;
|
||||
child_frame.trust = StackFrame::FRAME_TRUST_INLINE;
|
||||
ConstructInlineFrames(&child_frame, address, in->child_inlines,
|
||||
inlined_frames);
|
||||
// Add child_frame after ConstructInlineFrames so that the innermost frame is
|
||||
// the first frame inside inlined_frames.
|
||||
inlined_frames->push_back(
|
||||
unique_ptr<StackFrame>(new StackFrame(child_frame)));
|
||||
new_frame.function_base = new_frame.module->base_address() + inline_base;
|
||||
auto it = files_.find(origin->second->source_file_id);
|
||||
if (it != files_.end())
|
||||
new_frame.source_file_name = it->second;
|
||||
|
||||
new_frame.trust = StackFrame::FRAME_TRUST_INLINE;
|
||||
// Must add frames before calling ConstructInlineFrames to get correct order.
|
||||
int current_idx = inlined_frames->size();
|
||||
inlined_frames->push_back(unique_ptr<StackFrame>(new StackFrame(new_frame)));
|
||||
int source_line = ConstructInlineFrames(&new_frame, address,
|
||||
in->child_inlines, inlined_frames);
|
||||
if (source_line != -1) {
|
||||
(*inlined_frames)[current_idx]->source_line = source_line;
|
||||
}
|
||||
return in->call_site_line;
|
||||
}
|
||||
|
||||
void BasicSourceLineResolver::Module::LookupAddress(
|
||||
StackFrame* frame,
|
||||
deque<unique_ptr<StackFrame>>* inlined_frames) const {
|
||||
vector<unique_ptr<StackFrame>>* inlined_frames) const {
|
||||
MemAddr address = frame->instruction - frame->module->base_address();
|
||||
|
||||
// First, look for a FUNC record that covers address. Use
|
||||
|
|
@ -308,13 +306,10 @@ void BasicSourceLineResolver::Module::LookupAddress(
|
|||
|
||||
// Check if this is inlined function call.
|
||||
if (inlined_frames) {
|
||||
int source_line = frame->source_line;
|
||||
string source_file_name = frame->source_file_name;
|
||||
ConstructInlineFrames(frame, address, func->inlines, inlined_frames);
|
||||
if (!inlined_frames->empty()) {
|
||||
// Update the inner most frame's source line and source file name.
|
||||
inlined_frames->front()->source_line = source_line;
|
||||
inlined_frames->front()->source_file_name = source_file_name;
|
||||
int source_line =
|
||||
ConstructInlineFrames(frame, address, func->inlines, inlined_frames);
|
||||
if (source_line != -1) {
|
||||
frame->source_line = source_line;
|
||||
}
|
||||
}
|
||||
} else if (public_symbols_.Retrieve(address,
|
||||
|
|
@ -421,10 +416,12 @@ bool BasicSourceLineResolver::Module::ParseFile(char* file_line) {
|
|||
bool BasicSourceLineResolver::Module::ParseInlineOrigin(
|
||||
char* inline_origin_line) {
|
||||
long origin_id;
|
||||
long source_file_id;
|
||||
char* origin_name;
|
||||
if (SymbolParseHelper::ParseInlineOrigin(inline_origin_line, &origin_id,
|
||||
&origin_name)) {
|
||||
inline_origins_.insert(make_pair(origin_id, new InlineOrigin(origin_name)));
|
||||
&source_file_id, &origin_name)) {
|
||||
inline_origins_.insert(
|
||||
make_pair(origin_id, new InlineOrigin(source_file_id, origin_name)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -434,14 +431,12 @@ linked_ptr<BasicSourceLineResolver::Inline>
|
|||
BasicSourceLineResolver::Module::ParseInline(char* inline_line) {
|
||||
long inline_nest_level;
|
||||
long call_site_line;
|
||||
long call_site_file_id;
|
||||
long origin_id;
|
||||
vector<std::pair<MemAddr, MemAddr>> ranges;
|
||||
if (SymbolParseHelper::ParseInline(inline_line, &inline_nest_level,
|
||||
&call_site_line, &call_site_file_id,
|
||||
&origin_id, &ranges)) {
|
||||
return linked_ptr<Inline>(new Inline(inline_nest_level, call_site_line,
|
||||
call_site_file_id, origin_id, ranges));
|
||||
&call_site_line, &origin_id, &ranges)) {
|
||||
return linked_ptr<Inline>(
|
||||
new Inline(inline_nest_level, call_site_line, origin_id, ranges));
|
||||
}
|
||||
return linked_ptr<Inline>();
|
||||
}
|
||||
|
|
@ -641,12 +636,13 @@ bool SymbolParseHelper::ParseFile(char* file_line, long* index,
|
|||
// static
|
||||
bool SymbolParseHelper::ParseInlineOrigin(char* inline_origin_line,
|
||||
long* origin_id,
|
||||
long* file_id,
|
||||
char** name) {
|
||||
// INLINE_ORIGIN <origin_id> <name>
|
||||
// INLINE_ORIGIN <origin_id> <file_id> <name>
|
||||
assert(strncmp(inline_origin_line, "INLINE_ORIGIN ", 14) == 0);
|
||||
inline_origin_line += 14; // skip prefix
|
||||
vector<char*> tokens;
|
||||
if (!Tokenize(inline_origin_line, kWhitespace, 2, &tokens)) {
|
||||
if (!Tokenize(inline_origin_line, kWhitespace, 3, &tokens)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -657,7 +653,15 @@ bool SymbolParseHelper::ParseInlineOrigin(char* inline_origin_line,
|
|||
return false;
|
||||
}
|
||||
|
||||
*name = tokens[1];
|
||||
*file_id = strtol(tokens[1], &after_number, 10);
|
||||
// If the file id is -1, it might be an artificial function that doesn't have
|
||||
// file id. So, we consider -1 as a valid special case.
|
||||
if (!IsValidAfterNumber(after_number) ||
|
||||
*file_id < -1 | *origin_id == std::numeric_limits<long>::max()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*name = tokens[2];
|
||||
if (!*name) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -670,19 +674,18 @@ bool SymbolParseHelper::ParseInline(
|
|||
char* inline_line,
|
||||
long* inline_nest_level,
|
||||
long* call_site_line,
|
||||
long* call_site_file_id,
|
||||
long* origin_id,
|
||||
vector<std::pair<MemAddr, MemAddr>>* ranges) {
|
||||
// INLINE <inline_nest_level> <call_site_line> <call_site_file_id> <origin_id>
|
||||
// [<address> <size>]+
|
||||
// INLINE <inline_nest_level> <call_site_line> <origin_id> <address> <size>
|
||||
// ...
|
||||
assert(strncmp(inline_line, "INLINE ", 7) == 0);
|
||||
inline_line += 7; // skip prefix
|
||||
|
||||
vector<char*> tokens;
|
||||
Tokenize(inline_line, kWhitespace, std::numeric_limits<int>::max(), &tokens);
|
||||
|
||||
// The length of the vector should be at least 6 and an even number.
|
||||
if (tokens.size() < 6 || tokens.size() % 2 != 0)
|
||||
// The length of the vector should be at least 5 and an odd number.
|
||||
if (tokens.size() < 5 && tokens.size() % 2 == 0)
|
||||
return false;
|
||||
|
||||
char* after_number;
|
||||
|
|
@ -698,21 +701,13 @@ bool SymbolParseHelper::ParseInline(
|
|||
return false;
|
||||
}
|
||||
|
||||
*call_site_file_id = strtol(tokens[2], &after_number, 10);
|
||||
// If the file id is -1, it might be an artificial function that doesn't have
|
||||
// file id. So, we consider -1 as a valid special case.
|
||||
if (!IsValidAfterNumber(after_number) || *call_site_file_id < -1 ||
|
||||
*call_site_file_id == std::numeric_limits<long>::max()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*origin_id = strtol(tokens[3], &after_number, 10);
|
||||
*origin_id = strtol(tokens[2], &after_number, 10);
|
||||
if (!IsValidAfterNumber(after_number) || *origin_id < 0 ||
|
||||
*origin_id == std::numeric_limits<long>::max()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 4; i < tokens.size();) {
|
||||
for (size_t i = 3; i < tokens.size();) {
|
||||
MemAddr address = strtoull(tokens[i++], &after_number, 16);
|
||||
if (!IsValidAfterNumber(after_number) ||
|
||||
address == std::numeric_limits<unsigned long long>::max()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue