]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: move read_sc_value to checked_read module
authorPetr Machata <pmachata@redhat.com>
Mon, 11 Oct 2010 21:33:19 +0000 (23:33 +0200)
committerPetr Machata <pmachata@redhat.com>
Mon, 11 Oct 2010 21:33:19 +0000 (23:33 +0200)
dwarflint/check_debug_info.cc
dwarflint/checked_read.cc
dwarflint/checked_read.hh

index 022c71fe047501aef52c20d8d04af8703d1ad341..a8877f7efe2a84db05df0c5f2d98390ef8cc7625 100644 (file)
@@ -495,37 +495,6 @@ namespace
     ref_record_add (&ctx->cu->decl_file_refs, value, ctx->where);
   }
 
-  /// Read value depending on the form width and storage class.
-  bool
-  read_sc_value (uint64_t *valuep, form const *form, cu const *cu,
-                read_ctx *ctx, where *wherep)
-  {
-    form_width_t width = form->width (cu);
-    switch (width)
-      {
-      case fw_0:
-       // Who knows, DW_FORM_flag_absent might turn up one day...
-       assert (form->name () == DW_FORM_flag_present);
-       *valuep = 1;
-       return true;
-
-      case fw_1:
-      case fw_2:
-      case fw_4:
-      case fw_8:
-       return read_ctx_read_var (ctx, width, valuep);
-
-      case fw_uleb:
-      case fw_sleb:
-       return checked_read_leb128 (ctx, width, valuep,
-                                   wherep, "attribute value");
-
-      case fw_unknown:
-       ;
-      }
-    UNREACHABLE;
-  }
-
   /*
     Returns:
     -1 in case of error
@@ -659,7 +628,7 @@ namespace
            if (ver->form_class (form, attribute) == cl_indirect)
              {
                uint64_t value;
-               if (!read_sc_value (&value, form, cu, ctx, &where))
+               if (!read_sc_value (&value, form->width (cu), ctx, &where))
                  return -1;
                form_name = value;
                form = check_debug_abbrev::check_form
@@ -809,7 +778,7 @@ namespace
              }
            else
              {
-               if (!read_sc_value (&value, form, cu, ctx, &where))
+               if (!read_sc_value (&value, form->width (cu), ctx, &where))
                  {
                    // Note that for fw_uleb and fw_sleb we report the
                    // error the second time now.
index 131449f57f91fa8114e219d8ba7d0e42d56261cd..4b73152dc4489fe13a472027ca378ee1fc62440b 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "checked_read.hh"
 #include "messages.hh"
+#include "misc.hh"
 
 bool
 read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
@@ -148,3 +149,30 @@ checked_read_leb128 (read_ctx *ctx, form_width_t width, uint64_t *ret,
   else
     return checked_read_uleb128 (ctx, ret, where, what);
 }
+
+bool
+read_sc_value (uint64_t *valuep, form_width_t width,
+              read_ctx *ctx, where const *where)
+{
+  switch (width)
+    {
+    case fw_0:
+      *valuep = 1;
+      return true;
+
+    case fw_1:
+    case fw_2:
+    case fw_4:
+    case fw_8:
+      return read_ctx_read_var (ctx, width, valuep);
+
+    case fw_uleb:
+    case fw_sleb:
+      return checked_read_leb128 (ctx, width, valuep,
+                                 where, "attribute value");
+
+    case fw_unknown:
+      ;
+    }
+  UNREACHABLE;
+}
index 612ec6977fff4ea07353659b7e75a6fdb574fb8b..39927e5b13569712d867e07106ba4887dca9c5b2 100644 (file)
@@ -47,4 +47,8 @@ bool checked_read_sleb128 (read_ctx *ctx, int64_t *ret,
 bool checked_read_leb128 (read_ctx *ctx, form_width_t width, uint64_t *ret,
                          where const *where, const char *what);
 
+/// Read value depending on the form width and storage class.
+bool read_sc_value (uint64_t *valuep, form_width_t width,
+                   read_ctx *ctx, where const *where);
+
 #endif//DWARFLINT_CHECKED_READ_HH