]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Split check_debug_pub.cc to .hh
authorPetr Machata <pmachata@redhat.com>
Tue, 7 Sep 2010 12:25:16 +0000 (14:25 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 7 Sep 2010 12:25:16 +0000 (14:25 +0200)
dwarflint/Makefile.am
dwarflint/check_debug_pub.cc
dwarflint/check_debug_pub.hh [new file with mode: 0644]

index 1db8f2adbce27b283298cd32acb4216cf8d38785..c8cb062dc717ea6dea08b110958ac818aaff33f1 100644 (file)
@@ -60,8 +60,8 @@ dwarflint_SOURCES = \
        cu_coverage.cc cu_coverage.hh cu_coverage.ii \
        check_debug_abbrev.cc check_debug_abbrev.hh check_debug_abbrev.ii \
        check_debug_info.cc check_debug_info.hh check_debug_info.ii \
-       check_debug_line.cc \
-       check_debug_pub.cc \
+       check_debug_line.cc check_debug_line.hh check_debug_line.ii \
+       check_debug_pub.cc check_debug_pub.hh \
        check_debug_loc_range.cc check_debug_loc_range.hh check_debug_loc_range.ii \
        check_debug_aranges.cc check_debug_aranges.hh \
        check_matching_ranges.cc \
index 4188957819689e4f84335e6af342afa7249250c6..82eab1d2773483ba35583ad1f60c50b5c199e006 100644 (file)
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
+#include "check_debug_pub.hh"
 #include "check_debug_info.hh"
 #include "sections.hh"
 #include "pri.hh"
 
 namespace
 {
-  template<section_id sec_id>
-  class check_debug_pub
-    : public check<check_debug_pub<sec_id> >
+  template <class A, class B>
+  struct where xwhere (A a, B b)
   {
-  protected:
-    typedef section<sec_id> section_t;
-    section_t *_m_sec;
-    elf_file const &_m_file;
-    check_debug_info *_m_cus;
-
-    bool check_pub_structural ();
+    return WHERE (a, b);
+  }
+}
 
-  public:
-    check_debug_pub (checkstack &stack, dwarflint &lint)
-      : _m_sec (lint.check (stack, _m_sec))
-      , _m_file (_m_sec->file)
-      , _m_cus (lint.toplev_check (stack, _m_cus))
-    {
-      check_pub_structural ();
-    }
-  };
+template<section_id sec_id>
+check_debug_pub<sec_id>::check_debug_pub (checkstack &stack, dwarflint &lint)
+  : _m_sec (lint.check (stack, _m_sec))
+  , _m_file (_m_sec->file)
+  , _m_cus (lint.toplev_check (stack, _m_cus))
+{
+  check_pub_structural ();
+}
 
-  class check_debug_pubnames
-    : public check_debug_pub<sec_pubnames>
-  {
-  public:
-    check_debug_pubnames (checkstack &stack, dwarflint &lint)
-      : check_debug_pub<sec_pubnames> (stack, lint)
-    {}
 
-    static checkdescriptor const &descriptor () {
-      static checkdescriptor cd
-       (checkdescriptor::create ("check_debug_pubnames")
-        .groups ("@low")
-        .prereq<typeof (*_m_sec)> ()
-        .prereq<check_debug_info> ()
-        .description (
+checkdescriptor const &
+check_debug_pubnames::descriptor ()
+{
+  static checkdescriptor cd
+    (checkdescriptor::create ("check_debug_pubnames")
+     .groups ("@low")
+     .prereq<typeof (*_m_sec)> ()
+     .prereq<check_debug_info> ()
+     .description (
 "Checks for low-level structure of .debug_pubnames.  In addition it\n"
 "checks:\n"
 " - for garbage inside padding\n"
@@ -74,39 +64,28 @@ namespace
 "Furthermore, if .debug_info is valid, it is checked:\n"
 " - that references point to actual CUs and DIEs\n"
 " - that there's only one pub section per CU\n"));
-      return cd;
-    }
-  };
-  reg<check_debug_pubnames> reg_debug_pubnames;
-
-  class check_debug_pubtypes
-    : public check_debug_pub<sec_pubtypes>
-  {
-  public:
-    check_debug_pubtypes (checkstack &stack, dwarflint &lint)
-      : check_debug_pub<sec_pubtypes> (stack, lint)
-    {}
+  return cd;
+}
+static reg<check_debug_pubnames> reg_debug_pubnames;
+template check_debug_pub<sec_pubnames>::check_debug_pub (checkstack &stack,
+                                                        dwarflint &lint);
 
-    static checkdescriptor const &descriptor () {
-      static checkdescriptor cd
-       (checkdescriptor::create ("check_debug_pubtypes")
-        .groups ("@low")
-        .prereq<typeof (*_m_sec)> ()
-        .prereq<check_debug_info> ()
-        .description (
+checkdescriptor const &
+check_debug_pubtypes::descriptor ()
+{
+  static checkdescriptor cd
+    (checkdescriptor::create ("check_debug_pubtypes")
+     .groups ("@low")
+     .prereq<typeof (*_m_sec)> ()
+     .prereq<check_debug_info> ()
+     .description (
 "Checks for low-level structure of .debug_pubtypes.  In addition it\n"
 "makes the same checks as check_debug_pubnames.\n"));
-      return cd;
-    }
-  };
-  reg<check_debug_pubtypes> reg_debug_pubtypes;
-
-  template <class A, class B>
-  struct where xwhere (A a, B b)
-  {
-    return WHERE (a, b);
-  }
+  return cd;
 }
+static reg<check_debug_pubtypes> reg_debug_pubtypes;
+template check_debug_pub<sec_pubtypes>::check_debug_pub (checkstack &stack,
+                                                        dwarflint &lint);
 
 template <section_id sec_id>
 bool
diff --git a/dwarflint/check_debug_pub.hh b/dwarflint/check_debug_pub.hh
new file mode 100644 (file)
index 0000000..1f3e35c
--- /dev/null
@@ -0,0 +1,71 @@
+/* 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
+   <http://www.openinventionnetwork.com>.  */
+
+#ifndef DWARFLINT_CHECK_DEBUG_PUB_HH
+#define DWARFLINT_CHECK_DEBUG_PUB_HH
+
+#include "sections.ii"
+#include "check_debug_info.ii"
+#include "checks.hh"
+#include "low.h"
+
+template<section_id sec_id>
+class check_debug_pub
+  : public check<check_debug_pub<sec_id> >
+{
+protected:
+  typedef section<sec_id> section_t;
+  section_t *_m_sec;
+  elf_file const &_m_file;
+  check_debug_info *_m_cus;
+
+  bool check_pub_structural ();
+
+public:
+  // instantiated in .cc for each subclass
+  check_debug_pub (checkstack &stack, dwarflint &lint);
+};
+
+struct check_debug_pubnames
+  : public check_debug_pub<sec_pubnames>
+{
+  static checkdescriptor const &descriptor ();
+
+  check_debug_pubnames (checkstack &stack, dwarflint &lint)
+    : check_debug_pub<sec_pubnames> (stack, lint)
+  {}
+};
+
+struct check_debug_pubtypes
+  : public check_debug_pub<sec_pubtypes>
+{
+  static checkdescriptor const &descriptor ();
+
+  check_debug_pubtypes (checkstack &stack, dwarflint &lint)
+    : check_debug_pub<sec_pubtypes> (stack, lint)
+  {}
+};
+
+#endif//DWARFLINT_CHECK_DEBUG_PUB_HH