mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-04 13:44:33 +01:00
Add INLINE and INLINE_ORIGIN records to symbol file.
The size of symbol file for chrome binary increased from 577 MB to 1205 MB. There are 7,453,748 INLINE records and 1,268,493 INLINE_ORIGIN records. Bug: 1190878 Change-Id: I802ec1b4574c14f74ff80d0f69daf3c81085778a Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2915828 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
0d9416d3bf
commit
4f5b814790
11 changed files with 511 additions and 86 deletions
|
|
@ -38,14 +38,16 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace google_breakpad {
|
||||
|
||||
using std::dec;
|
||||
using std::hex;
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
Module::Module(const string& name, const string& os,
|
||||
const string& architecture, const string& id,
|
||||
|
|
@ -214,6 +216,13 @@ void Module::AssignSourceIds() {
|
|||
line_it != func->lines.end(); ++line_it)
|
||||
line_it->file->source_id = 0;
|
||||
}
|
||||
// Also mark all files cited by inline functions by setting each one's source
|
||||
// id to zero.
|
||||
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 (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
|
||||
|
|
@ -227,6 +236,33 @@ 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() {
|
||||
// Only add origins that have file and deduplicate origins with same name and
|
||||
// file id by doing a DFS.
|
||||
auto addInlineOrigins = [&](unique_ptr<Inline> &in) {
|
||||
auto it = inline_origins_.find(in->origin);
|
||||
if (it == inline_origins_.end())
|
||||
inline_origins_.insert(in->origin);
|
||||
else
|
||||
in->origin = *it;
|
||||
};
|
||||
for (Function* func : functions_)
|
||||
InlineDFS(func->inlines, addInlineOrigins);
|
||||
int next_id = 0;
|
||||
for (InlineOrigin* origin: inline_origins_) {
|
||||
origin->id = next_id++;
|
||||
}
|
||||
}
|
||||
|
||||
bool Module::ReportError() {
|
||||
fprintf(stderr, "error writing symbol file: %s\n",
|
||||
strerror(errno));
|
||||
|
|
@ -267,6 +303,8 @@ bool Module::Write(std::ostream& stream, SymbolData symbol_data) {
|
|||
}
|
||||
|
||||
if (symbol_data & SYMBOLS_AND_FILES) {
|
||||
if (symbol_data & INLINES)
|
||||
CreateInlineOrigins();
|
||||
AssignSourceIds();
|
||||
|
||||
// Write out files.
|
||||
|
|
@ -279,8 +317,17 @@ bool Module::Write(std::ostream& stream, SymbolData symbol_data) {
|
|||
return ReportError();
|
||||
}
|
||||
}
|
||||
// Write out inline origins.
|
||||
if (symbol_data & INLINES) {
|
||||
for (InlineOrigin* origin : inline_origins_) {
|
||||
stream << "INLINE_ORIGIN " << origin->id << " " << origin->getFileID()
|
||||
<< " " << origin->name << "\n";
|
||||
if (!stream.good())
|
||||
return ReportError();
|
||||
}
|
||||
}
|
||||
|
||||
// Write out functions and their lines.
|
||||
// Write out functions and their inlines and lines.
|
||||
for (FunctionSet::const_iterator func_it = functions_.begin();
|
||||
func_it != functions_.end(); ++func_it) {
|
||||
Function* func = *func_it;
|
||||
|
|
@ -296,6 +343,21 @@ bool Module::Write(std::ostream& stream, SymbolData symbol_data) {
|
|||
if (!stream.good())
|
||||
return ReportError();
|
||||
|
||||
// Write out inlines.
|
||||
if (symbol_data & INLINES) {
|
||||
auto write_inline = [&](unique_ptr<Inline>& in) {
|
||||
stream << "INLINE ";
|
||||
stream << in->inline_nest_level << " " << in->call_site_line << " "
|
||||
<< in->origin->id << hex;
|
||||
for (const Range& r : in->ranges)
|
||||
stream << " " << (r.address - load_address_) << " " << r.size;
|
||||
stream << dec << "\n";
|
||||
};
|
||||
InlineDFS(func->inlines, write_inline);
|
||||
if (!stream.good())
|
||||
return ReportError();
|
||||
}
|
||||
|
||||
while ((line_it != func->lines.end()) &&
|
||||
(line_it->address >= range_it->address) &&
|
||||
(line_it->address < (range_it->address + range_it->size))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue