From: Petr Machata Date: Fri, 18 Mar 2011 00:12:34 +0000 (+0100) Subject: dwarflint: Catch and report exceptions thrown in checks X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=290413c6be1bb320e0e8d067cedba0840dee86e8;p=thirdparty%2Felfutils.git dwarflint: Catch and report exceptions thrown in checks --- diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index 11e5770d8..6bff11bf0 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 cba9271dd..a29f83cbc 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 #include @@ -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");