]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Add form::storage_class
authorPetr Machata <pmachata@redhat.com>
Wed, 6 Oct 2010 18:37:23 +0000 (20:37 +0200)
committerPetr Machata <pmachata@redhat.com>
Wed, 6 Oct 2010 18:37:23 +0000 (20:37 +0200)
dwarflint/tables.cc
dwarflint/tables.hh

index 40c07cddd8a4da83bb6ad26299cc7cadb6ea8064..b065e846cd2a66d334e3fb4b8413ee0aafe76ab2 100644 (file)
@@ -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<class WidthSel>
+  template<class WidthSel, storage_class_t StorClass>
   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<width_off> offset_form;
-  typedef selwidth_form<width_addr> address_form;
+  typedef selwidth_form<width_off, sc_value> offset_form;
+  typedef selwidth_form<width_addr, sc_value> address_form;
 
-  template<dw_class... Clss>
-  class selclass_form
+  template<storage_class_t StorClass, dw_class... Clss>
+  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<cl_block> block_form;
-  typedef selclass_form<cl_constant> const_form;
-  typedef selclass_form<cl_reference> ref_form;
-  typedef selclass_form<cl_flag> flag_form;
+  typedef preset_form<sc_block, cl_block> block_form;
+  typedef preset_form<sc_value, cl_constant> const_form;
+  typedef preset_form<sc_value, cl_reference> ref_form;
+  typedef preset_form<sc_value, cl_flag> flag_form;
 
   struct dwarf_row {
     int val;
@@ -230,12 +244,20 @@ namespace
     {0,                                dw_class_set ()}
   };
 
+  struct string_form
+    : public preset_form<sc_string, cl_string>
+  {
+    string_form (int a_name)
+      : preset_form<sc_string, cl_string> (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<cl_constant, cl_lineptr, cl_loclistptr,
-                       cl_macptr, cl_rangelistptr> dw3_data_form;
+  typedef preset_form<sc_value,
+                     cl_constant, cl_lineptr, cl_loclistptr,
+                     cl_macptr, cl_rangelistptr> 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<sc_block, cl_exprloc>
+  {
+    exprloc_form (int a_name)
+      : preset_form<sc_block, cl_exprloc> (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<cl_exprloc> (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));
     }
index 931c46de7286c64276d9385c50378532b6fcef41..85746ff4d04de447205ea8a7d88e42eee31f924f 100644 (file)
@@ -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.