Skip to content

Commit

Permalink
Code cleanup for DwarfCUToModule::NullWarningReporter changes.
Browse files Browse the repository at this point in the history
Updated code to use Google's modern C++ style.

* Use std::unique_ptr to allocate DwarfCUToModule::WarningReporter.
* Fixed reference alignment in NullWarningReporter.

Change-Id: I230dac445a07b4023a64284b907010f31eadcdf4
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/5265662
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Ivan Penkov <[email protected]>
  • Loading branch information
nmoinvaz authored and Ivan Penkov committed Feb 5, 2024
1 parent 38ac9ae commit 6b871f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/common/dwarf_cu_to_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,61 +254,61 @@ class DwarfCUToModule: public RootDIEHandler {
void UncoveredHeading();
};

class NullWarningReporter: public WarningReporter {
class NullWarningReporter : public WarningReporter {
public:
NullWarningReporter(const string &filename, uint64_t cu_offset):
WarningReporter(filename, cu_offset) { }
NullWarningReporter(const string& filename, uint64_t cu_offset)
: WarningReporter(filename, cu_offset) {}

// Set the name of the compilation unit we're processing to NAME.
void SetCUName(const string &name) { }
void SetCUName(const string& 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.
void set_uncovered_warnings_enabled(bool value) { }
void set_uncovered_warnings_enabled(bool value) {}

// 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,
// at TARGET.
void UnknownSpecification(uint64_t offset, uint64_t target) { }
void UnknownSpecification(uint64_t offset, uint64_t target) {}

// A DW_AT_abstract_origin in the DIE at OFFSET refers to a DIE we
// haven't processed yet, or that wasn't marked as inline, at TARGET.
void UnknownAbstractOrigin(uint64_t offset, uint64_t target) { }
void UnknownAbstractOrigin(uint64_t offset, uint64_t target) {}

// We were unable to find the DWARF section named SECTION_NAME.
void MissingSection(const string &section_name) { }
void MissingSection(const string& section_name) {}

// The CU's DW_AT_stmt_list offset OFFSET is bogus.
void BadLineInfoOffset(uint64_t offset) { }
void BadLineInfoOffset(uint64_t offset) {}

// FUNCTION includes code covered by no line number data.
void UncoveredFunction(const Module::Function &function) { }
void UncoveredFunction(const Module::Function& function) {}

// Line number NUMBER in LINE_FILE, of length LENGTH, includes code
// covered by no function.
void UncoveredLine(const Module::Line &line) { }
void UncoveredLine(const Module::Line& line) {}

// The DW_TAG_subprogram DIE at OFFSET has no name specified directly
// in the DIE, nor via a DW_AT_specification or DW_AT_abstract_origin
// link.
void UnnamedFunction(uint64_t offset) { }
void UnnamedFunction(uint64_t offset) {}

// __cxa_demangle() failed to demangle INPUT.
void DemangleError(const string &input) { }
void DemangleError(const string& input) {}

// The DW_FORM_ref_addr at OFFSET to TARGET was not handled because
// FilePrivate did not retain the inter-CU specification data.
void UnhandledInterCUReference(uint64_t offset, uint64_t target) { }
void UnhandledInterCUReference(uint64_t offset, uint64_t target) {}

// The DW_AT_ranges at offset is malformed (truncated or outside of the
// .debug_ranges section's bound).
void MalformedRangeList(uint64_t offset) { }
void MalformedRangeList(uint64_t offset) {}

// A DW_AT_ranges attribute was encountered but the no .debug_ranges
// section was found.
void MissingRanges() { }
void MissingRanges() {}
};

// Create a DWARF debugging info handler for a compilation unit
Expand Down
11 changes: 5 additions & 6 deletions src/common/mac/dump_syms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,13 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module* module,
for (uint64_t offset = 0; offset < debug_info_length;) {
// Make a handler for the root DIE that populates MODULE with the
// debug info.
DwarfCUToModule::WarningReporter *reporter = nullptr;
std::unique_ptr<DwarfCUToModule::WarningReporter> reporter;
if (report_warnings_) {
reporter = new DwarfCUToModule::WarningReporter(
selected_object_name_, offset);
reporter = std::make_unique<DwarfCUToModule::WarningReporter>(
selected_object_name_, offset);
} else {
reporter = new DwarfCUToModule::NullWarningReporter(
selected_object_name_, offset);
reporter = std::make_unique<DwarfCUToModule::NullWarningReporter>(
selected_object_name_, offset);
}
DwarfCUToModule root_handler(&file_context, &line_to_module,
&ranges_handler, reporter,
Expand All @@ -554,7 +554,6 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module* module,
StartProcessSplitDwarf(&dwarf_reader, module, endianness,
handle_inter_cu_refs, handle_inline);
}
delete reporter;
}
}

Expand Down

0 comments on commit 6b871f4

Please sign in to comment.