]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Merge branch 'dwarf' into roland/dwarf-macinfo
authorRoland McGrath <roland@redhat.com>
Fri, 8 May 2009 01:43:03 +0000 (18:43 -0700)
committerRoland McGrath <roland@redhat.com>
Fri, 8 May 2009 01:43:03 +0000 (18:43 -0700)
Conflicts:
libdw/c++/dwarf
libdw/c++/values.cc

1  2 
libdw/c++/dwarf
libdw/c++/values.cc

diff --cc libdw/c++/dwarf
index 3092c089eb1f7f24319219686d43562738190d1d,45dc558f71a011b080d792f6c2a7045cdcdbb0ce..93ce401ab2a6ab0374ded14e581cdf6c22f3809a
@@@ -380,7 -391,7 +391,8 @@@ namespace elfutil
      class file_table;
      class line_table;
      class line_entry;
 +    class macro_info_table;
+     class dwarf_enum;
  
      class debug_info_entry
      {
            case VS_lineptr:
              return line_info () == other.line_info ();
  
 -          case VS_macptr:     // XXX punt for now, treat as constant
 -            /*FALLTHRU*/
 +          case VS_macptr:
 +             return macro_info () == macro_info ();
 +
-           case VS_constant:
            case VS_dwarf_constant:
+             return constant () == other.constant ();
+           case VS_constant:
+             if (constant_is_integer ())
+               return (other.constant_is_integer ()
+                       && constant () == other.constant ());
+             return (!other.constant_is_integer ()
+                     && constant_block () == other.constant_block ());
            case VS_source_line:
+             return source_line () == other.source_line ();
            case VS_source_column:
-             return constant () == other.constant ();
+             return source_column () == other.source_column ();
  
            case VS_identifier:
-             return !strcmp (identifier (), other.identifier ());
+             return subr::name_equal<typeof (other.identifier ())> ()
+               (identifier (), other.identifier ());
  
            case VS_string:
-             return !strcmp (string (), other.string ());
+             return subr::name_equal<typeof (other.string ())> ()
+               (string (), other.string ());
  
            case VS_address:
              return address () == other.address ();
        }
      };
  
 +    class macro_entry;                // XXX
 +    // The DW_AT_macro_info attribute yields a line info table.
 +    class macro_info_table
 +    {
 +      friend class attr_value;
 +    private:
 +      compile_unit _m_cu;
 +
 +      macro_info_table (const debug_info_entry &die) : _m_cu (die) {}
 +
 +    public:
 +      typedef macro_entry value_type;
 +
 +      macro_info_table (const macro_info_table &t) : _m_cu (t._m_cu) {}
 +
 +      typedef void **const_iterator; // XXX
 +      const_iterator begin () const { return NULL; } // dummy
 +      const_iterator end () const { return NULL; }   // dummy
 +
 +      template<typename table>
 +      inline bool operator== (const table &other) const
 +      {
 +      return std::equal (begin (), end (), other.begin ());
 +      }
 +      template<typename table>
 +      inline bool operator!= (const table &other) const
 +      {
 +      return !(*this == other);
 +      }
 +    };
 +
+     class dwarf_enum
+     {
+       friend class attr_value;
+     private:
+       const attr_value _m_attr;
+       dwarf_enum (const attr_value &attr) : _m_attr (attr) {}
+     public:
+       inline operator unsigned int () const
+       {
+       return _m_attr.constant ();
+       }
+       std::string to_string () const;
+       const char *identifier () const;
+       const char *name () const;
+     };
      // This describes one attribute, equivalent to pair<const int, attr_value>.
      class attribute
      {
index 3a52dbe456925b34966161301ac7e0dfb011865f,8b278c49b9013f7aac83f78cc019c34fccc08708..21fd66a59b8e24e5ed438d1a1b3800ef764e319f
@@@ -292,55 -323,9 +323,19 @@@ dwarf::attr_value::constant_block () co
        throw std::runtime_error ("XXX wrong form");
      }
  
-   const uint8_t *const begin = reinterpret_cast<const uint8_t *> (block.data);
-   const uint8_t *const end = begin + block.length;
-   return const_vector<uint8_t> (begin, end);
+   return const_vector<uint8_t> (block);
 +}
 +
 +const dwarf::macro_info_table
 +dwarf::attr_value::macro_info () const
 +{
 +  assert (dwarf_whatattr (thisattr ()) == DW_AT_macro_info);
 +  CUDIE (cudie, _m_attr.cu);
 +  debug_info_entry die;
 +  die._m_die = cudie;
 +  return macro_info_table (die);
  }
  \f
- // dwarf::location_attr
- const dwarf::location_attr
- dwarf::attr_value::location () const
- {
-   if (what_space () != VS_location)
-     throw std::runtime_error ("XXX not a location");
-   return location_attr (*this);
- }
- bool
- dwarf::location_attr::singleton () const
- {
-   switch (dwarf_whatform (_m_attr.thisattr ()))
-     {
-     case DW_FORM_block:
-     case DW_FORM_block1:
-     case DW_FORM_block2:
-     case DW_FORM_block4:
-       return true;
-     }
-   return false;
- }
- string
- dwarf::location_attr::to_string () const
- {
-   if (singleton ())
-     return "XXX";
-   return hex_string (_m_attr.constant (), "#");
- }
\f
  // dwarf::range_list
  
  dwarf::range_list::const_iterator::const_iterator (Dwarf_Attribute *attr,