From: Petr Machata Date: Thu, 7 Oct 2010 13:16:44 +0000 (+0200) Subject: dwarflint: Add form::cls to get the class of form in context of given attribute X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d2505a1f8a4106013605020190b56c0a3dbec5ad;p=thirdparty%2Felfutils.git dwarflint: Add form::cls to get the class of form in context of given attribute --- diff --git a/dwarflint/dwarf_version.cc b/dwarflint/dwarf_version.cc index f62992f96..bab5a7098 100644 --- a/dwarflint/dwarf_version.cc +++ b/dwarflint/dwarf_version.cc @@ -36,6 +36,7 @@ #include "../libdw/dwarf.h" #include #include +#include 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 (ffsl (result.to_ulong ())); +} + form_width_t form::width (cu const *cu) const { diff --git a/dwarflint/dwarf_version.hh b/dwarflint/dwarf_version.hh index db3e3e06f..520fa80ff 100644 --- a/dwarflint/dwarf_version.hh +++ b/dwarflint/dwarf_version.hh @@ -29,6 +29,7 @@ #include #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.