X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_model.hpp;h=ba7c845362e55fdc5aae14fe42a4597fada84e49;hb=2a5696befce6be00fa655b751af5ce2924ea45ae;hp=d04fe5eb4086ae3d4166426d6d030cc678a1e166;hpb=9c25e06ec2fd6cf84ac6f0e66c64ab8601a3ffef;p=apitrace diff --git a/common/trace_model.hpp b/common/trace_model.hpp index d04fe5e..ba7c845 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -36,11 +36,16 @@ #include #include +#include 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 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 values; inline size_t @@ -363,6 +389,22 @@ struct RawStackFrame { 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 StackFrame : public RawStackFrame {