From: Petr Machata Date: Tue, 7 Sep 2010 12:28:24 +0000 (+0200) Subject: dwarflint: Check for unresolved references from .debug_info to .debug_line X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9eb0ab7c08d30c34119921d941b443ead86f6d6;p=thirdparty%2Felfutils.git dwarflint: Check for unresolved references from .debug_info to .debug_line - while this check has already been there, it was part of .debug_line. If .debug_line was entirely missing or broken, the check would never be run. Now the check is in a separate pass. --- diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index 25ff93351..631083e0b 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -39,8 +39,9 @@ #include "check_debug_loc_range.hh" #include "check_debug_abbrev.hh" #include "check_debug_info.hh" +#include "check_debug_line.hh" -checkdescriptor +checkdescriptor const & read_cu_headers::descriptor () { static checkdescriptor cd @@ -51,7 +52,7 @@ read_cu_headers::descriptor () static reg reg_debug_info; -checkdescriptor +checkdescriptor const & check_debug_info::descriptor () { static checkdescriptor cd @@ -63,7 +64,6 @@ check_debug_info::descriptor () .prereq () .prereq () .description ( - "Checks for low-level structure of .debug_info. In addition it\n" "checks:\n" " - for dangling reference to .debug_abbrev section\n" @@ -1273,3 +1273,34 @@ check_debug_info::find_cu (::Dwarf_Off offset) return NULL; } + +checkdescriptor const & +check_debug_info_refs::descriptor () +{ + static checkdescriptor cd + (checkdescriptor::create ("check_debug_info_refs") + .groups ("@low") + .prereq () + .prereq () + .description ( +"This pass checks for outstanding unresolved references from\n" +".debug_info to .debug_line (and perhaps others as they are\n" +"identified).\n")); + return cd; +} + +check_debug_info_refs::check_debug_info_refs (checkstack &stack, + dwarflint &lint) + : _m_info (lint.check (stack, _m_info)) + , _m_line (lint.toplev_check (stack, _m_line)) +{ + for (std::vector::iterator it = _m_info->cus.begin (); + it != _m_info->cus.end (); ++it) + if (it->stmt_list.addr != (uint64_t)-1 + && (_m_line == NULL + || !_m_line->has_line_table (it->stmt_list.addr))) + wr_error (it->stmt_list.who) + << "unresolved reference to .debug_line table " + << pri::hex (it->stmt_list.addr) << '.' << std::endl; +} +static reg reg_debug_info_refs; diff --git a/dwarflint/check_debug_info.hh b/dwarflint/check_debug_info.hh index 2e2e8fef7..81827126f 100644 --- a/dwarflint/check_debug_info.hh +++ b/dwarflint/check_debug_info.hh @@ -29,6 +29,7 @@ #include "low.h" #include "checks.hh" #include "check_debug_abbrev.ii" +#include "check_debug_line.ii" #include "sections.ii" /** The pass for reading basic .debug_info data -- the layout of @@ -39,7 +40,7 @@ class read_cu_headers section *_m_sec_info; public: - static checkdescriptor descriptor (); + static checkdescriptor const &descriptor (); std::vector const cu_headers; read_cu_headers (checkstack &stack, dwarflint &lint); }; @@ -77,7 +78,7 @@ class check_debug_info void check_info_structural (); public: - static checkdescriptor descriptor (); + static checkdescriptor const &descriptor (); coverage const &cov () const { return _m_cov; } bool need_ranges () const { return _m_need_ranges; } @@ -91,4 +92,17 @@ public: cu *find_cu (::Dwarf_Off offset); }; +/** Check pending references that need other sections to be validated + first. */ +class check_debug_info_refs + : public check +{ + check_debug_info *_m_info; + check_debug_line *_m_line; + +public: + static checkdescriptor const &descriptor (); + check_debug_info_refs (checkstack &stack, dwarflint &lint); +}; + #endif//DWARFLINT_CHECK_DEBUG_INFO_HH diff --git a/dwarflint/check_debug_info.ii b/dwarflint/check_debug_info.ii index bd0ae5a90..70c4cbae8 100644 --- a/dwarflint/check_debug_info.ii +++ b/dwarflint/check_debug_info.ii @@ -1,2 +1,3 @@ class read_cu_headers; class check_debug_info; +class check_debug_info_refs;