Breakpad Linux dumper: Add support for dumping DWARF CFI as STACK CFI records.

Define a new DWARF parser class, dwarf2reader::CallFrameInfo.

Extend google_breakpad::Module to store and write out 'STACK CFI' records.

Define a new google_breakpad::DwarfCFIToModule class, to accept DWARF
CFI data from the parser and populate a Module with the equivalent
STACK CFI records.

Extend the Linux symbol dumping tool, dump_syms, to use
dwarf2reader::CallFrameInfo, google_breakpad::DwarfCFIToModule, and
google_breakpad::Module to extract DWARF CFI from the executable or
shared library files and write it to the Breakpad symbol file.

Define CFISection, a new class derived from TestAssembler::Section,
for use in creating DWARF CFI data for test cases.

a=jimblandy, r=nealsid


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@550 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
jimblandy 2010-03-16 16:31:49 +00:00
parent 6d3a825dbf
commit 3e768ed9c0
14 changed files with 4935 additions and 11 deletions

View file

@ -52,6 +52,9 @@ Module::~Module() {
for (vector<Function *>::iterator it = functions_.begin();
it != functions_.end(); it++)
delete *it;
for (vector<StackFrameEntry *>::iterator it = stack_frame_entries_.begin();
it != stack_frame_entries_.end(); it++)
delete *it;
}
void Module::SetLoadAddress(Address address) {
@ -67,6 +70,10 @@ void Module::AddFunctions(vector<Function *>::iterator begin,
functions_.insert(functions_.end(), begin, end);
}
void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) {
stack_frame_entries_.push_back(stack_frame_entry);
}
void Module::GetFunctions(vector<Function *> *vec,
vector<Function *>::iterator i) {
vec->insert(i, functions_.begin(), functions_.end());
@ -111,6 +118,10 @@ void Module::GetFiles(vector<File *> *vec) {
vec->push_back(it->second);
}
void Module::GetStackFrameEntries(vector<StackFrameEntry *> *vec) {
*vec = stack_frame_entries_;
}
void Module::AssignSourceIds() {
// First, give every source file an id of -1.
for (FileByNameMap::iterator file_it = files_.begin();
@ -144,6 +155,18 @@ bool Module::ReportError() {
return false;
}
bool Module::WriteRuleMap(const RuleMap &rule_map, FILE *stream) {
for (RuleMap::const_iterator it = rule_map.begin();
it != rule_map.end(); it++) {
if (it != rule_map.begin() &&
0 > putc(' ', stream))
return false;
if (0 > fprintf(stream, "%s: %s", it->first.c_str(), it->second.c_str()))
return false;
}
return true;
}
bool Module::Write(FILE *stream) {
if (0 > fprintf(stream, "MODULE %s %s %s %s\n",
os_.c_str(), architecture_.c_str(), id_.c_str(),
@ -183,6 +206,29 @@ bool Module::Write(FILE *stream) {
return ReportError();
}
// Write out 'STACK CFI INIT' and 'STACK CFI' records.
vector<StackFrameEntry *>::const_iterator frame_it;
for (frame_it = stack_frame_entries_.begin();
frame_it != stack_frame_entries_.end(); frame_it++) {
StackFrameEntry *entry = *frame_it;
if (0 > fprintf(stream, "STACK CFI INIT %llx %llx ",
(unsigned long long) entry->address - load_address_,
(unsigned long long) entry->size)
|| !WriteRuleMap(entry->initial_rules, stream)
|| 0 > putc('\n', stream))
return ReportError();
// Write out this entry's delta rules as 'STACK CFI' records.
for (RuleChangeMap::const_iterator delta_it = entry->rule_changes.begin();
delta_it != entry->rule_changes.end(); delta_it++) {
if (0 > fprintf(stream, "STACK CFI %llx ",
(unsigned long long) delta_it->first - load_address_)
|| !WriteRuleMap(delta_it->second, stream)
|| 0 > putc('\n', stream))
return ReportError();
}
}
return true;
}