From: Petr Machata Date: Wed, 6 Oct 2010 18:37:23 +0000 (+0200) Subject: dwarflint: Add form::storage_class X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec5f0f71597e7046bcba9b4c3e45f3f1118ce479;p=thirdparty%2Felfutils.git dwarflint: Add form::storage_class --- diff --git a/dwarflint/tables.cc b/dwarflint/tables.cc index 40c07cddd..b065e846c 100644 --- a/dwarflint/tables.cc +++ b/dwarflint/tables.cc @@ -101,11 +101,14 @@ namespace { protected: form_width_t _m_width; + storage_class_t _m_storclass; public: - full_form (int a_name, dw_class_set a_classes, form_width_t a_width) + full_form (int a_name, dw_class_set a_classes, + form_width_t a_width, storage_class_t a_storclass) : basic_form (a_name, a_classes) , _m_width (a_width) + , _m_storclass (a_storclass) {} form_width_t @@ -113,6 +116,12 @@ namespace { return _m_width; } + + storage_class_t + storage_class () const + { + return _m_storclass; + } }; struct width_off { @@ -127,7 +136,7 @@ namespace } }; - template + template class selwidth_form : public basic_form { @@ -142,25 +151,30 @@ namespace { return WidthSel::width (cu); } + + storage_class_t + storage_class () const + { + return StorClass; + } }; - typedef selwidth_form offset_form; - typedef selwidth_form address_form; + typedef selwidth_form offset_form; + typedef selwidth_form address_form; - template - class selclass_form + template + struct preset_form : public full_form { - public: - selclass_form (int a_name, form_width_t a_width) - : full_form (a_name, dw_class_set (Clss...), a_width) + preset_form (int a_name, form_width_t a_width) + : full_form (a_name, dw_class_set (Clss...), a_width, StorClass) {} }; - typedef selclass_form block_form; - typedef selclass_form const_form; - typedef selclass_form ref_form; - typedef selclass_form flag_form; + typedef preset_form block_form; + typedef preset_form const_form; + typedef preset_form ref_form; + typedef preset_form flag_form; struct dwarf_row { int val; @@ -230,12 +244,20 @@ namespace {0, dw_class_set ()} }; + struct string_form + : public preset_form + { + string_form (int a_name) + : preset_form (a_name, fw_unknown) + {} + }; + struct dwarf_2_forms : public form_table { dwarf_2_forms () { - add (new block_form (DW_FORM_block, fw_leb)); + add (new block_form (DW_FORM_block, fw_uleb)); add (new block_form (DW_FORM_block1, fw_1)); add (new block_form (DW_FORM_block2, fw_2)); add (new block_form (DW_FORM_block4, fw_4)); @@ -244,8 +266,8 @@ namespace add (new const_form (DW_FORM_data2, fw_2)); add (new const_form (DW_FORM_data4, fw_4)); add (new const_form (DW_FORM_data8, fw_8)); - add (new const_form (DW_FORM_sdata, fw_leb)); - add (new const_form (DW_FORM_udata, fw_leb)); + add (new const_form (DW_FORM_sdata, fw_sleb)); + add (new const_form (DW_FORM_udata, fw_uleb)); add (new flag_form (DW_FORM_flag, fw_1)); @@ -253,9 +275,9 @@ namespace add (new ref_form (DW_FORM_ref2, fw_2)); add (new ref_form (DW_FORM_ref4, fw_4)); add (new ref_form (DW_FORM_ref8, fw_8)); - add (new ref_form (DW_FORM_ref_udata, fw_leb)); + add (new ref_form (DW_FORM_ref_udata, fw_uleb)); - add (new full_form (DW_FORM_string, cl_string, fw_unknown)); + add (new string_form (DW_FORM_string)); add (new offset_form (DW_FORM_strp, cl_string)); add (new address_form (DW_FORM_addr, cl_address)); add (new address_form (DW_FORM_ref_addr, cl_reference)); @@ -314,8 +336,9 @@ namespace {0, dw_class_set ()} }; - typedef selclass_form dw3_data_form; + typedef preset_form dw3_data_form; struct dwarf_3_forms : public form_table @@ -361,6 +384,14 @@ namespace {0, dw_class_set ()} }; + struct exprloc_form + : public preset_form + { + exprloc_form (int a_name) + : preset_form (a_name, fw_uleb) + {} + }; + struct dwarf_4_forms : public form_table { @@ -371,7 +402,7 @@ namespace add (new offset_form (DW_FORM_sec_offset, cl_lineptr, cl_loclistptr, cl_macptr, cl_rangelistptr)); - add (new selclass_form (DW_FORM_exprloc, fw_leb)); + add (new exprloc_form (DW_FORM_exprloc)); add (new flag_form (DW_FORM_flag_present, fw_0)); add (new ref_form (DW_FORM_ref_sig8, fw_8)); } diff --git a/dwarflint/tables.hh b/dwarflint/tables.hh index 931c46de7..85746ff4d 100644 --- a/dwarflint/tables.hh +++ b/dwarflint/tables.hh @@ -66,7 +66,8 @@ enum form_width_t fw_2 = 2, fw_4 = 4, fw_8 = 8, - fw_leb, + fw_sleb, + fw_uleb, fw_unknown }; @@ -86,12 +87,16 @@ public: virtual dw_class_set const &classes () const = 0; /// Return width of data stored with given form. CU may be NULL if - /// you are sure that the form size doesn't depend on addr_64 or - /// off. Forms for which width makes no sense, such as - /// DW_FORM_string, get fw_unknown. Unknown forms get an assert. + /// you are sure that the form size doesn't depend on bitness of + /// address_size or offset_size. + /// + /// Forms for which width makes no sense (namely those in the + /// storage class of sc_string) get fw_unknown. Unknown forms get + /// an assert. virtual form_width_t width (cu const *cu = NULL) const = 0; - //virtual storage_class_t storage_class () const = 0; + /// Return storage class of given form. Closely related to width. + virtual storage_class_t storage_class () const = 0; virtual ~form () {} }; @@ -125,6 +130,14 @@ public: /// Return dwarf_version object for latest supported DWARF version. static dwarf_version const *get_latest () __attribute__ ((pure)); + + /// Return dwarf_version that represents SOURCE extended with + /// EXTENSION. Currently this probably has no use, but one obvious + /// candidate usage is representing GNU extensions over core DWARF. + /// Extension can contain overrides of the source dwarf_version + /// object, and these overrides take precedence. + static dwarf_version const *extend (dwarf_version const *source, + dwarf_version const *extension); }; /// Check that the form is suitable for the DW_AT_sibling attribute.