]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
New class hl_ctx for storing information useful across high-level checks
authorPetr Machata <pmachata@redhat.com>
Tue, 17 Feb 2009 15:04:17 +0000 (16:04 +0100)
committerPetr Machata <pmachata@redhat.com>
Tue, 17 Feb 2009 15:04:17 +0000 (16:04 +0100)
src/dwarflint-hl.cc
src/dwarflint.c
src/dwarflint.h

index 1c7c495d3ddcee20b2e83f4b42584fed6166a1be..970b8621585ef332b594fa8280f6017e783f86cd 100644 (file)
@@ -47,18 +47,38 @@ namespace
   }
 }
 
-bool
-check_matching_ranges (Dwarf *dwarf)
+struct hl_ctx
+{
+  elfutils::dwarf dw;
+
+  hl_ctx (Dwarf *dwarf)
+    : dw (dwarf)
+  {
+  }
+};
+
+hl_ctx *
+hl_ctx_new (Dwarf *dwarf)
 {
-  elfutils::dwarf dw(dwarf);
+  return new hl_ctx (dwarf);
+}
+
+void
+hl_ctx_delete (hl_ctx *hlctx)
+{
+  delete hlctx;
+}
 
+bool
+check_matching_ranges (struct hl_ctx *hlctx)
+{
   struct where where_ref = WHERE (sec_info, NULL);
   struct where where_ar = WHERE (sec_aranges, NULL);
   where_ar.ref = &where_ref;
   struct where where_r = WHERE (sec_ranges, NULL);
   where_r.ref = &where_ref;
 
-  const elfutils::dwarf::aranges_map &aranges = dw.aranges ();
+  const elfutils::dwarf::aranges_map &aranges = hlctx->dw.aranges ();
   for (elfutils::dwarf::aranges_map::const_iterator i = aranges.begin ();
        i != aranges.end (); ++i)
     {
@@ -98,5 +118,5 @@ check_matching_ranges (Dwarf *dwarf)
                    it->first, it->second);
     }
 
-  return dwarf != NULL;
+  return true;
 }
index 65df847759df93ae663628634cc486a011905302..ddc480f70363ea43228ba200adb5971607880a14 100644 (file)
@@ -998,12 +998,14 @@ process_file (int fd __attribute__((unused)),
   if (loc_data.data != NULL && cu_chain != NULL)
     check_loc_or_range_structural (dwarf, &loc_data, cu_chain);
 
+  struct hl_ctx *hlctx = hl_ctx_new (dwarf);
+
   if (aranges_data.data != NULL)
     {
       read_ctx_init (&ctx, dwarf, aranges_data.data);
       if (check_aranges_structural (&ctx, cu_chain)
          && ranges_sound)
-       check_matching_ranges (dwarf);
+       check_matching_ranges (hlctx);
     }
 
   if (pubnames_data.data != NULL)
@@ -1023,6 +1025,7 @@ process_file (int fd __attribute__((unused)),
   if (file.ebl != NULL)
     ebl_closebackend (file.ebl);
   free (file.sec);
+  hl_ctx_delete (hlctx);
 }
 
 static void
index b05ee992773450feac766d2121a503b090899bbd..e92d343cbdb3d090feb3851d7cf311462eff9fdb 100644 (file)
@@ -12,8 +12,12 @@ extern "C"
 
   /* Entry points for high-level checks.  */
 
+  struct hl_ctx;
+
   /* Check that .debug_aranges and .debug_ranges match.  */
-  extern bool check_matching_ranges (Dwarf *dwarf);
+  extern struct hl_ctx *hl_ctx_new (Dwarf *dwarf);
+  extern void hl_ctx_delete (struct hl_ctx *hlctx);
+  extern bool check_matching_ranges (struct hl_ctx *hlctx);
 
 
   /* Functions and data structures describing location in Dwarf.  */