X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_dump.cpp;h=e6810b6afa63e209e156b096bb8a5197b2dc32ce;hb=3fd020297fd1ff94d80d27df5a871e73267f8b9b;hp=06c0079a5e2a8d9436a20ee91e3c71527fd12766;hpb=fc9939fc84a006ccddfad84b137b6915b1a55771;p=apitrace diff --git a/common/trace_dump.cpp b/common/trace_dump.cpp index 06c0079..e6810b6 100644 --- a/common/trace_dump.cpp +++ b/common/trace_dump.cpp @@ -24,6 +24,8 @@ **************************************************************************/ +#include + #include "formatter.hpp" #include "trace_dump.hpp" @@ -73,7 +75,7 @@ public: } void visit(Null *) { - os << "NULL"; + os << literal << "NULL" << normal; } void visit(Bool *node) { @@ -89,11 +91,15 @@ public: } void visit(Float *node) { + std::streamsize oldPrecision = os.precision(std::numeric_limits::digits10 + 1); os << literal << node->value << normal; + os.precision(oldPrecision); } void visit(Double *node) { + std::streamsize oldPrecision = os.precision(std::numeric_limits::digits10 + 1); os << literal << node->value << normal; + os.precision(oldPrecision); } void visit(String *node) { @@ -164,14 +170,32 @@ public: } } - void visit(Struct *s) { - const char *sep = ""; - os << "{"; + const char * + visitMembers(Struct *s, const char *sep = "") { for (unsigned i = 0; i < s->members.size(); ++i) { - os << sep << italic << s->sig->member_names[i] << normal << " = "; - _visit(s->members[i]); + const char *memberName = s->sig->member_names[i]; + Value *memberValue = s->members[i]; + + if (!memberName || !*memberName) { + // Anonymous structure + Struct *memberStruct = dynamic_cast(memberValue); + assert(memberStruct); + if (memberStruct) { + sep = visitMembers(memberStruct, sep); + continue; + } + } + + os << sep << italic << memberName << normal << " = ", + _visit(memberValue); sep = ", "; } + return sep; + } + + void visit(Struct *s) { + os << "{"; + visitMembers(s); os << "}"; } @@ -200,6 +224,10 @@ public: os << pointer << "0x" << std::hex << p->value << std::dec << normal; } + void visit(Repr *r) { + _visit(r->humanValue); + } + void visit(Call *call) { CallFlags callFlags = call->flags;