]> git.cworth.org Git - apitrace/blobdiff - common/trace_model.hpp
retrace: Implement glxCopySubBufferMESA
[apitrace] / common / trace_model.hpp
index fbfa1fbbc989102710a5e4a99cc3eb48a259b9a0..2ce133903d1ffb3f822d7186d215587ffe7808a3 100644 (file)
 
 #include <map>
 #include <vector>
+#include <ostream>
 
 
 namespace trace {
 
 
+// Should match Call::no
+typedef unsigned CallNo;
+
+
 typedef unsigned Id;
 
 
@@ -87,6 +92,9 @@ struct BitmaskSig {
 
 
 class Visitor;
+class Null;
+class Struct;
+class Array;
 
 
 class Value
@@ -106,6 +114,15 @@ public:
     virtual unsigned long long toUIntPtr(void) const;
     virtual const char *toString(void) const;
 
+    virtual const Null *toNull(void) const { return NULL; }
+    virtual Null *toNull(void) { return NULL; }
+
+    virtual const Array *toArray(void) const { return NULL; }
+    virtual Array *toArray(void) { return NULL; }
+
+    virtual const Struct *toStruct(void) const { return NULL; }
+    virtual Struct *toStruct(void) { return NULL; }
+
     const Value & operator[](size_t index) const;
 };
 
@@ -123,6 +140,9 @@ public:
     unsigned long long toUIntPtr(void) const;
     const char *toString(void) const;
     void visit(Visitor &visitor);
+
+    const Null *toNull(void) const { return this; }
+    Null *toNull(void) { return this; }
 };
 
 
@@ -262,6 +282,9 @@ public:
     bool toBool(void) const;
     void visit(Visitor &visitor);
 
+    const Struct *toStruct(void) const { return this; }
+    Struct *toStruct(void) { return this; }
+
     const StructSig *sig;
     std::vector<Value *> members;
 };
@@ -276,6 +299,9 @@ public:
     bool toBool(void) const;
     void visit(Visitor &visitor);
 
+    const Array *toArray(void) const { return this; }
+    Array *toArray(void) { return this; }
+
     std::vector<Value *> values;
 
     inline size_t
@@ -348,30 +374,46 @@ public:
     void visit(Visitor &visitor);
 };
 
-class StackFrame {
-public:
-    String* module;
-    String* function;
-    String* filename;
-    String* linenumber;
-    String* offset;
-    StackFrame() :
-        module(NULL),
-        function(NULL),
-        filename(NULL),
-        linenumber(NULL),
-        offset(NULL)
-    {}
-    ~StackFrame();
+struct RawStackFrame {
+    Id id;
+    const char * module;
+    const char * function;
+    const char * filename;
+    int linenumber;
+    long long offset;
+    RawStackFrame() :
+        module(0),
+        function(0),
+        filename(0),
+        linenumber(-1),
+        offset(-1)
+    {
+    }
+
+    void dump(std::ostream &os) {
+        os << (this->module ? this->module : "?");
+        if (this->function != NULL) {
+            os << ": " << this->function;
+        }
+        if (this->offset >= 0) {
+            os << "+0x" << std::hex << this->offset << std::dec;
+        }
+        if (this->filename != NULL) {
+            os << ": " << this->filename;
+            if (this->linenumber >= 0) {
+                os << ":" << this->linenumber;
+            }
+        }
+    }
 };
 
-class Backtrace {
+class StackFrame : public RawStackFrame {
 public:
-    std::vector<StackFrame*> frames;
-    ~Backtrace();
-    void addFrame(StackFrame* frame);
+    ~StackFrame();
 };
 
+typedef std::vector<StackFrame *> Backtrace;
+
 class Visitor
 {
 public:
@@ -473,6 +515,13 @@ enum {
      * Whether this call is verbose (i.e., not usually interesting).
      */
     CALL_FLAG_VERBOSE                  = (1 << 7),
+
+    /**
+     * String markers.
+     */
+    CALL_FLAG_MARKER                    = (1 << 8),
+    CALL_FLAG_MARKER_PUSH               = (1 << 9),
+    CALL_FLAG_MARKER_POP                = (1 << 10),
 };