]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Drop transitional code
authorPetr Machata <pmachata@redhat.com>
Mon, 30 Nov 2009 12:49:24 +0000 (13:49 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:15 +0000 (14:55 +0200)
src/dwarflint/check_debug_info.cc
src/dwarflint/pri.cc
src/dwarflint/pri.hh

index bab45b5aa1e9c80bad32e265d57d71f9c1df226e..586560a7432142e7547fdff1549ad3fe00ab0c59 100644 (file)
    Network licensing program, please visit www.openinventionnetwork.com
    <http://www.openinventionnetwork.com>.  */
 
-// xxx drop as soon as not necessary
-#define __STDC_FORMAT_MACROS
-#define PRI_DIE "DIE 0x%" PRIx64
-#include <inttypes.h>
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include <cassert>
-#include <sstream>
 #include <algorithm>
 #include "../libdw/dwarf.h"
 
 #include "messages.h"
-#include "low.h"
 #include "pri.hh"
 #include "config.h"
 #include "check_debug_loc_range.hh"
@@ -63,8 +56,9 @@ namespace
        struct ref *ref = die_refs->refs + i;
        if (!addr_record_has_addr (&cu->die_addrs, ref->addr))
          {
-           wr_error (&ref->who,
-                     ": unresolved reference to " PRI_DIE ".\n", ref->addr);
+           wr_error (ref->who)
+             << "unresolved reference to " << pri::DIE (ref->addr)
+             << '.' << std::endl;
            retval = false;
          }
       }
@@ -99,10 +93,10 @@ namespace
               reference is valid, which it is.  But warn about this
               anyway, perhaps local reference could be formed on
               smaller number of bytes.  */
-           wr_message (mc_impact_2 | mc_acc_suboptimal | mc_die_rel,
-                       &ref->who,
-                       ": local reference to " PRI_DIE " formed as global.\n",
-                       ref->addr);
+           wr_message (ref->who,
+                       cat (mc_impact_2, mc_acc_suboptimal, mc_die_rel))
+             << "local reference to " << pri::DIE (ref->addr)
+             << " formed as global." << std::endl;
        }
 
     return retval;
@@ -340,9 +334,9 @@ namespace
     assert (ctx->ctx->end > ctx->ctx->begin);
     if (addr > (uint64_t)(ctx->ctx->end - ctx->ctx->begin))
       {
-       wr_error (ctx->where,
-                 ": invalid reference outside the CU: 0x%" PRIx64 ".\n",
-                 addr);
+       wr_error (*ctx->where)
+         << "invalid reference outside the CU: " << pri::hex (addr)
+         << '.' << std::endl;
        return;
       }
 
@@ -365,11 +359,12 @@ namespace
   check_strp (uint64_t addr, struct value_check_cb_ctx const *ctx)
   {
     if (ctx->strings == NULL)
-      wr_error (ctx->where, ": strp attribute, but no .debug_str data.\n");
+      wr_error (*ctx->where)
+       << "strp attribute, but no .debug_str data." << std::endl;
     else if (addr >= ctx->strings->d_size)
-      wr_error (ctx->where,
-               ": Invalid offset outside .debug_str: 0x%" PRIx64 ".\n",
-               addr);
+      wr_error (*ctx->where)
+       << "invalid offset outside .debug_str: " << pri::hex (addr)
+       << '.' << std::endl;
     else
       {
        /* Record used part of .debug_str.  */
@@ -380,9 +375,9 @@ namespace
        while (strp < data_end && *strp != 0)
          ++strp;
        if (strp == data_end)
-         wr_error (ctx->where,
-                   ": String at .debug_str: 0x%" PRIx64
-                   " is not zero-terminated.\n", addr);
+         wr_error (*ctx->where)
+           << "string at .debug_str: " << pri::hex (addr)
+           << " is not zero-terminated." << std::endl;
 
        if (ctx->strings_coverage != NULL)
          coverage_add (ctx->strings_coverage, addr, strp - startp + 1);
@@ -394,9 +389,9 @@ namespace
   check_rangeptr (uint64_t value, struct value_check_cb_ctx const *ctx)
   {
     if ((value % ctx->cu->head->address_size) != 0)
-      wr_message (mc_ranges | mc_impact_2, ctx->where,
-                 ": rangeptr value %#" PRIx64
-                 " not aligned to CU address size.\n", value);
+      wr_message (*ctx->where, cat (mc_ranges, mc_impact_2))
+       << "rangeptr value " << pri::hex (value)
+       << " not aligned to CU address size." << std::endl;
     ctx->cu_coverage->need_ranges = true;
     ref_record_add (&ctx->cu->range_refs, value, ctx->where);
   }
@@ -475,10 +470,10 @@ namespace
            else if (sibling_addr != die_off)
              {
                DEF_PREV_WHERE;
-               wr_error (&prev_where,
-                         ": This DIE claims that its sibling is 0x%"
-                         PRIx64 ", but it's actually 0x%" PRIx64 ".\n",
-                         sibling_addr, die_off);
+               wr_error (prev_where)
+                 << "this DIE claims that its sibling is "
+                 << pri::hex (sibling_addr) << " but it's actually "
+                 << pri::hex (die_off) << '.' << std::endl;
              }
            sibling_addr = 0;
          }
@@ -513,18 +508,16 @@ namespace
        prev_die_off = die_off;
        got_die = true;
        if (dump_die_offsets)
-         fprintf (stderr, "%s: abbrev %" PRId64 "\n",
-                  where_fmt (&where, NULL), abbr_code);
+         std::cerr << where << ": abbrev " << abbr_code << std::endl;
 
        /* Find the abbrev matching the code.  */
        prev_abbrev = abbrev;
        abbrev = abbrev_table_find_abbrev (abbrevs, abbr_code);
        if (abbrev == NULL)
          {
-           wr_error (&where,
-                     ": abbrev section at 0x%" PRIx64
-                     " doesn't contain code %" PRIu64 ".\n",
-                     abbrevs->offset, abbr_code);
+           wr_error (where)
+             << "abbrev section at " << pri::hex (abbrevs->offset)
+             << " doesn't contain code " << abbr_code << '.' << std::endl;
            return -1;
          }
        abbrev->used = true;
@@ -949,9 +942,9 @@ namespace
       }
 
     if (sibling_addr != 0)
-      wr_error (&where,
-               ": this DIE should have had its sibling at 0x%"
-               PRIx64 ", but the DIE chain ended.\n", sibling_addr);
+      wr_error (where)
+       << "this DIE should have had its sibling at " << pri::hex (sibling_addr)
+       << ", but the DIE chain ended." << std::endl;
 
     return got_die ? 1 : 0;
   }
index 166428f1363ccf3998ccbe3da50f416d8ee8b197..1beb799ab44c4084fc56c9894073911d47e431fc 100644 (file)
@@ -36,6 +36,8 @@ std::ostream &
 pri::operator << (std::ostream &os, pri::hex const &obj)
 {
   std::stringstream ss;
+  if (obj.pre)
+    ss << obj.pre << " ";
   ss << std::hex << "0x" << obj.value;
   return os << ss.str ();
 }
index 54d47ebfa6274ae4326c26cf3798a0eb73a7372a..5ce28870dd9058b710c03e2d275333992b782f3d 100644 (file)
@@ -78,18 +78,24 @@ namespace pri
   class hex
   {
     Dwarf_Off value;
+    char const *const pre;
   public:
-    hex (Dwarf_Off a_value)
+    hex (Dwarf_Off a_value, char const *a_pre = NULL)
       : value (a_value)
+      , pre (a_pre)
     {}
     friend std::ostream &operator << (std::ostream &os, hex const &obj);
   };
   std::ostream &operator << (std::ostream &os, hex const &obj);
 
-  struct addr : public hex {
+  struct addr: public hex {
     addr (Dwarf_Off off) : hex (off) {}
   };
 
+  struct DIE: public hex {
+    DIE (Dwarf_Off off) : hex (off, "DIE ") {}
+  };
+
   class range
   {
     Dwarf_Off start;