Breakpad Linux Dumper: Disable warnings about unpaired functions and lines by default.

In the process of pairing up DWARF source lines with the functions they
belong to, the dumper detects and warns about regions of functions that
have no source line information, and vice versa. However, this seems to
occur in real code frequently enough (although not often) that the warnings
may obscure more serious problems.

This patch makes those warnings disabled by default in
DwarfCUToModule::WarningReporter. It does not add a way for the dump_syms
user to enable them.

a=jimblandy, r=nealsid


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@566 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
jimblandy 2010-04-05 19:35:10 +00:00
parent 5c27539f91
commit 9e6b619ad0
3 changed files with 82 additions and 1 deletions

View file

@ -493,6 +493,8 @@ void DwarfCUToModule::WarningReporter::UncoveredHeading() {
void DwarfCUToModule::WarningReporter::UncoveredFunction( void DwarfCUToModule::WarningReporter::UncoveredFunction(
const Module::Function &function) { const Module::Function &function) {
if (!uncovered_warnings_enabled_)
return;
UncoveredHeading(); UncoveredHeading();
fprintf(stderr, " function%s: %s\n", fprintf(stderr, " function%s: %s\n",
function.size == 0 ? " (zero-length)" : "", function.size == 0 ? " (zero-length)" : "",
@ -500,6 +502,8 @@ void DwarfCUToModule::WarningReporter::UncoveredFunction(
} }
void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) { void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) {
if (!uncovered_warnings_enabled_)
return;
UncoveredHeading(); UncoveredHeading();
fprintf(stderr, " line%s: %s:%d at 0x%llx\n", fprintf(stderr, " line%s: %s:%d at 0x%llx\n",
(line.size == 0 ? " (zero-length)" : ""), (line.size == 0 ? " (zero-length)" : ""),

View file

@ -120,12 +120,24 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
// compilation unit at OFFSET. // compilation unit at OFFSET.
WarningReporter(const string &filename, uint64 cu_offset) WarningReporter(const string &filename, uint64 cu_offset)
: filename_(filename), cu_offset_(cu_offset), printed_cu_header_(false), : filename_(filename), cu_offset_(cu_offset), printed_cu_header_(false),
printed_unpaired_header_(false) { } printed_unpaired_header_(false),
uncovered_warnings_enabled_(false) { }
virtual ~WarningReporter() { } virtual ~WarningReporter() { }
// Set the name of the compilation unit we're processing to NAME. // Set the name of the compilation unit we're processing to NAME.
virtual void SetCUName(const string &name) { cu_name_ = name; } virtual void SetCUName(const string &name) { cu_name_ = name; }
// Accessor and setter for uncovered_warnings_enabled_.
// UncoveredFunction and UncoveredLine only report a problem if that is
// true. By default, these warnings are disabled, because those
// conditions occur occasionally in healthy code.
virtual bool uncovered_warnings_enabled() const {
return uncovered_warnings_enabled_;
}
virtual void set_uncovered_warnings_enabled(bool value) {
uncovered_warnings_enabled_ = value;
}
// A DW_AT_specification in the DIE at OFFSET refers to a DIE we // A DW_AT_specification in the DIE at OFFSET refers to a DIE we
// haven't processed yet, or that wasn't marked as a declaration, // haven't processed yet, or that wasn't marked as a declaration,
// at TARGET. // at TARGET.
@ -154,6 +166,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
string cu_name_; string cu_name_;
bool printed_cu_header_; bool printed_cu_header_;
bool printed_unpaired_header_; bool printed_unpaired_header_;
bool uncovered_warnings_enabled_;
private: private:
// Print a per-CU heading, once. // Print a per-CU heading, once.

View file

@ -1633,5 +1633,69 @@ TEST_F(Errors, BadCURootDIETag) {
no_attrs)); no_attrs));
} }
// Tests for DwarfCUToModule::Reporter. These just produce (or fail to
// produce) output, so their results need to be checked by hand.
struct Reporter: public Test {
Reporter()
: reporter("filename", 0x123456789abcdef0ULL) {
reporter.SetCUName("compilation-unit-name");
function.name = "function name";
function.address = 0x19c45c30770c1eb0ULL;
function.size = 0x89808a5bdfa0a6a3ULL;
function.parameter_size = 0x6a329f18683dcd51ULL;
file.name = "source file name";
line.address = 0x3606ac6267aebeccULL;
line.size = 0x5de482229f32556aULL;
line.file = &file;
line.number = 93400201;
}
DwarfCUToModule::WarningReporter reporter;
Module::Function function;
Module::File file;
Module::Line line;
};
TEST_F(Reporter, UnknownSpecification) {
reporter.UnknownSpecification(0x123456789abcdef1ULL, 0x323456789abcdef2ULL);
}
TEST_F(Reporter, UnknownAbstractOrigin) {
reporter.UnknownAbstractOrigin(0x123456789abcdef1ULL, 0x323456789abcdef2ULL);
}
TEST_F(Reporter, MissingSection) {
reporter.MissingSection("section name");
}
TEST_F(Reporter, BadLineInfoOffset) {
reporter.BadLineInfoOffset(0x123456789abcdef1ULL);
}
TEST_F(Reporter, UncoveredFunctionDisabled) {
reporter.UncoveredFunction(function);
EXPECT_FALSE(reporter.uncovered_warnings_enabled());
}
TEST_F(Reporter, UncoveredFunctionEnabled) {
reporter.set_uncovered_warnings_enabled(true);
reporter.UncoveredFunction(function);
EXPECT_TRUE(reporter.uncovered_warnings_enabled());
}
TEST_F(Reporter, UncoveredLineDisabled) {
reporter.UncoveredLine(line);
EXPECT_FALSE(reporter.uncovered_warnings_enabled());
}
TEST_F(Reporter, UncoveredLineEnabled) {
reporter.set_uncovered_warnings_enabled(true);
reporter.UncoveredLine(line);
EXPECT_TRUE(reporter.uncovered_warnings_enabled());
}
// Would be nice to also test: // Would be nice to also test:
// - overlapping lines, functions // - overlapping lines, functions