]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Getting rid of compat C bindings
authorPetr Machata <pmachata@redhat.com>
Wed, 22 Sep 2010 14:23:39 +0000 (16:23 +0200)
committerPetr Machata <pmachata@redhat.com>
Wed, 22 Sep 2010 14:23:39 +0000 (16:23 +0200)
40 files changed:
dwarflint/Makefile.am
dwarflint/addr-record.cc
dwarflint/addr-record.hh [moved from dwarflint/addr-record.h with 100% similarity]
dwarflint/check_debug_abbrev.cc
dwarflint/check_debug_aranges.cc
dwarflint/check_debug_info.cc
dwarflint/check_debug_info.hh
dwarflint/check_debug_line.cc
dwarflint/check_debug_loc_range.cc
dwarflint/check_debug_loc_range.hh
dwarflint/check_debug_pub.cc
dwarflint/check_duplicate_DW_tag_variable.cc
dwarflint/check_dups_abstract_origin.cc
dwarflint/check_expected_trees.cc
dwarflint/check_nodebug.cc
dwarflint/check_range_out_of_scope.cc
dwarflint/checked_read.cc
dwarflint/checked_read.hh [moved from dwarflint/checked_read.h with 100% similarity]
dwarflint/coverage.cc
dwarflint/coverage.h [deleted file]
dwarflint/coverage.hh
dwarflint/cu_coverage.cc
dwarflint/dwarflint.cc
dwarflint/highlevel_check.cc
dwarflint/locstats.cc
dwarflint/low.cc
dwarflint/low.h
dwarflint/main.cc
dwarflint/messages.cc
dwarflint/messages.hh [moved from dwarflint/messages.h with 59% similarity]
dwarflint/reloc.cc
dwarflint/reloc.hh [moved from dwarflint/reloc.h with 51% similarity]
dwarflint/section_id.cc
dwarflint/section_id.hh [moved from dwarflint/section_id.h with 85% similarity]
dwarflint/sections.cc
dwarflint/sections.ii
dwarflint/tables.cc
dwarflint/tables.h [deleted file]
dwarflint/tables.hh
dwarflint/where.h

index 92c5b8a0b4cb1362ae313fe4cb55b1a7a6a3baef..f83cef4c6b7b485075d559cbac50e2011b0d05dc 100644 (file)
@@ -44,17 +44,17 @@ dwarflint_SOURCES = \
        dwarflint.cc dwarflint.hh dwarflint.ii misc.h \
        low.cc low.h elf_file.ii \
        expected-at.cc expected.hh \
-       coverage.cc coverage.h \
+       coverage.cc coverage.hh \
        readctx.c readctx.h \
-       checked_read.cc checked_read.h \
+       checked_read.cc checked_read.hh \
        pri.cc pri.hh \
-       messages.cc messages.h \
-       section_id.cc section_id.h \
+       messages.cc messages.hh \
+       section_id.cc section_id.hh \
        where.c where.h \
        option.cc option.hh \
-       addr-record.cc addr-record.h \
-       reloc.cc reloc.h \
-       tables.cc tables.hh tables.h \
+       addr-record.cc addr-record.hh \
+       reloc.cc reloc.hh \
+       tables.cc tables.hh \
        all-dies-it.hh \
        checks.cc checks.hh checks.ii \
        sections.cc sections.hh sections.ii \
index 856e76c36d6aa1f7f50b94c266f32fb4ad7ce727..5c4234a7c87b1a8abdb7a58c4493b0c5449725d7 100644 (file)
@@ -23,7 +23,7 @@
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-#include "addr-record.h"
+#include "addr-record.hh"
 #include "misc.h"
 
 size_t
index 27effb5d357d9d47207422f233dad73a1c2be3e1..a46f0e8ea9fcdadd197f34e44d1632a74df5db57 100644 (file)
@@ -32,9 +32,9 @@
 #include "pri.hh"
 #include "tables.hh"
 #include "sections.hh"
-#include "checked_read.h"
-#include "messages.h"
-#include "tables.h"
+#include "checked_read.hh"
+#include "messages.hh"
+#include "misc.h"
 
 #include <dwarf.h>
 #include <sstream>
@@ -146,13 +146,13 @@ namespace
     struct where where = WHERE (sec_abbrev, NULL);
 
     // Tolerate failure here.
-    dwarf_version_h ver = NULL;
+    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 = get_latest_dwarf_version ();
+       ver = dwarf_version::get_latest ();
       }
     where.addr1 = 0;
 
@@ -246,7 +246,8 @@ namespace
                  if (it->abbrev_offset == abbr_off)
                    {
                      section->used = true;
-                     dwarf_version_h nver = get_dwarf_version (it->version);
+                     dwarf_version const *nver
+                       = dwarf_version::get (it->version);
                      if (ver == NULL)
                        ver = nver;
                      else if (nver != ver)
@@ -271,7 +272,7 @@ namespace
                    // table without knowing what version to use.
                    wr_error (where)
                      << "abbreviation table is never used." << std::endl;
-                   ver = get_latest_dwarf_version ();
+                   ver = dwarf_version::get_latest ();
                  }
              }
            assert (ver != NULL);
@@ -414,7 +415,7 @@ namespace
                    << "excessive DW_AT_sibling attribute at childless abbrev."
                    << std::endl;
 
-               switch (dwver_check_sibling_form (ver, attrib_form))
+               switch (ver->check_sibling_form (attrib_form))
                  {
                  case -1:
                    wr_message (where, cat (mc_die_rel, mc_impact_2))
@@ -432,7 +433,7 @@ namespace
            /* Similar for DW_AT_location and friends.  */
            else if (is_location_attrib (attrib_name))
              {
-               if (!dwver_form_allowed (ver, attrib_name, attrib_form))
+               if (!ver->form_allowed (attrib_name, attrib_form))
                  complain_invalid_form (where, attrib_name, attrib_form,
                                         "location attribute");
              }
index 4283254a721cc77d3718272b00d280eed85191f8..88bc7c91fea65d2739bc4dfa0388c4791f81a555 100644 (file)
@@ -38,7 +38,7 @@
 #include "check_debug_info.hh"
 #include "check_debug_loc_range.hh"
 #include "cu_coverage.hh"
-#include "checked_read.h"
+#include "checked_read.hh"
 
 checkdescriptor const *
 check_debug_aranges::descriptor ()
index 8489819d870f57317dd0142eb83c7b99d1c4831d..c9bced674c4caa6421e13632dfca95a174b21ef4 100644 (file)
 #include <algorithm>
 #include "../libdw/dwarf.h"
 
-#include "messages.h"
-#include "tables.h"
+#include "messages.hh"
+#include "tables.hh"
 #include "pri.hh"
 #include "option.hh"
 #include "sections.hh"
-#include "checked_read.h"
+#include "checked_read.hh"
 #include "check_debug_loc_range.hh"
 #include "check_debug_abbrev.hh"
 #include "check_debug_info.hh"
 #include "check_debug_line.hh"
+#include "misc.h"
 
 checkdescriptor const *
 read_cu_headers::descriptor ()
@@ -238,7 +239,7 @@ namespace
            wr_error (head.where) << "can't read version." << std::endl;
            throw check_base::failed ();
          }
-       if (get_dwarf_version (version) == NULL)
+       if (dwarf_version::get (version) == NULL)
          {
            wr_error (head.where) << "unsupported CU version "
                                  << version << '.' << std::endl;
@@ -501,7 +502,7 @@ namespace
     +1 in case some dies were actually loaded
   */
   int
-  read_die_chain (dwarf_version_h ver,
+  read_die_chain (dwarf_version const *ver,
                  elf_file const &file,
                  struct read_ctx *ctx,
                  struct cu *cu,
@@ -629,7 +630,7 @@ namespace
                                           "indirect attribute form"))
                  return -1;
 
-               if (!dwver_form_valid (ver, form))
+               if (!ver->form_allowed (form))
                  {
                    wr_error (where)
                      << "invalid indirect form " << pri::hex (value)
@@ -639,7 +640,7 @@ namespace
                form = value;
 
                if (it->name == DW_AT_sibling)
-                 switch (dwver_check_sibling_form (ver, form))
+                 switch (ver->check_sibling_form (form))
                    {
                    case -1:
                      wr_message (where, cat (mc_die_rel, mc_impact_2))
@@ -1067,7 +1068,7 @@ check_debug_info::check_cu_structural (struct read_ctx *ctx,
     fprintf (stderr, "%s: CU starts\n", where_fmt (&cu->head->where, NULL));
   bool retval = true;
 
-  dwarf_version_h ver = get_dwarf_version (cu->head->version);
+  dwarf_version const *ver = dwarf_version::get (cu->head->version);
   assert (ver != NULL);
 
   /* Look up Abbrev table for this CU.  */
index d5aa1a3043f345bb0a3904ff5fa0182f34f85916..01189d14457cf1fa83b9afa1c25065ece873cb21 100644 (file)
@@ -27,7 +27,7 @@
 #define DWARFLINT_CHECK_DEBUG_INFO_HH
 
 #include <libdw.h>
-#include "addr-record.h"
+#include "addr-record.hh"
 #include "elf_file.ii"
 #include "coverage.hh"
 #include "checks.hh"
index 046364e28782ac9fdd26bdc7864008094f9abe67..64c1a09a7d13a027694e79f455bcde245275fbe9 100644 (file)
@@ -27,8 +27,8 @@
 #include "check_debug_info.hh"
 #include "sections.hh"
 #include "pri.hh"
-#include "checked_read.h"
-#include "messages.h"
+#include "checked_read.hh"
+#include "messages.hh"
 
 #include <dwarf.h>
 #include "../libdw/known-dwarf.h"
index da82e00c497fed9769e81bc2b677898a41aade9c..6f5251ad77d185cefc7b6957d0a77d866a4d14cf 100644 (file)
 #include "check_debug_loc_range.hh"
 #include "check_debug_info.hh"
 #include "sections.hh"
-#include "checked_read.h"
+#include "checked_read.hh"
 #include "../src/dwarf-opcodes.h"
 #include "pri.hh"
+#include "misc.h"
 
 bool do_range_coverage = false; // currently no option
 
index c64140323a350290876da4a09fc8b44e13f19992..4f5ac45235c3527a17802335552ef85a3168c513 100644 (file)
@@ -26,7 +26,7 @@
 #include "checks.hh"
 #include "sections.ii"
 #include "check_debug_info.ii"
-#include "messages.h"
+#include "messages.hh"
 #include "coverage.hh"
 
 struct section_coverage
index e649888d1a1798207ec00e4849df90c49e8213c0..354a631674ef878c29aca3a92ed9b00e16758eb6 100644 (file)
@@ -27,8 +27,8 @@
 #include "check_debug_info.hh"
 #include "sections.hh"
 #include "pri.hh"
-#include "checked_read.h"
-#include "messages.h"
+#include "checked_read.hh"
+#include "messages.hh"
 
 template<section_id sec_id>
 check_debug_pub<sec_id>::check_debug_pub (checkstack &stack, dwarflint &lint)
index 1a7d027d9c19dfb4f39ddd8db60d2fe9481cca1c..3fb11632a1f03758a6c412b6b87c787dc270c5c4 100644 (file)
@@ -26,7 +26,7 @@
 #include "highlevel_check.hh"
 #include "all-dies-it.hh"
 #include "pri.hh"
-#include "messages.h"
+#include "messages.hh"
 #include <map>
 
 using elfutils::dwarf;
index a45cd66065bfc2e9aa027a72b804908bac335bb1..ec786561f89c73b472578f00e3dfba0963a741a8 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files.
-   Copyright (C) 2009 Red Hat, Inc.
+   Copyright (C) 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
 #include "../src/dwarfstrings.h"
 #include "all-dies-it.hh"
 #include "pri.hh"
-#include "messages.h"
+#include "messages.hh"
 #include <map>
 
 using elfutils::dwarf;
index 0f8f369f50a7ffc1382d2f3fc0b669399fe7f53c..26f0375c1fa0cea077eee64b726ea491e07eb39c 100644 (file)
@@ -33,7 +33,7 @@
 #include "../src/dwarfstrings.h"
 #include "../libdw/c++/dwarf-knowledge.cc"
 #include "pri.hh"
-#include "messages.h"
+#include "messages.hh"
 
 using elfutils::dwarf;
 
index 56b0ca805ca781785c6d8ed6ae2e2f418a9048d7..543daf5b1400f255e8352db473ef9edec7ce974f 100644 (file)
@@ -24,7 +24,7 @@
    <http://www.openinventionnetwork.com>.  */
 
 #include "checks.hh"
-#include "messages.h"
+#include "messages.hh"
 #include "sections.hh"
 #include "option.hh"
 
index c930aa2105f50b3ced8f7f82cf3b6aa8b69001b7..df6cda798c42c536cb86ce9912b658d2da239680 100644 (file)
@@ -31,6 +31,7 @@
 #include "coverage.hh"
 #include "pri.hh"
 #include "check_debug_loc_range.hh"
+#include "misc.h"
 
 using elfutils::dwarf;
 
index fd5edebf0bd8345c8417f11bbac00590d525bcf4..ced62beac24f74b9ae89a747e319f4e0e7aa2eee 100644 (file)
@@ -31,8 +31,8 @@
 #endif
 
 #include <dwarf.h>
-#include "checked_read.h"
-#include "messages.h"
+#include "checked_read.hh"
+#include "messages.hh"
 
 bool
 read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
index 2cbf3b301e89788fa9b04707ff66e67a279d4092..80e3be5873f01b611742c2f56f540accd181adde 100644 (file)
@@ -1,6 +1,6 @@
 /* Implementation of coverage analysis.
 
-   Copyright (C) 2008,2009 Red Hat, Inc.
+   Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -30,6 +30,7 @@
 
 #include "coverage.hh"
 #include "pri.hh"
+#include "misc.h"
 
 #include <stdbool.h>
 #include <assert.h>
diff --git a/dwarflint/coverage.h b/dwarflint/coverage.h
deleted file mode 100644 (file)
index d6418c2..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Coverage analysis.
-
-   Copyright (C) 2008,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_COVERAGE_H
-#define DWARFLINT_COVERAGE_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "misc.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Functions and data structures for handling of address range
-   coverage.  We use that to find holes of unused bytes in DWARF
-   string table.  */
-
-struct cov_range
-{
-  uint64_t start;
-  uint64_t length;
-
-#ifdef __cplusplus
-  uint64_t end () const { return start + length; }
-#endif
-};
-
-struct coverage
-{
-  struct cov_range *ranges;
-  size_t size;
-  size_t alloc;
-
-#ifdef __cplusplus
-  cov_range &back () { return ranges[size - 1]; }
-  cov_range const &back () const { return ranges[size - 1]; }
-#endif
-};
-
-char *range_fmt (char *buf, size_t buf_size,
-                uint64_t start, uint64_t end);
-
-struct coverage *coverage_clone (struct coverage const *cov)
-  __attribute__ ((malloc));
-void coverage_free (struct coverage *cov);
-
-void coverage_add (struct coverage *cov, uint64_t start, uint64_t length);
-void coverage_add_all (struct coverage *__restrict__ cov,
-                      struct coverage const *__restrict__ other);
-
-/* Returns true if something was actually removed, false if whole
-   range falls into hole in coverage.  */
-bool coverage_remove (struct coverage *cov, uint64_t start, uint64_t length);
-
-/* Returns true if something was actually removed, false if whole
-   range falls into hole in coverage.  */
-bool coverage_remove_all (struct coverage *__restrict__ cov,
-                         struct coverage const *__restrict__ other);
-
-/* Returns true if whole range ADDRESS/LENGTH is covered by COV.
-   LENGTH may not be zero.  */
-bool coverage_is_covered (struct coverage const *cov,
-                         uint64_t start, uint64_t length);
-
-/* Returns true if at least some of the range ADDRESS/LENGTH is
-   covered by COV.  Zero-LENGTH range never overlaps.  */
-bool coverage_is_overlap (struct coverage const *cov,
-                         uint64_t start, uint64_t length);
-
-bool coverage_find_holes (struct coverage const *cov,
-                         uint64_t start, uint64_t length,
-                         bool (*cb)(uint64_t start, uint64_t length,
-                                    void *data),
-                         void *data);
-bool coverage_find_ranges (struct coverage const *cov,
-                         bool (*cb)(uint64_t start, uint64_t length,
-                                    void *data),
-                         void *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif//DWARFLINT_COVERAGE_H
index d2b418a2042bd98b22919da68a7bd056ea6dc7ee..e13344be255441c3d385fe8a959caae2d5edd7b7 100644 (file)
@@ -1,6 +1,6 @@
 /* Coverage analysis, C++ support.
 
-   Copyright (C) 2008,2009 Red Hat, Inc.
+   Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
 
 #include <string>
 #include <sstream>
-#include "coverage.h"
+
+/* Functions and data structures for handling of address range
+   coverage.  We use that to find holes of unused bytes in DWARF
+   string table.  */
+
+struct cov_range
+{
+  uint64_t start;
+  uint64_t length;
+
+#ifdef __cplusplus
+  uint64_t end () const { return start + length; }
+#endif
+};
+
+struct coverage
+{
+  struct cov_range *ranges;
+  size_t size;
+  size_t alloc;
+
+#ifdef __cplusplus
+  cov_range &back () { return ranges[size - 1]; }
+  cov_range const &back () const { return ranges[size - 1]; }
+#endif
+};
+
+char *range_fmt (char *buf, size_t buf_size,
+                uint64_t start, uint64_t end);
+
+struct coverage *coverage_clone (struct coverage const *cov)
+  __attribute__ ((malloc));
+void coverage_free (struct coverage *cov);
+
+void coverage_add (struct coverage *cov, uint64_t start, uint64_t length);
+void coverage_add_all (struct coverage *__restrict__ cov,
+                      struct coverage const *__restrict__ other);
+
+/* Returns true if something was actually removed, false if whole
+   range falls into hole in coverage.  */
+bool coverage_remove (struct coverage *cov, uint64_t start, uint64_t length);
+
+/* Returns true if something was actually removed, false if whole
+   range falls into hole in coverage.  */
+bool coverage_remove_all (struct coverage *__restrict__ cov,
+                         struct coverage const *__restrict__ other);
+
+/* Returns true if whole range ADDRESS/LENGTH is covered by COV.
+   LENGTH may not be zero.  */
+bool coverage_is_covered (struct coverage const *cov,
+                         uint64_t start, uint64_t length);
+
+/* Returns true if at least some of the range ADDRESS/LENGTH is
+   covered by COV.  Zero-LENGTH range never overlaps.  */
+bool coverage_is_overlap (struct coverage const *cov,
+                         uint64_t start, uint64_t length);
+
+bool coverage_find_holes (struct coverage const *cov,
+                         uint64_t start, uint64_t length,
+                         bool (*cb)(uint64_t start, uint64_t length,
+                                    void *data),
+                         void *data);
+bool coverage_find_ranges (struct coverage const *cov,
+                         bool (*cb)(uint64_t start, uint64_t length,
+                                    void *data),
+                         void *data);
 
 namespace cov
 {
index 7fb0d3d614939e1bf4cda43e1b2af981acc7b000..9098806ce80cbdf4fcb516c3d049e70f8964884e 100644 (file)
@@ -26,6 +26,7 @@
 #include "cu_coverage.hh"
 #include "check_debug_info.hh"
 #include "check_debug_loc_range.hh"
+#include <cstring>
 
 checkdescriptor const *
 cu_coverage::descriptor ()
@@ -41,7 +42,7 @@ cu_coverage::cu_coverage (checkstack &stack, dwarflint &lint)
   : _m_info (lint.check (stack, _m_info))
   , _m_ranges (lint.check_if (_m_info->need_ranges (), stack, _m_ranges))
 {
-  memset (&cov, 0, sizeof (cov));
+  std::memset (&cov, 0, sizeof (cov));
   coverage_add_all (&cov, &_m_info->cov ());
   if (_m_ranges)
     coverage_add_all (&cov, &_m_ranges->cov ());
index a6d68a043a1da888840192f81b85ad69492cd12b..63fd8b714d7c6baca0e7dfb6f6abfb0df9d5a572 100644 (file)
@@ -24,7 +24,7 @@
    <http://www.openinventionnetwork.com>.  */
 
 #include "dwarflint.hh"
-#include "messages.h"
+#include "messages.hh"
 #include "checks.hh"
 #include "main.hh"
 
index fefc727b6df572708adec459a4b654af4beb9ddf..17c69244a766cb488b43178ddcf20278cdfeabd4 100644 (file)
@@ -24,7 +24,7 @@
    <http://www.openinventionnetwork.com>.  */
 
 #include "highlevel_check.hh"
-#include "messages.h"
+#include "messages.hh"
 
 #include "sections.hh"
 #include "lowlevel_checks.hh"
index 1b335ba6be30bd861827a2fe84090551c668feef..83dafbb05c6a4faadc8defbb1fe80bf676ac2f25 100644 (file)
@@ -26,7 +26,7 @@
 #include "highlevel_check.hh"
 #include "all-dies-it.hh"
 #include "option.hh"
-#include "messages.h"
+#include "messages.hh"
 #include "pri.hh"
 
 #include <sstream>
index 34dd76e7f7795cf6042cb5de194eebbd333606ff..30c2f2b31963017de4f638da83a717e8ff834ec8 100644 (file)
@@ -28,7 +28,7 @@
 #endif
 
 #include "low.h"
-#include "messages.h"
+#include "messages.hh"
 #include <stdarg.h>
 
 bool
index 7606557b397cc546d183ae02d95c2213f065a1e5..8f4d4424c75d29b31e960ea320c34e83c649fcd5 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "../libdw/libdw.h"
 #include "../libebl/libebl.h"
-#include "reloc.h"
+#include "reloc.hh"
 
 #ifdef __cplusplus
 extern "C"
index 823022af30a024dad4b804cbc49d06325e0ab3ec..16850628b75e441cf07db5f65321912388089807 100644 (file)
@@ -38,7 +38,7 @@
 #include "readctx.h"
 #include "checks.hh"
 #include "option.hh"
-#include "messages.h"
+#include "messages.hh"
 
 /* Messages that are accepted (and made into warning).  */
 struct message_criteria warning_criteria;
index d96cf88d267eafd0de5931e3791146bc65d6c90f..784dffb7bfedbc6e27a4e8386b16d9c9412fc372 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2009,2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -23,9 +23,9 @@
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-#include "messages.h"
+#include "messages.hh"
 #include "misc.h"
-#include "coverage.h"
+#include "coverage.hh"
 
 #include <vector>
 #include <sstream>
similarity index 59%
rename from dwarflint/messages.h
rename to dwarflint/messages.hh
index af2048b7560ced8d6191a8896ae337ead5ce99bc..d14230b0a008f3a4ee66f27bdda341f8ecc1f4fb 100644 (file)
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-#ifndef DWARFLINT_MESSAGES_H
-#define DWARFLINT_MESSAGES_H
+#ifndef DWARFLINT_MESSAGES_HH
+#define DWARFLINT_MESSAGES_HH
 
 #include "where.h"
 #include "libdw.h"
-
-#ifdef __cplusplus
-# define IF_CPLUSPLUS(X) X
-# include <string>
-extern "C"
-{
-#endif
+#include <string>
 
 #define MESSAGE_CATEGORIES                                             \
   /* Severity: */                                                      \
@@ -69,98 +63,90 @@ extern "C"
   MC (mac,       22) /* messages related to .debug_mac */ \
   MC (other,     31) /* messages unrelated to any of the above */
 
-  enum message_category
+enum message_category
   {
     mc_none      = 0,
 
-#define MC(CAT, ID)\
+#define MC(CAT, ID)                            \
     mc_##CAT = 1u << ID,
     MESSAGE_CATEGORIES
 #undef MC
   };
 
-  struct message_term
-  {
-    /* Given a term like A && !B && C && !D, we decompose it thus: */
-    unsigned long positive; /* non-zero bits for plain predicates */
-    unsigned long negative; /* non-zero bits for negated predicates */
-
-#ifdef __cplusplus
-    message_term (unsigned long pos, unsigned long neg)
-      : positive (pos), negative (neg)
-    {}
-    std::string str () const;
-#endif
-  };
+struct message_term
+{
+  /* Given a term like A && !B && C && !D, we decompose it thus: */
+  unsigned long positive; /* non-zero bits for plain predicates */
+  unsigned long negative; /* non-zero bits for negated predicates */
+
+  message_term (unsigned long pos, unsigned long neg)
+    : positive (pos), negative (neg)
+  {}
+  std::string str () const;
+};
 
-  struct message_criteria
+struct message_criteria
+{
+  struct message_term *terms;
+  size_t size;
+  size_t alloc;
+
+  message_criteria ()
+    : terms (NULL), size (0), alloc (0)
+  {}
+
+  ~message_criteria ()
   {
-    struct message_term *terms;
-    size_t size;
-    size_t alloc;
-
-#ifdef __cplusplus
-    message_criteria ()
-      : terms (NULL), size (0), alloc (0)
-    {}
-    ~message_criteria ()
-    {
-      free (terms);
-    }
-
-    void operator |= (message_term const &term);
-    void operator &= (message_term const &term);
-    std::string str () const;
-#endif
-  };
+    free (terms);
+  }
 
-#ifdef __cplusplus
-  message_criteria operator ! (message_term const &);
-#endif
+  void operator |= (message_term const &term);
+  void operator &= (message_term const &term);
+  std::string str () const;
+};
 
-  extern void wr_error (const struct where *wh, const char *format, ...)
-    __attribute__ ((format (printf, 2, 3)));
+message_criteria operator ! (message_term const &);
 
-  extern void wr_warning (const struct where *wh, const char *format, ...)
-    __attribute__ ((format (printf, 2, 3)));
+extern void wr_error (const struct where *wh, const char *format, ...)
+  __attribute__ ((format (printf, 2, 3)));
 
-  extern void wr_message (unsigned long category, const struct where *wh,
-                         const char *format, ...)
-    __attribute__ ((format (printf, 3, 4)));
+extern void wr_warning (const struct where *wh, const char *format, ...)
+  __attribute__ ((format (printf, 2, 3)));
 
-  extern void wr_format_padding_message (unsigned long category,
-                                        struct where const *wh,
-                                        uint64_t start, uint64_t end,
-                                        char const *kind);
+extern void wr_message (unsigned long category, const struct where *wh,
+                       const char *format, ...)
+  __attribute__ ((format (printf, 3, 4)));
 
-  extern void wr_format_leb128_message (struct where const *where,
-                                       const char *what,
-                                       const char *purpose,
-                                       const unsigned char *begin,
-                                       const unsigned char *end);
+extern void wr_format_padding_message (unsigned long category,
+                                      struct where const *wh,
+                                      uint64_t start, uint64_t end,
+                                      char const *kind);
 
-  extern void wr_message_padding_0 (unsigned long category,
-                                   struct where const *wh,
-                                   uint64_t start, uint64_t end);
+extern void wr_format_leb128_message (struct where const *where,
+                                     const char *what,
+                                     const char *purpose,
+                                     const unsigned char *begin,
+                                     const unsigned char *end);
 
-  extern void wr_message_padding_n0 (unsigned long category,
-                                    struct where const *wh,
-                                    uint64_t start, uint64_t end);
+extern void wr_message_padding_0 (unsigned long category,
+                                 struct where const *wh,
+                                 uint64_t start, uint64_t end);
 
-  extern bool message_accept (struct message_criteria const *cri,
-                             unsigned long cat);
+extern void wr_message_padding_n0 (unsigned long category,
+                                  struct where const *wh,
+                                  uint64_t start, uint64_t end);
 
+extern bool message_accept (struct message_criteria const *cri,
+                           unsigned long cat);
 
-  extern unsigned error_count;
 
-  /* Messages that are accepted (and made into warning).  */
-  extern struct message_criteria warning_criteria;
+extern unsigned error_count;
 
-  /* Accepted (warning) messages, that are turned into errors.  */
-  extern struct message_criteria error_criteria;
+/* Messages that are accepted (and made into warning).  */
+extern struct message_criteria warning_criteria;
 
-#ifdef __cplusplus
-}
+/* Accepted (warning) messages, that are turned into errors.  */
+extern struct message_criteria error_criteria;
 
 inline message_category
 cat (message_category c1,
@@ -177,6 +163,5 @@ std::ostream &wr_error (where const &wh);
 std::ostream &wr_error ();
 std::ostream &wr_message (where const &wh, message_category cat);
 std::ostream &wr_message (message_category cat);
-#endif
 
-#endif//DWARFLINT_MESSAGES_H
+#endif//DWARFLINT_MESSAGES_HH
index 53510a75a7b3ba378cdcf78c677656528c3343f5..94730466ba9ba148796660d34b21dc27a84f98ef 100644 (file)
@@ -27,8 +27,8 @@
 #define __STDC_FORMAT_MACROS
 
 #include "low.h"
-#include "reloc.h"
-#include "messages.h"
+#include "reloc.hh"
+#include "messages.hh"
 #include "misc.h"
 #include "readctx.h"
 
similarity index 51%
rename from dwarflint/reloc.h
rename to dwarflint/reloc.hh
index 5d65f3852c3bcc01e3016e1219ba9252e94c9104..e5d292bace1c298784d69c4bc1802c96c3819b69 100644 (file)
 #include <libelf.h>
 #include <gelf.h>
 
-#ifdef __cplusplus
-extern "C"
+struct relocation
 {
-#else
-# include <stdbool.h>
-#endif
-
-  struct relocation
-  {
-    uint64_t offset;
-    uint64_t addend;
-    int symndx;
-    int type;
-    bool invalid;      /* Whether this one relocation should be
-                          ignored.  Necessary so that we don't report
-                          invalid & missing relocation twice.  */
-  };
-
-  struct relocation_data
-  {
-    Elf_Data *symdata;         /* Symbol table associated with this
-                                  relocation section.  */
-    size_t type;               /* SHT_REL or SHT_RELA.  */
-
-    struct relocation *rel;    /* Array of relocations.  May be NULL
-                                  if there are no associated
-                                  relocation data.  */
-    size_t size;
-    size_t alloc;
-    size_t index;              /* Current index. */
-  };
-
-  enum skip_type
+  uint64_t offset;
+  uint64_t addend;
+  int symndx;
+  int type;
+  bool invalid;        /* Whether this one relocation should be
+                  ignored.  Necessary so that we don't report
+                  invalid & missing relocation twice.  */
+};
+
+struct relocation_data
+{
+  Elf_Data *symdata;       /* Symbol table associated with this
+                             relocation section.  */
+  size_t type;             /* SHT_REL or SHT_RELA.  */
+
+  struct relocation *rel;  /* Array of relocations.  May be NULL if
+                             there are no associated relocation
+                             data.  */
+  size_t size;
+  size_t alloc;
+  size_t index;            /* Current index. */
+};
+
+enum skip_type
   {
     skip_unref = 0,
     skip_mismatched = 1,
     skip_ok,
   };
 
-  bool read_rel (struct elf_file *file, struct sec *sec,
-                Elf_Data *reldata, bool elf_64);
+bool read_rel (struct elf_file *file, struct sec *sec,
+              Elf_Data *reldata, bool elf_64);
 
-  struct relocation *relocation_next (struct relocation_data *reloc,
-                                     uint64_t offset,
-                                     struct where const *where,
-                                     enum skip_type st);
+struct relocation *relocation_next (struct relocation_data *reloc,
+                                   uint64_t offset,
+                                   struct where const *where,
+                                   enum skip_type st);
 
-  void relocation_reset (struct relocation_data *reloc);
+void relocation_reset (struct relocation_data *reloc);
 
-  void relocation_skip (struct relocation_data *reloc, uint64_t offset,
-                       struct where const *where, enum skip_type st);
+void relocation_skip (struct relocation_data *reloc, uint64_t offset,
+                     struct where const *where, enum skip_type st);
 
-  void relocation_skip_rest (struct relocation_data *reloc,
-                            enum section_id id);
+void relocation_skip_rest (struct relocation_data *reloc,
+                          enum section_id id);
 
-  void relocate_one (struct elf_file const *file,
-                    struct relocation_data *reloc,
-                    struct relocation *rel,
-                    unsigned width, uint64_t *value,
-                    struct where const *where,
-                    enum section_id offset_into, GElf_Sym **symptr);
+void relocate_one (struct elf_file const *file,
+                  struct relocation_data *reloc,
+                  struct relocation *rel,
+                  unsigned width, uint64_t *value,
+                  struct where const *where,
+                  enum section_id offset_into, GElf_Sym **symptr);
 
 #define PRI_LACK_RELOCATION ": %s seems to lack a relocation.\n"
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif//DWARFLINT_RELOC_H
index a9d28c699b3b6bf4322ad5c6697030987a142477..8e594a7f6f64b9bb164997fe87a4d74dd400c59b 100644 (file)
@@ -23,7 +23,7 @@
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-#include "section_id.h"
+#include "section_id.hh"
 
 #include <stdlib.h>
 
similarity index 85%
rename from dwarflint/section_id.h
rename to dwarflint/section_id.hh
index 1fe74b0208c922e6bf4c7f18b143872927741c31..4b937d7fd7f98e9b582c89c07643b9b618a27c6c 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2009,2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-#ifndef DWARFLINT_SECTION_ID_H
-#define DWARFLINT_SECTION_ID_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#ifndef DWARFLINT_SECTION_ID_HH
+#define DWARFLINT_SECTION_ID_HH
 
 #define DEBUGINFO_SECTIONS \
   SEC (info)              \
@@ -43,7 +38,7 @@ extern "C"
   SEC (mac)               \
   SEC (ranges)
 
-  enum section_id
+enum section_id
   {
     sec_invalid = 0,
 
@@ -68,12 +63,8 @@ extern "C"
     rel_exec,          /* Some as above, but we expect EXEC bit.  */
   };
 
-  // section_name[0] is for sec_invalid.  The last index is for
-  // count_debuginfo_sections and is NULL.
-  extern char const *section_name[];
-
-#ifdef __cplusplus
-}
-#endif
+// section_name[0] is for sec_invalid.  The last index is for
+// count_debuginfo_sections and is NULL.
+extern char const *section_name[];
 
-#endif//DWARFLINT_SECTION_ID_H
+#endif//DWARFLINT_SECTION_ID_HH
index 201dac7fccd4f83141ae04424d247b3531027c22..a81d7dc62975cdd0b1fe7a1f5a20e5a6335c7f14 100644 (file)
@@ -32,7 +32,7 @@
 #include "../libelf/gelf.h"
 
 #include "sections.hh"
-#include "messages.h"
+#include "messages.hh"
 #include "pri.hh"
 #include "misc.h"
 
index bc726d440c1e2192714c94b4fb843af69467d8e6..ef5ec2139e64c3b1bc1d8ec46171cb15acd47fe4 100644 (file)
@@ -1,2 +1,2 @@
-#include "section_id.h"
+#include "section_id.hh"
 template<enum section_id> class section;
index 82d4dd4b5fbc84d5f3bcafb90d73c429aef8b05d..a44f2a61ec176c2bd8b5407895b81008bf8ef23e 100644 (file)
@@ -28,7 +28,6 @@
 // a version in its own.
 
 #include "tables.hh"
-#include "tables.h"
 #include "../libdw/dwarf.h"
 
 #include <map>
@@ -389,8 +388,8 @@ namespace
   std_dwarf dwarf4 (dwarf_4_at_table, dwarf_4_form_table, &dwarf3);
 }
 
-dwarf_version_h
-get_dwarf_version (unsigned version)
+dwarf_version const *
+dwarf_version::get (unsigned version)
 {
   switch (version)
     {
@@ -401,34 +400,16 @@ get_dwarf_version (unsigned version)
     };
 }
 
-dwarf_version_h
-get_latest_dwarf_version ()
+dwarf_version const *
+dwarf_version::get_latest ()
 {
-  return &dwarf4;
-}
-
-bool
-dwver_form_valid (dwarf_version const *ver, int form)
-{
-  return ver->form_allowed (form);
-}
-
-bool
-dwver_form_allowed (dwarf_version const *ver, int attr, int form)
-{
-  return ver->form_allowed (attr, form);
-}
-
-bool
-dwver_form_allowed_in (dwarf_version const *ver, int attr, int form, int tag)
-{
-  return ver->form_allowed (attr, form, tag);
+  return get (4);
 }
 
 int
-dwver_check_sibling_form (dwarf_version_h ver, int form)
+dwarf_version::check_sibling_form (int form) const
 {
-  if (!dwver_form_allowed (ver, DW_AT_sibling, form))
+  if (!form_allowed (DW_AT_sibling, form))
     return -2;
   else if (form == DW_FORM_ref_addr)
     return -1;
diff --git a/dwarflint/tables.h b/dwarflint/tables.h
deleted file mode 100644 (file)
index 0aa5384..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Dwarf version tables, C binding.
-
-   Copyright (C) 2009, 2010 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_TABLES_H
-#define DWARFLINT_TABLES_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#else
-# include <stdbool.h>
-#endif
-
-  struct dwarf_version;
-  typedef struct dwarf_version const *dwarf_version_h;
-
-  dwarf_version_h get_dwarf_version (unsigned version)
-    __attribute__ ((pure));
-
-  dwarf_version_h get_latest_dwarf_version ()
-    __attribute__ ((pure));
-
-  bool dwver_form_valid (dwarf_version_h ver, int form);
-
-  bool dwver_form_allowed (dwarf_version_h ver, int attr, int form);
-
-  bool dwver_form_allowed_in (dwarf_version_h ver, int attr,int form, int tag);
-
-  int dwver_check_sibling_form (dwarf_version_h ver, int form);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif//DWARFLINT_TABLES_H
index 16ee24dc2137efdd319a88f706658c13aec7a321..6208b893cb352a3775aca081cd21546d043017b5 100644 (file)
@@ -1,6 +1,6 @@
 /* Dwarf version tables.
 
-   Copyright (C) 2009 Red Hat, Inc.
+   Copyright (C) 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -70,6 +70,14 @@ public:
   {
     return find_form (allowed_forms (at, tag), f);
   }
+
+  int check_sibling_form (int form) const;
+
+  static dwarf_version const *get (unsigned version)
+    __attribute__ ((pure));
+
+  static dwarf_version const *get_latest ()
+    __attribute__ ((pure));
 };
 
 #endif//DWARFLINT_TABLES_HH
index 1cd5d55ba3f0b957695c61dc92b80890bf6b56fa..c5e22761f5e6b51d1edaf9a3b263deab0680b260 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef DWARFLINT_WHERE_H
 #define DWARFLINT_WHERE_H
 
-#include "section_id.h"
+#include "section_id.hh"
 
 #include <stdint.h>
 #include <stdlib.h>