]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Fail check_debug_info test if serious error turns up
authorPetr Machata <pmachata@redhat.com>
Wed, 2 Mar 2011 20:32:38 +0000 (21:32 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 2 Mar 2011 20:32:38 +0000 (21:32 +0100)
- All the tracking was in place, we just forgot to actually throw the
  exception in the end.

dwarflint/check_debug_info.cc
dwarflint/check_debug_info.hh

index c839d77b5412b739a2246cf6f0b7faebb20f2346..59792d5c3881abd39881e52acb3b5e295a95fe99 100644 (file)
@@ -970,8 +970,12 @@ check_debug_info::check_cu_structural (struct read_ctx *ctx,
   return retval;
 }
 
-void
-check_debug_info::check_info_structural ()
+check_debug_info::check_debug_info (checkstack &stack, dwarflint &lint)
+  : _m_sec_info (lint.check (stack, _m_sec_info))
+  , _m_sec_str (lint.check (stack, _m_sec_str))
+  , _m_file (_m_sec_info->file)
+  , _m_abbrevs (lint.check (stack, _m_abbrevs))
+  , _m_cu_headers (lint.check (stack, _m_cu_headers))
 {
   std::vector <cu_head> const &cu_headers = _m_cu_headers->cu_headers;
   sec &sec = _m_sec_info->sect;
@@ -1069,26 +1073,27 @@ check_debug_info::check_info_structural ()
                << ": abbreviation is never used." << std::endl;
     }
 
-  // Relink the CU chain.
+  // re-link CUs so that they form a chain again.  This is to
+  // interface with legacy code.
   {
     cu *last = NULL;
     for (std::vector<cu>::iterator it = cus.begin ();
         it != cus.end (); ++it)
       {
+       cu *cur = &*it;
        if (last != NULL)
-         last->next = &*it;
-       last = &*it;
+         last->next = cur;
+       last = cur;
       }
     if (last != NULL)
       last->next = NULL;
   }
 
-
   /* We used to check that all CUs have the same address size.  Now
      that we validate address_size of each CU against the ELF header,
      that's not necessary anymore.  */
 
-  check_global_die_references (&cus.front ());
+  check_global_die_references (!cus.empty () ? &cus.front () : NULL);
   ref_record_free (&die_refs);
 
   if (strings_coverage != NULL)
@@ -1100,29 +1105,10 @@ check_debug_info::check_info_structural ()
        }
       delete strings_coverage;
     }
-}
-
-check_debug_info::check_debug_info (checkstack &stack, dwarflint &lint)
-  : _m_sec_info (lint.check (stack, _m_sec_info))
-  , _m_sec_str (lint.check (stack, _m_sec_str))
-  , _m_file (_m_sec_info->file)
-  , _m_abbrevs (lint.check (stack, _m_abbrevs))
-  , _m_cu_headers (lint.check (stack, _m_cu_headers))
-{
-  check_info_structural ();
 
-  // re-link CUs so that they form a chain again.  This is to
-  // interface with C-level code.  The last CU's next is NULL, so we
-  // don't have to re-link it.
-  cu *last = NULL;
-  for (std::vector<cu>::iterator it = cus.begin ();
-       it != cus.end (); ++it)
-    {
-      cu *cur = &*it;
-      if (last != NULL)
-       last->next = cur;
-      last = cur;
-    }
+  // If we were unsuccessful, fail now.
+  if (!success)
+    throw check_base::failed ();
 
   if (cus.size () > 0)
     assert (cus.back ().next == NULL);
index 714b6499ad0618536592e0d8c4712d3863fd388f..8febc2d5d5bc61d10f4d13939507fdda38e5b731 100644 (file)
@@ -1,5 +1,5 @@
 /* Low-level checking of .debug_info.
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010, 2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -110,8 +110,6 @@ class check_debug_info
                            struct coverage *strings_coverage,
                            struct relocation_data *reloc);
 
-  void check_info_structural ();
-
 public:
   static checkdescriptor const *descriptor ();