Revert "Fix incorrect source file name for inlined frames"

This reverts commit 54d878abcb.

54d878abcb changed 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:
Mark Mentovai 2021-10-26 09:31:09 -04:00
parent 076073c96b
commit dfcb7b6799
18 changed files with 214 additions and 223 deletions

View file

@ -97,6 +97,17 @@ void Module::InlineOriginMap::SetReference(uint64_t offset,
references_[offset] = specification_offset;
}
void Module::InlineOriginMap::AssignFilesToInlineOrigins(
const vector<uint64_t>& inline_origin_offsets,
Module::File* file) {
for (uint64_t offset : inline_origin_offsets)
if (references_.find(offset) != references_.end()) {
auto origin = inline_origins_.find(references_[offset]);
if (origin != inline_origins_.end())
origin->second->file = file;
}
}
Module::Module(const string& name, const string& os,
const string& architecture, const string& id,
const string& code_id /* = "" */) :
@ -265,18 +276,13 @@ void Module::AssignSourceIds(
line_it != func->lines.end(); ++line_it)
line_it->file->source_id = 0;
}
// Also mark all files cited by inline callsite by setting each one's source
// Also mark all files cited by inline functions by setting each one's source
// id to zero.
auto markInlineFiles = [](unique_ptr<Inline>& in) {
for (InlineOrigin* origin : inline_origins)
// There are some artificial inline functions which don't belong to
// any file. Those will have file id -1.
if (in->call_site_file)
in->call_site_file->source_id = 0;
};
for (auto func : functions_) {
Inline::InlineDFS(func->inlines, markInlineFiles);
}
if (origin->file)
origin->file->source_id = 0;
// Finally, assign source ids to those files that have been marked.
// We could have just assigned source id numbers while traversing
@ -290,6 +296,15 @@ void Module::AssignSourceIds(
}
}
static void InlineDFS(
vector<unique_ptr<Module::Inline>>& inlines,
std::function<void(unique_ptr<Module::Inline>&)> const& forEach) {
for (unique_ptr<Module::Inline>& in : inlines) {
forEach(in);
InlineDFS(in->child_inlines, forEach);
}
}
void Module::CreateInlineOrigins(
set<InlineOrigin*, InlineOriginCompare>& inline_origins) {
// Only add origins that have file and deduplicate origins with same name and
@ -302,7 +317,7 @@ void Module::CreateInlineOrigins(
in->origin = *it;
};
for (Function* func : functions_)
Module::Inline::InlineDFS(func->inlines, addInlineOrigins);
InlineDFS(func->inlines, addInlineOrigins);
int next_id = 0;
for (InlineOrigin* origin : inline_origins) {
origin->id = next_id++;
@ -366,7 +381,8 @@ bool Module::Write(std::ostream& stream, SymbolData symbol_data) {
}
// Write out inline origins.
for (InlineOrigin* origin : inline_origins) {
stream << "INLINE_ORIGIN " << origin->id << " " << origin->name << "\n";
stream << "INLINE_ORIGIN " << origin->id << " " << origin->getFileID()
<< " " << origin->name << "\n";
if (!stream.good())
return ReportError();
}
@ -391,12 +407,12 @@ bool Module::Write(std::ostream& stream, SymbolData symbol_data) {
auto write_inline = [&](unique_ptr<Inline>& in) {
stream << "INLINE ";
stream << in->inline_nest_level << " " << in->call_site_line << " "
<< in->getCallSiteFileID() << " " << in->origin->id << hex;
<< in->origin->id << hex;
for (const Range& r : in->ranges)
stream << " " << (r.address - load_address_) << " " << r.size;
stream << dec << "\n";
};
Module::Inline::InlineDFS(func->inlines, write_inline);
InlineDFS(func->inlines, write_inline);
if (!stream.good())
return ReportError();