From b9578f20fe00eb22980cb618790a699ef2cd04bc Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Wed, 2 Dec 2009 19:26:17 +0100 Subject: [PATCH] dwarflint: Split checks-low.hh/cc into check_debug_aranges.hh/cc and sections.hh/cc/ii --- src/Makefile.am | 5 +- src/dwarflint/check_debug_abbrev.cc | 6 +- src/dwarflint/check_debug_abbrev.hh | 2 - src/dwarflint/check_debug_aranges.cc | 58 ++++++++++++++++++++ src/dwarflint/check_debug_aranges.hh | 43 +++++++++++++++ src/dwarflint/check_debug_info.cc | 1 + src/dwarflint/check_debug_info.hh | 4 +- src/dwarflint/check_debug_line.cc | 27 ++++++++- src/dwarflint/check_debug_loc_range.cc | 1 + src/dwarflint/check_debug_loc_range.hh | 8 ++- src/dwarflint/check_debug_pub.cc | 27 ++++++++- src/dwarflint/check_dups_abstract_origin.cc | 1 + src/dwarflint/check_matching_ranges.cc | 1 + src/dwarflint/highlevel_check.cc | 1 + src/dwarflint/highlevel_check.hh | 2 +- src/dwarflint/main.cc | 1 - src/dwarflint/{checks-low.cc => sections.cc} | 42 +++----------- src/dwarflint/{checks-low.hh => sections.hh} | 24 +++----- src/dwarflint/sections.ii | 1 + 19 files changed, 190 insertions(+), 65 deletions(-) create mode 100644 src/dwarflint/check_debug_aranges.cc create mode 100644 src/dwarflint/check_debug_aranges.hh rename src/dwarflint/{checks-low.cc => sections.cc} (92%) rename src/dwarflint/{checks-low.hh => sections.hh} (82%) create mode 100644 src/dwarflint/sections.ii diff --git a/src/Makefile.am b/src/Makefile.am index 086e5c0e8..26486b02f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -89,18 +89,19 @@ dwarflint_SOURCES = dwarfstrings.c \ dwarflint/messages.cc dwarflint/messages.h \ dwarflint/where.c dwarflint/where.h \ dwarflint/config.cc dwarflint/config.h \ - dwarflint/checks.hh \ - dwarflint/checks-low.cc dwarflint/checks-low.hh \ dwarflint/addr-record.cc dwarflint/addr-record.h \ dwarflint/reloc.cc dwarflint/reloc.h \ dwarflint/tables.cc dwarflint/tables.hh dwarflint/tables.h \ dwarflint/all-dies-it.hh \ + dwarflint/checks.hh \ + dwarflint/sections.cc dwarflint/sections.hh dwarflint/sections.ii \ dwarflint/highlevel_check.cc dwarflint/highlevel_check.hh \ dwarflint/check_debug_abbrev.cc dwarflint/check_debug_abbrev.hh dwarflint/check_debug_abbrev.ii \ dwarflint/check_debug_info.cc dwarflint/check_debug_info.hh dwarflint/check_debug_info.ii \ dwarflint/check_debug_line.cc \ dwarflint/check_debug_pub.cc \ dwarflint/check_debug_loc_range.cc dwarflint/check_debug_loc_range.hh \ + dwarflint/check_debug_aranges.cc dwarflint/check_debug_aranges.hh \ dwarflint/check_matching_ranges.cc \ dwarflint/check_range_out_of_scope.cc \ dwarflint/check_expected_trees.cc \ diff --git a/src/dwarflint/check_debug_abbrev.cc b/src/dwarflint/check_debug_abbrev.cc index 2271d2b7c..03e3726dc 100644 --- a/src/dwarflint/check_debug_abbrev.cc +++ b/src/dwarflint/check_debug_abbrev.cc @@ -27,11 +27,11 @@ # include #endif -#include "checks-low.hh" -#include "pri.hh" -#include "tables.hh" #include "check_debug_info.hh" #include "check_debug_abbrev.hh" +#include "pri.hh" +#include "tables.hh" +#include "sections.hh" #include #include diff --git a/src/dwarflint/check_debug_abbrev.hh b/src/dwarflint/check_debug_abbrev.hh index aeb0b9ffd..efa6320a0 100644 --- a/src/dwarflint/check_debug_abbrev.hh +++ b/src/dwarflint/check_debug_abbrev.hh @@ -26,8 +26,6 @@ #ifndef DWARFLINT_CHECK_DEBUG_ABBREV_HH #define DWARFLINT_CHECK_DEBUG_ABBREV_HH -#include "checks-low.hh" - class check_debug_abbrev : public check { diff --git a/src/dwarflint/check_debug_aranges.cc b/src/dwarflint/check_debug_aranges.cc new file mode 100644 index 000000000..41cd4ce73 --- /dev/null +++ b/src/dwarflint/check_debug_aranges.cc @@ -0,0 +1,58 @@ +/* Low-level checking of .debug_aranges. + Copyright (C) 2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "low.h" +#include "sections.hh" +#include "check_debug_aranges.hh" +#include "check_debug_info.hh" +#include "check_debug_loc_range.hh" + +check_debug_aranges::check_debug_aranges (dwarflint &lint) + : _m_sec_aranges (lint.check (_m_sec_aranges)) +{ + check_debug_info *info = lint.toplev_check (); + coverage *cov = NULL; + if (info != NULL) + { + // xxx If need_ranges is true, we have to load ranges first. + // That's a flaw in design of checks, that data should have been + // stored in check_ranges, and that should have been requested + // explicitly. But for the time being... + if (info->cu_cov.need_ranges) + lint.toplev_check (); + if (!info->cu_cov.need_ranges) + cov = &info->cu_cov.cov; + } + + if (!check_aranges_structural (&_m_sec_aranges->file, + &_m_sec_aranges->sect, + info != NULL ? &info->cus.front () : NULL, + cov)) + throw check_base::failed (); +} diff --git a/src/dwarflint/check_debug_aranges.hh b/src/dwarflint/check_debug_aranges.hh new file mode 100644 index 000000000..d2f6f8749 --- /dev/null +++ b/src/dwarflint/check_debug_aranges.hh @@ -0,0 +1,43 @@ +/* Low-level checking of .debug_aranges. + Copyright (C) 2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifndef DWARFLINT_CHECKS_LOW_HH +#define DWARFLINT_CHECKS_LOW_HH + +#include "low.h" +#include "checks.hh" +#include "sections.ii" + +class check_debug_aranges + : public check +{ + section *_m_sec_aranges; + +public: + explicit check_debug_aranges (dwarflint &lint); +}; +static reg reg_debug_aranges; + +#endif//DWARFLINT_CHECKS_LOW_HH diff --git a/src/dwarflint/check_debug_info.cc b/src/dwarflint/check_debug_info.cc index fc3e8c1d0..441f6b69c 100644 --- a/src/dwarflint/check_debug_info.cc +++ b/src/dwarflint/check_debug_info.cc @@ -35,6 +35,7 @@ #include "messages.h" #include "pri.hh" #include "config.h" +#include "sections.hh" #include "check_debug_loc_range.hh" #include "check_debug_abbrev.hh" #include "check_debug_info.hh" diff --git a/src/dwarflint/check_debug_info.hh b/src/dwarflint/check_debug_info.hh index 1f8b7bf86..e82ac7776 100644 --- a/src/dwarflint/check_debug_info.hh +++ b/src/dwarflint/check_debug_info.hh @@ -26,8 +26,10 @@ #ifndef DWARFLINT_CHECK_DEBUG_INFO_HH #define DWARFLINT_CHECK_DEBUG_INFO_HH -#include "checks-low.hh" #include "check_debug_abbrev.ii" +#include "sections.ii" +#include "checks.hh" +#include "low.h" /** The pass for reading basic .debug_info data -- the layout of sections and their headers. */ diff --git a/src/dwarflint/check_debug_line.cc b/src/dwarflint/check_debug_line.cc index 8ff26584c..7b538c87f 100644 --- a/src/dwarflint/check_debug_line.cc +++ b/src/dwarflint/check_debug_line.cc @@ -1,5 +1,30 @@ -#include "checks-low.hh" +/* Low-level checking of .debug_line. + Copyright (C) 2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + #include "check_debug_info.hh" +#include "sections.hh" #include "pri.hh" #include diff --git a/src/dwarflint/check_debug_loc_range.cc b/src/dwarflint/check_debug_loc_range.cc index 8759e0822..26289ae7b 100644 --- a/src/dwarflint/check_debug_loc_range.cc +++ b/src/dwarflint/check_debug_loc_range.cc @@ -40,6 +40,7 @@ #include "config.h" #include "check_debug_loc_range.hh" #include "check_debug_info.hh" +#include "sections.hh" #include "dwarf-opcodes.h" #include "pri.hh" diff --git a/src/dwarflint/check_debug_loc_range.hh b/src/dwarflint/check_debug_loc_range.hh index 086c455e0..31373288b 100644 --- a/src/dwarflint/check_debug_loc_range.hh +++ b/src/dwarflint/check_debug_loc_range.hh @@ -1,5 +1,4 @@ -/* Routines related to .debug_loc and .debug_range. - +/* Low-level checking of .debug_loc and .debug_range. Copyright (C) 2009 Red Hat, Inc. This file is part of Red Hat elfutils. @@ -24,8 +23,11 @@ Network licensing program, please visit www.openinventionnetwork.com . */ -#include "checks-low.hh" +#include "sections.ii" #include "check_debug_info.ii" +#include "checks.hh" +#include "messages.h" +#include "low.h" class check_debug_ranges : public check diff --git a/src/dwarflint/check_debug_pub.cc b/src/dwarflint/check_debug_pub.cc index 29d2b95e0..cd2aec087 100644 --- a/src/dwarflint/check_debug_pub.cc +++ b/src/dwarflint/check_debug_pub.cc @@ -1,5 +1,30 @@ -#include "checks-low.hh" +/* Low-level checking of .debug_pub*. + Copyright (C) 2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + #include "check_debug_info.hh" +#include "sections.hh" #include "pri.hh" namespace diff --git a/src/dwarflint/check_dups_abstract_origin.cc b/src/dwarflint/check_dups_abstract_origin.cc index 8e980a360..a514d2682 100644 --- a/src/dwarflint/check_dups_abstract_origin.cc +++ b/src/dwarflint/check_dups_abstract_origin.cc @@ -38,6 +38,7 @@ #include "dwarfstrings.h" #include "all-dies-it.hh" #include "pri.hh" +#include "messages.h" #include using elfutils::dwarf; diff --git a/src/dwarflint/check_matching_ranges.cc b/src/dwarflint/check_matching_ranges.cc index a9bb20e50..ba3800123 100644 --- a/src/dwarflint/check_matching_ranges.cc +++ b/src/dwarflint/check_matching_ranges.cc @@ -4,6 +4,7 @@ #include "highlevel_check.hh" #include "check_debug_loc_range.hh" +#include "check_debug_aranges.hh" using elfutils::dwarf; diff --git a/src/dwarflint/highlevel_check.cc b/src/dwarflint/highlevel_check.cc index 87c64b957..00dea3238 100644 --- a/src/dwarflint/highlevel_check.cc +++ b/src/dwarflint/highlevel_check.cc @@ -24,6 +24,7 @@ . */ #include "highlevel_check.hh" +#include "messages.h" namespace { diff --git a/src/dwarflint/highlevel_check.hh b/src/dwarflint/highlevel_check.hh index 1d5582506..dcc9e0b36 100644 --- a/src/dwarflint/highlevel_check.hh +++ b/src/dwarflint/highlevel_check.hh @@ -30,7 +30,7 @@ # include #endif -#include "checks-low.hh" +#include "checks.hh" #include "config.h" #include "c++/dwarf" #include "../libdwfl/libdwfl.h" diff --git a/src/dwarflint/main.cc b/src/dwarflint/main.cc index 9801d2929..c79a4e861 100644 --- a/src/dwarflint/main.cc +++ b/src/dwarflint/main.cc @@ -38,7 +38,6 @@ #include "dwarflint.hh" #include "readctx.h" #include "checks.hh" -#include "checks-low.hh" // xxx /* Bug report address. */ const char *argp_program_bug_address = PACKAGE_BUGREPORT; diff --git a/src/dwarflint/checks-low.cc b/src/dwarflint/sections.cc similarity index 92% rename from src/dwarflint/checks-low.cc rename to src/dwarflint/sections.cc index 4e07beb7f..36f1ef668 100644 --- a/src/dwarflint/checks-low.cc +++ b/src/dwarflint/sections.cc @@ -1,4 +1,4 @@ -/* Pedantic checking of DWARF files +/* Low-level section handling. Copyright (C) 2009 Red Hat, Inc. This file is part of Red Hat elfutils. @@ -27,16 +27,16 @@ # include #endif -#include "low.h" -#include "config.h" -#include "pri.hh" -#include "check_debug_loc_range.hh" -#include "check_debug_info.hh" -#include -#include +#include #include -#include +#include +#include "../libelf/gelf.h" +#include "sections.hh" + +#include "messages.h" +#include "pri.hh" +#include "config.h" namespace { @@ -463,27 +463,3 @@ section_base::section_base (dwarflint &lint, section_id secid) , file (sections->file) { } - -check_debug_aranges::check_debug_aranges (dwarflint &lint) - : _m_sec_aranges (lint.check (_m_sec_aranges)) -{ - check_debug_info *info = lint.toplev_check (); - coverage *cov = NULL; - if (info != NULL) - { - // xxx If need_ranges is true, we have to load ranges first. - // That's a flaw in design of checks, that data should have been - // stored in check_ranges, and that should have been requested - // explicitly. But for the time being... - if (info->cu_cov.need_ranges) - lint.toplev_check (); - if (!info->cu_cov.need_ranges) - cov = &info->cu_cov.cov; - } - - if (!check_aranges_structural (&_m_sec_aranges->file, - &_m_sec_aranges->sect, - info != NULL ? &info->cus.front () : NULL, - cov)) - throw check_base::failed (); -} diff --git a/src/dwarflint/checks-low.hh b/src/dwarflint/sections.hh similarity index 82% rename from src/dwarflint/checks-low.hh rename to src/dwarflint/sections.hh index 3169e7fd7..3bd2c63da 100644 --- a/src/dwarflint/checks-low.hh +++ b/src/dwarflint/sections.hh @@ -1,4 +1,4 @@ -/* +/* Low-level section handling. Copyright (C) 2009 Red Hat, Inc. This file is part of Red Hat elfutils. @@ -23,11 +23,11 @@ Network licensing program, please visit www.openinventionnetwork.com . */ -#ifndef DWARFLINT_CHECKS_LOW_HH -#define DWARFLINT_CHECKS_LOW_HH +#ifndef DWARFLINT_SECTIONS_HH +#define DWARFLINT_SECTIONS_HH -#include "low.h" #include "checks.hh" +#include "low.h" class load_sections : public check @@ -53,25 +53,15 @@ public: } }; -template +template class section : public section_base , public check > { public: explicit section (dwarflint &lint) - : section_base (lint, sec_id) + : section_base (lint, static_cast (sec_id)) {} }; -class check_debug_aranges - : public check -{ - section *_m_sec_aranges; - -public: - explicit check_debug_aranges (dwarflint &lint); -}; -static reg reg_debug_aranges; - -#endif//DWARFLINT_CHECKS_LOW_HH +#endif//DWARFLINT_SECTIONS_HH diff --git a/src/dwarflint/sections.ii b/src/dwarflint/sections.ii new file mode 100644 index 000000000..67f5e3f3f --- /dev/null +++ b/src/dwarflint/sections.ii @@ -0,0 +1 @@ +template class section; -- 2.47.3