]> git.cworth.org Git - apitrace/blobdiff - common/trace_dump.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / common / trace_dump.cpp
index 0f7ee3656e76288ccd12caca37ec5e62394ce76b..e6810b6afa63e209e156b096bb8a5197b2dc32ce 100644 (file)
@@ -24,6 +24,8 @@
  **************************************************************************/
 
 
+#include <limits>
+
 #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<float>::digits10 + 1);
         os << literal << node->value << normal;
+        os.precision(oldPrecision);
     }
 
     void visit(Double *node) {
+        std::streamsize oldPrecision = os.precision(std::numeric_limits<double>::digits10 + 1);
         os << literal << node->value << normal;
+        os.precision(oldPrecision);
     }
 
     void visit(String *node) {
@@ -142,6 +148,7 @@ public:
         const BitmaskSig *sig = bitmask->sig;
         bool first = true;
         for (const BitmaskFlag *it = sig->flags; it != sig->flags + sig->num_flags; ++it) {
+            assert(it->value || first);
             if ((it->value && (value & it->value) == it->value) ||
                 (!it->value && value == 0)) {
                 if (!first) {
@@ -163,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<Struct *>(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 << "}";
     }
 
@@ -199,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;