]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Check for unresolved references from .debug_info to .debug_line
authorPetr Machata <pmachata@redhat.com>
Tue, 7 Sep 2010 12:28:24 +0000 (14:28 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 7 Sep 2010 12:28:24 +0000 (14:28 +0200)
- 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.

dwarflint/check_debug_info.cc
dwarflint/check_debug_info.hh
dwarflint/check_debug_info.ii

index 25ff933515525acce6c6bdf316205411e157b7a4..631083e0b55fbe2182f6f054d9f1edd66c4a6a38 100644 (file)
@@ -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<check_debug_info> reg_debug_info;
 
-checkdescriptor
+checkdescriptor const &
 check_debug_info::descriptor ()
 {
   static checkdescriptor cd
@@ -63,7 +64,6 @@ check_debug_info::descriptor ()
      .prereq<typeof (*_m_abbrevs)> ()
      .prereq<typeof (*_m_cu_headers)> ()
      .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<typeof (*_m_info)> ()
+     .prereq<typeof (*_m_line)> ()
+     .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<cu>::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<check_debug_info_refs> reg_debug_info_refs;
index 2e2e8fef73b1b1ad294a53a856fdbc337fb0615a..81827126fec43f547930a4014427d223a25d4e30 100644 (file)
@@ -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<sec_info> *_m_sec_info;
 
 public:
-  static checkdescriptor descriptor ();
+  static checkdescriptor const &descriptor ();
   std::vector<cu_head> 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_refs>
+{
+  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
index bd0ae5a903bca080d4180a762a706ac087d093db..70c4cbae83294130bd2c92b5e78d7bd8877d3541 100644 (file)
@@ -1,2 +1,3 @@
 class read_cu_headers;
 class check_debug_info;
+class check_debug_info_refs;