diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-11-26 15:46:36 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-11-26 15:46:36 +0000 |
commit | 7eef8ce6f7cc1c410b8a78b66137d9448a92155b (patch) | |
tree | ff69099b17a4e2cd1baeba63eb3026059c347568 /trace_parser.hpp | |
parent | f84c70e16aaf953f8984981456f5baf8eada7153 (diff) |
More compact struct representation.
Diffstat (limited to 'trace_parser.hpp')
-rw-r--r-- | trace_parser.hpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/trace_parser.hpp b/trace_parser.hpp index 254141c..e9f8c42 100644 --- a/trace_parser.hpp +++ b/trace_parser.hpp @@ -59,6 +59,9 @@ protected: typedef std::map<size_t, Call::Signature *> FunctionMap; FunctionMap functions; + typedef std::map<size_t, Struct::Signature *> StructMap; + StructMap structs; + typedef std::map<size_t, Enum *> EnumMap; EnumMap enums; @@ -311,14 +314,30 @@ public: } Value *parse_struct() { - size_t length = read_uint(); - /* XXX */ - for (size_t i = 0; i < length; ++i) { - std::string name = read_name(); - Value *value = parse_value(); - std::cout << " " << name << " = " << value << "\n"; + size_t id = read_uint(); + + Struct::Signature *sig; + StructMap::const_iterator it = structs.find(id); + if (it == structs.end()) { + sig = new Struct::Signature; + sig->name = read_string(); + unsigned size = read_uint(); + for (unsigned i = 0; i < size; ++i) { + sig->member_names.push_back(read_string()); + } + structs[id] = sig; + } else { + sig = it->second; + } + assert(sig); + + Struct *value = new Struct(sig); + + for (size_t i = 0; i < sig->member_names.size(); ++i) { + value->members[i] = parse_value(); } - return NULL; + + return value; } Value *parse_opaque() { |