]> git.cworth.org Git - apitrace/blobdiff - common/trace_dump.cpp
Replace dynamic_cast with virtual functions.
[apitrace] / common / trace_dump.cpp
index e6810b6afa63e209e156b096bb8a5197b2dc32ce..6e67e08ab53e0f2585d5a1e952b9d00bae220b02 100644 (file)
@@ -178,7 +178,7 @@ public:
 
             if (!memberName || !*memberName) {
                 // Anonymous structure
-                Struct *memberStruct = dynamic_cast<Struct *>(memberValue);
+                Struct *memberStruct = memberValue->toStruct();
                 assert(memberStruct);
                 if (memberStruct) {
                     sep = visitMembers(memberStruct, sep);
@@ -228,6 +228,33 @@ public:
         _visit(r->humanValue);
     }
 
+    void visit(StackFrame *frame) {
+        if (frame->module != NULL) {
+            os << frame->module << " ";
+        }
+        if (frame->function != NULL) {
+            os << "at " << frame->function << "() ";
+        }
+        if (frame->filename != NULL) {
+            os << "at " << frame->filename;
+            if (frame->linenumber >= 0) {
+                os << ":" << frame->linenumber << " ";
+            }
+        }
+        else {
+            if (frame->offset >= 0) {
+                os << "[" << "0x" << std::hex << frame->offset << std::dec << "]";
+            }
+        }
+    }
+
+    void visit(Backtrace & backtrace) {
+        for (int i = 0; i < backtrace.size(); i ++) {
+            visit(backtrace[i]);
+            os << "\n";
+        }
+    }
+
     void visit(Call *call) {
         CallFlags callFlags = call->flags;
         
@@ -271,6 +298,10 @@ public:
         
         os << "\n";
 
+        if (call->backtrace != NULL) {
+            os << bold << red << "Backtrace:\n" << normal;
+            visit(*call->backtrace);
+        }
         if (callFlags & CALL_FLAG_END_FRAME) {
             os << "\n";
         }