Breakpad Linux dumper: Tolerate STABS data from code linked with --gc-sections.
Programs compiled with -ffunction-sections -Wl,--gc-sections may have SO entries for the start of the compilation unit whose addresses are zero, even when the compilation unit contains non-omitted functions at non-zero addresses. The breakpad dumper should not assume that the compilation unit starting address is always non-zero. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@542 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
de545c09d0
commit
81aadb99a6
3 changed files with 26 additions and 2 deletions
|
@ -58,7 +58,8 @@ static string Demangle(const string &mangled) {
|
||||||
|
|
||||||
bool DumpStabsHandler::StartCompilationUnit(const char *name, uint64_t address,
|
bool DumpStabsHandler::StartCompilationUnit(const char *name, uint64_t address,
|
||||||
const char *build_directory) {
|
const char *build_directory) {
|
||||||
assert(!comp_unit_base_address_);
|
assert(!in_compilation_unit_);
|
||||||
|
in_compilation_unit_ = true;
|
||||||
current_source_file_name_ = name;
|
current_source_file_name_ = name;
|
||||||
current_source_file_ = module_->FindFile(name);
|
current_source_file_ = module_->FindFile(name);
|
||||||
comp_unit_base_address_ = address;
|
comp_unit_base_address_ = address;
|
||||||
|
@ -67,7 +68,8 @@ bool DumpStabsHandler::StartCompilationUnit(const char *name, uint64_t address,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DumpStabsHandler::EndCompilationUnit(uint64_t address) {
|
bool DumpStabsHandler::EndCompilationUnit(uint64_t address) {
|
||||||
assert(comp_unit_base_address_);
|
assert(in_compilation_unit_);
|
||||||
|
in_compilation_unit_ = false;
|
||||||
comp_unit_base_address_ = 0;
|
comp_unit_base_address_ = 0;
|
||||||
current_source_file_ = NULL;
|
current_source_file_ = NULL;
|
||||||
current_source_file_name_ = NULL;
|
current_source_file_name_ = NULL;
|
||||||
|
|
|
@ -63,6 +63,7 @@ class DumpStabsHandler: public google_breakpad::StabsHandler {
|
||||||
// store it all in MODULE.
|
// store it all in MODULE.
|
||||||
DumpStabsHandler(Module *module) :
|
DumpStabsHandler(Module *module) :
|
||||||
module_(module),
|
module_(module),
|
||||||
|
in_compilation_unit_(false),
|
||||||
comp_unit_base_address_(0),
|
comp_unit_base_address_(0),
|
||||||
current_function_(NULL),
|
current_function_(NULL),
|
||||||
current_source_file_(NULL),
|
current_source_file_(NULL),
|
||||||
|
@ -109,6 +110,11 @@ class DumpStabsHandler: public google_breakpad::StabsHandler {
|
||||||
// finding the next object.
|
// finding the next object.
|
||||||
vector<Module::Address> boundaries_;
|
vector<Module::Address> boundaries_;
|
||||||
|
|
||||||
|
// True if we are currently within a compilation unit: we have gotten a
|
||||||
|
// StartCompilationUnit call, but no matching EndCompilationUnit call
|
||||||
|
// yet. We use this for sanity checks.
|
||||||
|
bool in_compilation_unit_;
|
||||||
|
|
||||||
// The base address of the current compilation unit. We use this to
|
// The base address of the current compilation unit. We use this to
|
||||||
// recognize functions we should omit from the symbol file. (If you
|
// recognize functions we should omit from the symbol file. (If you
|
||||||
// know the details of why we omit these, please patch this
|
// know the details of why we omit these, please patch this
|
||||||
|
|
|
@ -157,6 +157,22 @@ TEST(FunctionNames, Mangled) {
|
||||||
ASSERT_EQ(0U, function->lines.size());
|
ASSERT_EQ(0U, function->lines.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The GNU toolchain can omit functions that are not used; however,
|
||||||
|
// when it does so, it doesn't clean up the debugging information that
|
||||||
|
// refers to them. In STABS, this results in compilation units whose
|
||||||
|
// SO addresses are zero.
|
||||||
|
TEST(Omitted, Function) {
|
||||||
|
Module m("name", "os", "arch", "id");
|
||||||
|
DumpStabsHandler h(&m);
|
||||||
|
|
||||||
|
// The StartCompilationUnit and EndCompilationUnit calls may both have an
|
||||||
|
// address of zero if the compilation unit has had sections removed.
|
||||||
|
EXPECT_TRUE(h.StartCompilationUnit("compilation-unit", 0, "build-directory"));
|
||||||
|
EXPECT_TRUE(h.StartFunction("function", 0x2a133596));
|
||||||
|
EXPECT_TRUE(h.EndFunction(0));
|
||||||
|
EXPECT_TRUE(h.EndCompilationUnit(0));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO --- if we actually cared about STABS. Even without these we've
|
// TODO --- if we actually cared about STABS. Even without these we've
|
||||||
// got full coverage of non-failure source lines in dump_stabs.cc.
|
// got full coverage of non-failure source lines in dump_stabs.cc.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue