]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Add form::cls to get the class of form in context of given attribute
authorPetr Machata <pmachata@redhat.com>
Thu, 7 Oct 2010 13:16:44 +0000 (15:16 +0200)
committerPetr Machata <pmachata@redhat.com>
Thu, 7 Oct 2010 13:16:44 +0000 (15:16 +0200)
dwarflint/dwarf_version.cc
dwarflint/dwarf_version.hh

index f62992f96870af6da14170c9bedc45dfbf49a42e..bab5a70983eb9a26bbf313a4b5098f21f7246f48 100644 (file)
@@ -36,6 +36,7 @@
 #include "../libdw/dwarf.h"
 #include <map>
 #include <cassert>
+#include <string.h>
 
 dw_class_set::dw_class_set (dw_class a, dw_class b, dw_class c,
                            dw_class d, dw_class e)
@@ -65,6 +66,16 @@ form::form (int a_name, dw_class_set a_classes,
   , _m_storclass (a_storclass)
 {}
 
+dw_class
+form::cls (attribute const *attribute) const
+{
+  assert (attribute != NULL);
+  dw_class_set result = classes ();
+  result &= attribute->classes ();
+  assert (result.count () == 1);
+  return static_cast<dw_class> (ffsl (result.to_ulong ()));
+}
+
 form_width_t
 form::width (cu const *cu) const
 {
index db3e3e06fb2b27e0c25902f30019275a1dda22d6..520fa80ff52792be69bab342d457c1d3f6580fea 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <bitset>
 #include "check_debug_info.ii"
+#include "dwarf_version.ii"
 
 enum dw_class
   {
@@ -109,6 +110,12 @@ public:
     return _m_classes;
   }
 
+  /// Answer a class of form given attribute as a context.  This
+  /// assumes that the result is exactly one class.  You must validate
+  /// the form via form_allowed before calling this.  If more than two
+  /// classes match, the form and attribute tables are ill-designed.
+  dw_class cls (attribute const *attribute) const;
+
   /// Return width of data stored with given form.  CU may be NULL if
   /// you are sure that the form size doesn't depend on bitness of
   /// address_size or offset_size.