summaryrefslogtreecommitdiffstats
path: root/dwarflint
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2010-09-22 16:23:39 +0200
committerPetr Machata <[email protected]>2010-09-22 16:23:39 +0200
commit4eec4fa552709e0677f5bcc1c8ab2baf907dd072 (patch)
tree3d3b0b9b741f93c36dc10c873a45eb7b8cd9e361 /dwarflint
parente8d64a0ffab2efe582f69de9bc8dbccb723b1853 (diff)
dwarflint: Getting rid of compat C bindings
Diffstat (limited to 'dwarflint')
-rw-r--r--dwarflint/Makefile.am14
-rw-r--r--dwarflint/addr-record.cc2
-rw-r--r--dwarflint/addr-record.hh (renamed from dwarflint/addr-record.h)0
-rw-r--r--dwarflint/check_debug_abbrev.cc19
-rw-r--r--dwarflint/check_debug_aranges.cc2
-rw-r--r--dwarflint/check_debug_info.cc17
-rw-r--r--dwarflint/check_debug_info.hh2
-rw-r--r--dwarflint/check_debug_line.cc4
-rw-r--r--dwarflint/check_debug_loc_range.cc3
-rw-r--r--dwarflint/check_debug_loc_range.hh2
-rw-r--r--dwarflint/check_debug_pub.cc4
-rw-r--r--dwarflint/check_duplicate_DW_tag_variable.cc2
-rw-r--r--dwarflint/check_dups_abstract_origin.cc4
-rw-r--r--dwarflint/check_expected_trees.cc2
-rw-r--r--dwarflint/check_nodebug.cc2
-rw-r--r--dwarflint/check_range_out_of_scope.cc1
-rw-r--r--dwarflint/checked_read.cc4
-rw-r--r--dwarflint/checked_read.hh (renamed from dwarflint/checked_read.h)0
-rw-r--r--dwarflint/coverage.cc3
-rw-r--r--dwarflint/coverage.h112
-rw-r--r--dwarflint/coverage.hh69
-rw-r--r--dwarflint/cu_coverage.cc3
-rw-r--r--dwarflint/dwarflint.cc2
-rw-r--r--dwarflint/highlevel_check.cc2
-rw-r--r--dwarflint/locstats.cc2
-rw-r--r--dwarflint/low.cc2
-rw-r--r--dwarflint/low.h2
-rw-r--r--dwarflint/main.cc2
-rw-r--r--dwarflint/messages.cc6
-rw-r--r--dwarflint/messages.hh (renamed from dwarflint/messages.h)143
-rw-r--r--dwarflint/reloc.cc4
-rw-r--r--dwarflint/reloc.hh (renamed from dwarflint/reloc.h)95
-rw-r--r--dwarflint/section_id.cc2
-rw-r--r--dwarflint/section_id.hh (renamed from dwarflint/section_id.h)25
-rw-r--r--dwarflint/sections.cc2
-rw-r--r--dwarflint/sections.ii2
-rw-r--r--dwarflint/tables.cc33
-rw-r--r--dwarflint/tables.h58
-rw-r--r--dwarflint/tables.hh10
-rw-r--r--dwarflint/where.h2
40 files changed, 260 insertions, 405 deletions
diff --git a/dwarflint/Makefile.am b/dwarflint/Makefile.am
index 92c5b8a0..f83cef4c 100644
--- a/dwarflint/Makefile.am
+++ b/dwarflint/Makefile.am
@@ -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 \
diff --git a/dwarflint/addr-record.cc b/dwarflint/addr-record.cc
index 856e76c3..5c4234a7 100644
--- a/dwarflint/addr-record.cc
+++ b/dwarflint/addr-record.cc
@@ -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
diff --git a/dwarflint/addr-record.h b/dwarflint/addr-record.hh
index 1542ff31..1542ff31 100644
--- a/dwarflint/addr-record.h
+++ b/dwarflint/addr-record.hh
diff --git a/dwarflint/check_debug_abbrev.cc b/dwarflint/check_debug_abbrev.cc
index 27effb5d..a46f0e8e 100644
--- a/dwarflint/check_debug_abbrev.cc
+++ b/dwarflint/check_debug_abbrev.cc
@@ -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");
}
diff --git a/dwarflint/check_debug_aranges.cc b/dwarflint/check_debug_aranges.cc
index 4283254a..88bc7c91 100644
--- a/dwarflint/check_debug_aranges.cc
+++ b/dwarflint/check_debug_aranges.cc
@@ -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 ()
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc
index 8489819d..c9bced67 100644
--- a/dwarflint/check_debug_info.cc
+++ b/dwarflint/check_debug_info.cc
@@ -32,16 +32,17 @@
#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. */
diff --git a/dwarflint/check_debug_info.hh b/dwarflint/check_debug_info.hh
index d5aa1a30..01189d14 100644
--- a/dwarflint/check_debug_info.hh
+++ b/dwarflint/check_debug_info.hh
@@ -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"
diff --git a/dwarflint/check_debug_line.cc b/dwarflint/check_debug_line.cc
index 046364e2..64c1a09a 100644
--- a/dwarflint/check_debug_line.cc
+++ b/dwarflint/check_debug_line.cc
@@ -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"
diff --git a/dwarflint/check_debug_loc_range.cc b/dwarflint/check_debug_loc_range.cc
index da82e00c..6f5251ad 100644
--- a/dwarflint/check_debug_loc_range.cc
+++ b/dwarflint/check_debug_loc_range.cc
@@ -41,9 +41,10 @@
#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
diff --git a/dwarflint/check_debug_loc_range.hh b/dwarflint/check_debug_loc_range.hh
index c6414032..4f5ac452 100644
--- a/dwarflint/check_debug_loc_range.hh
+++ b/dwarflint/check_debug_loc_range.hh
@@ -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
diff --git a/dwarflint/check_debug_pub.cc b/dwarflint/check_debug_pub.cc
index e649888d..354a6316 100644
--- a/dwarflint/check_debug_pub.cc
+++ b/dwarflint/check_debug_pub.cc
@@ -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)
diff --git a/dwarflint/check_duplicate_DW_tag_variable.cc b/dwarflint/check_duplicate_DW_tag_variable.cc
index 1a7d027d..3fb11632 100644
--- a/dwarflint/check_duplicate_DW_tag_variable.cc
+++ b/dwarflint/check_duplicate_DW_tag_variable.cc
@@ -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;
diff --git a/dwarflint/check_dups_abstract_origin.cc b/dwarflint/check_dups_abstract_origin.cc
index a45cd660..ec786561 100644
--- a/dwarflint/check_dups_abstract_origin.cc
+++ b/dwarflint/check_dups_abstract_origin.cc
@@ -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;
diff --git a/dwarflint/check_expected_trees.cc b/dwarflint/check_expected_trees.cc
index 0f8f369f..26f0375c 100644
--- a/dwarflint/check_expected_trees.cc
+++ b/dwarflint/check_expected_trees.cc
@@ -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;
diff --git a/dwarflint/check_nodebug.cc b/dwarflint/check_nodebug.cc
index 56b0ca80..543daf5b 100644
--- a/dwarflint/check_nodebug.cc
+++ b/dwarflint/check_nodebug.cc
@@ -24,7 +24,7 @@
<http://www.openinventionnetwork.com>. */
#include "checks.hh"
-#include "messages.h"
+#include "messages.hh"
#include "sections.hh"
#include "option.hh"
diff --git a/dwarflint/check_range_out_of_scope.cc b/dwarflint/check_range_out_of_scope.cc
index c930aa21..df6cda79 100644
--- a/dwarflint/check_range_out_of_scope.cc
+++ b/dwarflint/check_range_out_of_scope.cc
@@ -31,6 +31,7 @@
#include "coverage.hh"
#include "pri.hh"
#include "check_debug_loc_range.hh"
+#include "misc.h"
using elfutils::dwarf;
diff --git a/dwarflint/checked_read.cc b/dwarflint/checked_read.cc
index fd5edebf..ced62bea 100644
--- a/dwarflint/checked_read.cc
+++ b/dwarflint/checked_read.cc
@@ -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,
diff --git a/dwarflint/checked_read.h b/dwarflint/checked_read.hh
index caeba92d..caeba92d 100644
--- a/dwarflint/checked_read.h
+++ b/dwarflint/checked_read.hh
diff --git a/dwarflint/coverage.cc b/dwarflint/coverage.cc
index 2cbf3b30..80e3be58 100644
--- a/dwarflint/coverage.cc
+++ b/dwarflint/coverage.cc
@@ -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
index d6418c2a..00000000
--- a/dwarflint/coverage.h
+++ /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
diff --git a/dwarflint/coverage.hh b/dwarflint/coverage.hh
index d2b418a2..e13344be 100644
--- a/dwarflint/coverage.hh
+++ b/dwarflint/coverage.hh
@@ -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
@@ -29,7 +29,72 @@
#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
{
diff --git a/dwarflint/cu_coverage.cc b/dwarflint/cu_coverage.cc
index 7fb0d3d6..9098806c 100644
--- a/dwarflint/cu_coverage.cc
+++ b/dwarflint/cu_coverage.cc
@@ -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 ());
diff --git a/dwarflint/dwarflint.cc b/dwarflint/dwarflint.cc
index a6d68a04..63fd8b71 100644
--- a/dwarflint/dwarflint.cc
+++ b/dwarflint/dwarflint.cc
@@ -24,7 +24,7 @@
<http://www.openinventionnetwork.com>. */
#include "dwarflint.hh"
-#include "messages.h"
+#include "messages.hh"
#include "checks.hh"
#include "main.hh"
diff --git a/dwarflint/highlevel_check.cc b/dwarflint/highlevel_check.cc
index fefc727b..17c69244 100644
--- a/dwarflint/highlevel_check.cc
+++ b/dwarflint/highlevel_check.cc
@@ -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"
diff --git a/dwarflint/locstats.cc b/dwarflint/locstats.cc
index 1b335ba6..83dafbb0 100644
--- a/dwarflint/locstats.cc
+++ b/dwarflint/locstats.cc
@@ -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>
diff --git a/dwarflint/low.cc b/dwarflint/low.cc
index 34dd76e7..30c2f2b3 100644
--- a/dwarflint/low.cc
+++ b/dwarflint/low.cc
@@ -28,7 +28,7 @@
#endif
#include "low.h"
-#include "messages.h"
+#include "messages.hh"
#include <stdarg.h>
bool
diff --git a/dwarflint/low.h b/dwarflint/low.h
index 7606557b..8f4d4424 100644
--- a/dwarflint/low.h
+++ b/dwarflint/low.h
@@ -28,7 +28,7 @@
#include "../libdw/libdw.h"
#include "../libebl/libebl.h"
-#include "reloc.h"
+#include "reloc.hh"
#ifdef __cplusplus
extern "C"
diff --git a/dwarflint/main.cc b/dwarflint/main.cc
index 823022af..16850628 100644
--- a/dwarflint/main.cc
+++ b/dwarflint/main.cc
@@ -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;
diff --git a/dwarflint/messages.cc b/dwarflint/messages.cc
index d96cf88d..784dffb7 100644
--- a/dwarflint/messages.cc
+++ b/dwarflint/messages.cc
@@ -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>
diff --git a/dwarflint/messages.h b/dwarflint/messages.hh
index af2048b7..d14230b0 100644
--- a/dwarflint/messages.h
+++ b/dwarflint/messages.hh
@@ -23,18 +23,12 @@
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
diff --git a/dwarflint/reloc.cc b/dwarflint/reloc.cc
index 53510a75..94730466 100644
--- a/dwarflint/reloc.cc
+++ b/dwarflint/reloc.cc
@@ -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"
diff --git a/dwarflint/reloc.h b/dwarflint/reloc.hh
index 5d65f385..e5d292ba 100644
--- a/dwarflint/reloc.h
+++ b/dwarflint/reloc.hh
@@ -31,72 +31,61 @@
#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
diff --git a/dwarflint/section_id.cc b/dwarflint/section_id.cc
index a9d28c69..8e594a7f 100644
--- a/dwarflint/section_id.cc
+++ b/dwarflint/section_id.cc
@@ -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>
diff --git a/dwarflint/section_id.h b/dwarflint/section_id.hh
index 1fe74b02..4b937d7f 100644
--- a/dwarflint/section_id.h
+++ b/dwarflint/section_id.hh
@@ -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,13 +23,8 @@
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
diff --git a/dwarflint/sections.cc b/dwarflint/sections.cc
index 201dac7f..a81d7dc6 100644
--- a/dwarflint/sections.cc
+++ b/dwarflint/sections.cc
@@ -32,7 +32,7 @@
#include "../libelf/gelf.h"
#include "sections.hh"
-#include "messages.h"
+#include "messages.hh"
#include "pri.hh"
#include "misc.h"
diff --git a/dwarflint/sections.ii b/dwarflint/sections.ii
index bc726d44..ef5ec213 100644
--- a/dwarflint/sections.ii
+++ b/dwarflint/sections.ii
@@ -1,2 +1,2 @@
-#include "section_id.h"
+#include "section_id.hh"
template<enum section_id> class section;
diff --git a/dwarflint/tables.cc b/dwarflint/tables.cc
index 82d4dd4b..a44f2a61 100644
--- a/dwarflint/tables.cc
+++ b/dwarflint/tables.cc
@@ -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
index 0aa5384e..00000000
--- a/dwarflint/tables.h
+++ /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
diff --git a/dwarflint/tables.hh b/dwarflint/tables.hh
index 16ee24dc..6208b893 100644
--- a/dwarflint/tables.hh
+++ b/dwarflint/tables.hh
@@ -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
diff --git a/dwarflint/where.h b/dwarflint/where.h
index 1cd5d55b..c5e22761 100644
--- a/dwarflint/where.h
+++ b/dwarflint/where.h
@@ -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>