From aa67698e23bcffd74a678662ff674e761ff4d984 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 3 Mar 2011 17:02:47 +0100 Subject: [PATCH] dwarflint: Be lazy when looking into CU headers for check_debug_abbrev - And so don't complain that we have no headers in cases where we have no abbrevs either. - Also consider no abbrevs a message, not an error - Add a test case for the same --- dwarflint/check_debug_abbrev.cc | 22 ++++++++++++++-------- dwarflint/tests/null.o.bz2 | Bin 0 -> 343 bytes dwarflint/tests/run-nodebug.sh | 12 ++++++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 dwarflint/tests/null.o.bz2 diff --git a/dwarflint/check_debug_abbrev.cc b/dwarflint/check_debug_abbrev.cc index 8d413fc60..f2383319f 100644 --- a/dwarflint/check_debug_abbrev.cc +++ b/dwarflint/check_debug_abbrev.cc @@ -125,10 +125,15 @@ namespace check_no_abbreviations (check_debug_abbrev::abbrev_map const &abbrevs) { bool ret = abbrevs.begin () == abbrevs.end (); + + // It's not an error when the abbrev table contains no abbrevs. + // But since we got here, apparently there was a .debug_abbrev + // section with size of more than 0 bytes, which is wasteful. if (ret) { where wh = WHERE (sec_abbrev, NULL); - wr_error (&wh, ": no abbreviations.\n"); + wr_message (wh, cat (mc_abbrevs, mc_impact_1, mc_acc_bloat)) + << "no abbreviations." << std::endl; } return ret; } @@ -148,13 +153,6 @@ namespace // Tolerate failure here. dwarf_version const *ver = NULL; - if (cu_headers == NULL) - { - wr_error (where) - << "couldn't load CU headers; assuming CUs are of latest DWARF flavor." - << std::endl; - ver = dwarf_version::get_latest (); - } where.addr1 = 0; bool failed = false; @@ -277,6 +275,14 @@ namespace ver = dwarf_version::get_latest (); } } + else if (ver == NULL) + { + wr_error (where) + << "couldn't load CU headers; assuming CUs are of latest DWARF flavor." + << std::endl; + ver = dwarf_version::get_latest (); + } + assert (ver != NULL); } diff --git a/dwarflint/tests/null.o.bz2 b/dwarflint/tests/null.o.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..f272d5a7471770602bdbfeb3536125dcd293cb5d GIT binary patch literal 343 zc-jG10jT~$T4*^jL0KkKSrd_@6954te}n)1=tyYib}?_o5(vNVpJ2cMKmcF>umKhr z8iHw}G+_V$001-q27!bW(^E+G9;S@|44D8801XC=ngbw6q$%opo}<(NGGuz5paUR! zC#V2DKo^d6282@ZAFxE%QJMrvK*=S+BH&Q~3Ezxikv(KgSc{bzm2qLkw@rHUG0{!f zz>T-DyM7=M83%Gr=84+|>X zg1*icj2BXXAGt~aD@t}Ykf&%+vaD6!)AX8W)Jx?Q^F?7Hdn6Q=bXYn2Bdp;85;(83 zf`qJ71anp-c0Wk$byy`G#P39+1I2otU@^(0Lzu+_qE#mEuc(L!?wKuoIncYYRS<@o peg+ws*llCnG$n~M#McVDi7<>rvJYXxXgBZT?ntK!5(08Gf?(S6k~;tZ literal 0 Hc-jL100001 diff --git a/dwarflint/tests/run-nodebug.sh b/dwarflint/tests/run-nodebug.sh index 5bfc2c552..049bf5708 100755 --- a/dwarflint/tests/run-nodebug.sh +++ b/dwarflint/tests/run-nodebug.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2010 Red Hat, Inc. +# Copyright (C) 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 @@ -27,7 +27,7 @@ srcdir=$srcdir/tests -testfiles nodebug +testfiles nodebug null.o testrun_compare ./dwarflint nodebug <