#include <list>
#include <map>
#include <set>
+#include <vector>
#include <stack>
#include <algorithm>
#include <functional>
::Dwarf_Word constant () const;
::Dwarf_Sword signed_constant () const;
// XXX better type??
- std::string constant_block () const;
+ std::vector<uint8_t> constant_block () const;
// XXX known enums
// dwarf_enum dwarf_constant () const;
inline bool operator== (const value &other) const
{
const value_space what = what_space ();
- if (other.what_space () == what)
+ if (likely (other.what_space () == what))
switch (what)
{
case VS_reference:
case VS_unit_reference:
- // return reference () == other.reference ();
- return true; // XXX temporary stub
+ // XXX Reference identity check (?)
+ return reference ().offset () == other.reference ().offset ();
case VS_flag:
return flag () == other.flag ();
}
static string
-hex_string (Dwarf_Word value)
+hex_string (Dwarf_Word value, const char *before = "", const char *after = "")
{
std::ostringstream os;
os.setf(std::ios::hex, std::ios::basefield);
- os << value;
+ os << before << value << after;
return os.str ();
}
case VS_reference:
case VS_unit_reference:
- return "XXX";
+ return hex_string (reference ().offset (), "[", "]");
case VS_source_file:
return source_file ().to_string ();
return result;
}
-string
+vector<uint8_t>
dwarf::attr_value::constant_block () const
{
Dwarf_Block block;
throw std::runtime_error ("XXX wrong form");
}
- return std::string (reinterpret_cast<const char *> (block.data),
- block.length);
+ const uint8_t *const begin = reinterpret_cast<const uint8_t *> (block.data);
+ const uint8_t *const end = begin + block.length;
+ return vector<uint8_t> (begin, end);
}
\f
// dwarf::source_file
{
if (singleton ())
return "XXX";
- return hex_string (_m_attr.constant ());
+ return hex_string (_m_attr.constant (), "#");
}
\f
// dwarf::range_list