+2009-09-25 Roland McGrath <roland@redhat.com>
+
+ * c++/values.cc (dwarf::range_list::const_iterator::const_iterator):
+ For begin case, actually get the offset from the attribute!
+ (dwarf::location_attr::begin): Likewise.
+ * c++/dwarf (dwarf::range_list, dwarf::location_attr): Fix iterator
+ initializers accordingly.
+
2009-09-21 Roland McGrath <roland@redhat.com>
* c++/dwarf-knowledge.cc (expected_value_space): DW_AT_const_value can
::Dwarf_CU *_m_cu;
ptrdiff_t _m_offset;
- const_iterator (Dwarf_Attribute *, ptrdiff_t);
+ const_iterator (Dwarf_Attribute *, ptrdiff_t offset);
public:
// Default constructor: only valid for operator=.
void advance ();
- inline const_iterator (Dwarf_Attribute *attr, ptrdiff_t offset)
- : range_list::const_iterator (attr, offset), _m_block ()
+ // For end iterator.
+ inline explicit const_iterator (Dwarf_Attribute *attr)
+ : dwarf::range_list::const_iterator (attr, 1), _m_block ()
{}
public:
const_iterator begin () const;
inline const_iterator end () const
{
- return const_iterator (_m_attr.thisattr (), 1);
+ return const_iterator (_m_attr.thisattr ());
}
inline bool empty () const
ptrdiff_t offset)
: _m_base (-1), _m_begin (0), _m_end (0), _m_cu (attr->cu), _m_offset (offset)
{
+ if (_m_offset == 0)
+ {
+ Dwarf_Word ofs;
+ xif (attr, dwarf_formudata (attr, &ofs) < 0); // XXX __libdw_formptr
+ _m_offset = ofs;
+ }
}
static bool
dwarf::location_attr::const_iterator
dwarf::location_attr::begin () const
{
- const_iterator i (_m_attr.thisattr (), 0);
+ const_iterator i (_m_attr.thisattr ());
if (is_list ())
- i.advance ();
+ {
+ // XXX __libdw_formptr
+ Dwarf_Word offset;
+ xif (_m_attr.thisattr (),
+ dwarf_formudata (_m_attr.thisattr (), &offset) < 0);
+ i._m_offset = offset;
+ i.advance ();
+ }
else
- xif (_m_attr.thisattr (),
- dwarf_formblock (_m_attr.thisattr (), &i._m_block) < 0);
+ {
+ xif (_m_attr.thisattr (),
+ dwarf_formblock (_m_attr.thisattr (), &i._m_block) < 0);
+ i._m_base = 0;
+ i._m_end = -1;
+ i._m_offset = 0;
+ }
return i;
}
throw std::runtime_error ("incrementing end iterator");
if (_m_offset == 0)
- // Singleton, now at end.
- _m_offset = 1;
+ {
+ // Singleton, now at end.
+ _m_offset = 1;
+ _m_block.data = NULL;
+ _m_block.length = 0;
+ }
else
// Advance to next list entry.
advance ();