]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Catch and report exceptions thrown in checks
authorPetr Machata <pmachata@redhat.com>
Fri, 18 Mar 2011 00:12:34 +0000 (01:12 +0100)
committerPetr Machata <pmachata@redhat.com>
Fri, 18 Mar 2011 00:12:34 +0000 (01:12 +0100)
dwarflint/check_debug_info.cc
dwarflint/checks.hh

index 11e5770d8d7c9f67272d827c496e1adf0070781e..6bff11bf0eb5442acabe2f9826e1bce9944664fc 100644 (file)
@@ -628,9 +628,6 @@ namespace
 
        prev_die_off = die_off;
        got_die = true;
-       if (dump_die_offsets)
-         std::cerr << "[" << level << "] "
-                   << where << ": abbrev " << abbr_code << std::endl;
 
        /* Find the abbrev matching the code.  */
        abbrev = abbrevs->find_abbrev (abbr_code);
@@ -643,6 +640,11 @@ namespace
          }
        abbrev->used = true;
 
+       if (dump_die_offsets)
+         std::cerr << "[" << level << "] "
+                   << where << ": abbrev " << abbr_code
+                   << "; DIE tag 0x" << std::hex << abbrev->tag << std::endl;
+
        // DWARF 4 Ch. 7.5: compilation unit header [is] followed by a
        // single DW_TAG_compile_unit or DW_TAG_partial_unit.
        bool is_cudie = level == 0
index cba9271dd2009a8c2ae22f41962ee470171e9192..a29f83cbc7e227495f47b9b7abbd1312973ed77c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
@@ -29,6 +29,7 @@
 #include "where.h"
 #include "dwarflint.hh"
 #include "checkdescriptor.hh"
+#include "messages.hh"
 #include <string>
 #include <cassert>
 
@@ -84,6 +85,11 @@ dwarflint::check (checkstack &stack)
        = _m_checks.insert (std::make_pair (key, (T *)marker)).second;
       assert (inserted || !"duplicate key");
 
+#define FAIL                                   \
+      /* Put the anchor in the table.  */      \
+       _m_checks[key] = NULL;                  \
+       report ("FAIL")
+
       reporter report (stack, cd);
       try
        {
@@ -102,13 +108,28 @@ dwarflint::check (checkstack &stack)
          _m_checks.erase (key);
          throw;
        }
-      catch (...)
+      catch (check_base::failed &e)
        {
-         // Nope, we failed.  Put the anchor there.
-         _m_checks[key] = NULL;
-         report ("FAIL");
+         // We can assume that the check emitted error message.
+         FAIL;
          throw;
        }
+      catch (std::exception &e)
+       {
+         wr_error () << "A check failed: " << (cd.name () ?: "(nil)") << ": "
+                     << e.what () << std::endl;
+         FAIL;
+         throw check_base::failed ();
+       }
+      catch (...)
+       {
+         wr_error () << "A check failed: " << (cd.name () ?: "(nil)") << "."
+                     << std::endl;
+         FAIL;
+         throw check_base::failed ();
+       }
+
+#undef FAIL
 
       report ("done");