summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2011-03-18 01:12:34 +0100
committerPetr Machata <[email protected]>2011-03-18 01:12:34 +0100
commit290413c6be1bb320e0e8d067cedba0840dee86e8 (patch)
tree6ebecd596edbe1b1239102e92e4ed469fea17bea
parentecece746acee6967ef3aefcbfd79a8755715a7a8 (diff)
dwarflint: Catch and report exceptions thrown in checks
-rw-r--r--dwarflint/check_debug_info.cc8
-rw-r--r--dwarflint/checks.hh31
2 files changed, 31 insertions, 8 deletions
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc
index 11e5770d..6bff11bf 100644
--- a/dwarflint/check_debug_info.cc
+++ b/dwarflint/check_debug_info.cc
@@ -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
diff --git a/dwarflint/checks.hh b/dwarflint/checks.hh
index cba9271d..a29f83cb 100644
--- a/dwarflint/checks.hh
+++ b/dwarflint/checks.hh
@@ -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");