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
{
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,