]> git.cworth.org Git - apitrace/blobdiff - common/trace_model.hpp
More WGL support. It's ugly and the resulting code probably doesn't compile.
[apitrace] / common / trace_model.hpp
index 076ff098d61f9fa25edf72a80aef7c4796663d9f..4a9ca476f262580f6c32a83ce6ba882f41630935 100644 (file)
 namespace trace {
 
 
+// Should match Call::no
+typedef unsigned CallNo;
+
+
 typedef unsigned Id;
 
 
@@ -228,6 +232,17 @@ public:
     void visit(Visitor &visitor);
 
     const EnumSig *sig;
+
+    const EnumValue *
+    lookup() {
+        // TODO: use a std::map
+        for (const EnumValue *it = sig->values; it != sig->values + sig->num_values; ++it) {
+            if (it->value == value) {
+                return it;
+            }
+        }
+        return NULL;
+    }
 };
 
 
@@ -266,6 +281,11 @@ public:
     void visit(Visitor &visitor);
 
     std::vector<Value *> values;
+
+    inline size_t
+    size(void) const {
+        return values.size();
+    }
 };
 
 
@@ -304,6 +324,58 @@ public:
 };
 
 
+class Repr : public Value
+{
+public:
+    Repr(Value *human, Value *machine) :
+        humanValue(human),
+        machineValue(machine)
+    {}
+
+    /** Human-readible value */
+    Value *humanValue;
+
+    /** Machine-readible value */
+    Value *machineValue;
+    
+    virtual bool toBool(void) const;
+    virtual signed long long toSInt(void) const;
+    virtual unsigned long long toUInt(void) const;
+    virtual float toFloat(void) const;
+    virtual double toDouble(void) const;
+
+    virtual void *toPointer(void) const;
+    virtual void *toPointer(bool bind);
+    virtual unsigned long long toUIntPtr(void) const;
+    virtual const char *toString(void) const;
+
+    void visit(Visitor &visitor);
+};
+
+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)
+    {
+    }
+};
+
+class StackFrame : public RawStackFrame {
+public:
+    ~StackFrame();
+};
+
+typedef std::vector<StackFrame *> Backtrace;
+
 class Visitor
 {
 public:
@@ -320,7 +392,9 @@ public:
     virtual void visit(Array *);
     virtual void visit(Blob *);
     virtual void visit(Pointer *);
-
+    virtual void visit(Repr *);
+    virtual void visit(Backtrace *);
+    virtual void visit(StackFrame *);
 protected:
     inline void _visit(Value *value) {
         if (value) { 
@@ -406,6 +480,11 @@ enum {
 };
 
 
+struct Arg
+{
+    Value *value;
+};
+
 
 class Call
 {
@@ -413,17 +492,19 @@ public:
     unsigned thread_id;
     unsigned no;
     const FunctionSig *sig;
-    std::vector<Value *> args;
+    std::vector<Arg> args;
     Value *ret;
 
     CallFlags flags;
+    Backtrace* backtrace;
 
-    Call(FunctionSig *_sig, const CallFlags &_flags, unsigned _thread_id) :
+    Call(const FunctionSig *_sig, const CallFlags &_flags, unsigned _thread_id) :
         thread_id(_thread_id), 
         sig(_sig), 
         args(_sig->num_args), 
         ret(0),
-        flags(_flags) {
+        flags(_flags),
+        backtrace(0) {
     }
 
     ~Call();
@@ -434,7 +515,7 @@ public:
 
     inline Value & arg(unsigned index) {
         assert(index < args.size());
-        return *(args[index]);
+        return *(args[index].value);
     }
 };