From 16e08520e6027df4bf1934abbfd5e1a088ffb69c Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Sat, 4 Aug 2018 00:59:34 +0200 Subject: Add support for parsing the DW_AT_ranges attributes This enables the DWARF reader to properly parse DW_AT_ranges attributes in compilation units and functions. Code covered by a function is now represented by a vector of ranges instead of a single contiguous range and DW_AT_ranges entries are used to populate it. All the code and tests that assumed functions to be contiguous entities has been updated to reflect the change. DW_AT_ranges attributes found in compilation units are parsed but no data is generated for them as it is not currently needed. BUG=754 Change-Id: I310391b525aaba0dd329f1e3187486f2e0c6d442 Reviewed-on: https://chromium-review.googlesource.com/1124721 Reviewed-by: Ted Mielczarek --- src/common/dwarf_cu_to_module.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/common/dwarf_cu_to_module.h') diff --git a/src/common/dwarf_cu_to_module.h b/src/common/dwarf_cu_to_module.h index a36b82b0..c1135dd0 100644 --- a/src/common/dwarf_cu_to_module.h +++ b/src/common/dwarf_cu_to_module.h @@ -123,6 +123,22 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { scoped_ptr file_private_; }; + // An abstract base class for handlers that handle DWARF range lists for + // DwarfCUToModule. + class RangesHandler { + public: + RangesHandler() { } + virtual ~RangesHandler() { } + + // Called when finishing a function to populate the function's ranges. + // The ranges' entries are read starting from offset in the .debug_ranges + // section, base_address holds the base PC the range list values are + // offsets off. Return false if the rangelist falls out of the + // .debug_ranges section. + virtual bool ReadRanges(uint64 offset, Module::Address base_address, + vector* ranges) = 0; + }; + // An abstract base class for handlers that handle DWARF line data // for DwarfCUToModule. DwarfCUToModule could certainly just use // dwarf2reader::LineInfo itself directly, but decoupling things @@ -208,6 +224,14 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // FilePrivate did not retain the inter-CU specification data. virtual void UnhandledInterCUReference(uint64 offset, uint64 target); + // The DW_AT_ranges at offset is malformed (truncated or outside of the + // .debug_ranges section's bound). + virtual void MalformedRangeList(uint64 offset); + + // A DW_AT_ranges attribute was encountered but the no .debug_ranges + // section was found. + virtual void MissingRanges(); + uint64 cu_offset() const { return cu_offset_; } @@ -235,6 +259,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // data we find. DwarfCUToModule(FileContext *file_context, LineToModuleHandler *line_reader, + RangesHandler *ranges_handler, WarningReporter *reporter); ~DwarfCUToModule(); @@ -296,6 +321,9 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // The handler to use to handle line number data. LineToModuleHandler *line_reader_; + // The handler to use to handle range lists. + RangesHandler *ranges_handler_; + // This compilation unit's context. scoped_ptr cu_context_; -- cgit v1.2.1