X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=common%2Ftrace_model.hpp;h=a2fd97f4a68b2c9a425ec0196d51f292641ef581;hb=ee659c84695e9f94b1f6a5f8be203dc0012ca685;hp=1b2e1f2c45a48ede154195544ff271803e0f444a;hpb=eb64451efcd8100d02ec89ff2ae6ea2c78c7645b;p=apitrace diff --git a/common/trace_model.hpp b/common/trace_model.hpp index 1b2e1f2..a2fd97f 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -32,10 +32,10 @@ #include +#include #include #include -#include namespace trace { @@ -107,8 +107,6 @@ public: virtual const char *toString(void) const; const Value & operator[](size_t index) const; - - void dump(std::ostream &os, bool color=true); }; @@ -230,6 +228,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; + } }; @@ -332,14 +341,6 @@ protected: }; -inline std::ostream & operator <<(std::ostream &os, Value *value) { - if (value) { - value->dump(os); - } - return os; -} - - typedef unsigned CallFlags; /** @@ -416,18 +417,25 @@ enum { }; +struct Arg +{ + Value *value; +}; + class Call { public: + unsigned thread_id; unsigned no; const FunctionSig *sig; - std::vector args; + std::vector args; Value *ret; CallFlags flags; - Call(FunctionSig *_sig, const CallFlags &_flags) : + Call(FunctionSig *_sig, const CallFlags &_flags, unsigned _thread_id) : + thread_id(_thread_id), sig(_sig), args(_sig->num_args), ret(0), @@ -442,19 +450,11 @@ public: inline Value & arg(unsigned index) { assert(index < args.size()); - return *(args[index]); + return *(args[index].value); } - - void dump(std::ostream &os, bool color=true); }; -inline std::ostream & operator <<(std::ostream &os, Call &call) { - call.dump(os); - return os; -} - - } /* namespace trace */ #endif /* _TRACE_MODEL_HPP_ */