X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_writer.hpp;h=4c9547788c8e28b5833943744b86f18f533280dd;hb=cad5d619dcb5e1c6349bfff69176660668402622;hp=50d4bbf705294e20fc8b76f6674d799d0da3023c;hpb=46a4839cd1b65981bec9f33b1d7978b821866a51;p=apitrace diff --git a/common/trace_writer.hpp b/common/trace_writer.hpp index 50d4bbf..4c95477 100644 --- a/common/trace_writer.hpp +++ b/common/trace_writer.hpp @@ -37,8 +37,7 @@ #include "trace_model.hpp" - -namespace Trace { +namespace trace { class File; class Writer { @@ -50,6 +49,7 @@ namespace Trace { std::vector structs; std::vector enums; std::vector bitmasks; + std::vector frames; public: Writer(); @@ -58,7 +58,7 @@ namespace Trace { bool open(const char *filename); void close(void); - unsigned beginEnter(const FunctionSig *sig); + unsigned beginEnter(const FunctionSig *sig, unsigned thread_id); void endEnter(void); void beginLeave(unsigned call); @@ -70,6 +70,10 @@ namespace Trace { void beginReturn(void); inline void endReturn(void) {} + void beginBacktrace(unsigned num_frames); + void writeStackFrame(const RawStackFrame *frame); + inline void endBacktrace(void) {} + void beginArray(size_t length); inline void endArray(void) {} @@ -79,6 +83,9 @@ namespace Trace { void beginStruct(const StructSig *sig); inline void endStruct(void) {} + void beginRepr(void); + inline void endRepr(void) {} + void writeBool(bool value); void writeSInt(signed long long value); void writeUInt(unsigned long long value); @@ -88,10 +95,10 @@ namespace Trace { void writeString(const char *str, size_t size); void writeWString(const wchar_t *str); void writeBlob(const void *data, size_t size); - void writeEnum(const EnumSig *sig); + void writeEnum(const EnumSig *sig, signed long long value); void writeBitmask(const BitmaskSig *sig, unsigned long long value); void writeNull(void); - void writeOpaque(const void *ptr); + void writePointer(unsigned long long addr); void writeCall(Call *call); @@ -105,46 +112,6 @@ namespace Trace { }; - extern const FunctionSig memcpy_sig; - extern const FunctionSig malloc_sig; - extern const FunctionSig free_sig; - extern const FunctionSig realloc_sig; - - /** - * A specialized Writer class, mean to trace the current process. - * - * In particular: - * - it creates a trace file based on the current process name - * - uses mutexes to allow tracing from multiple threades - * - flushes the output to ensure the last call is traced in event of - * abnormal termination - */ - class LocalWriter : public Writer { - protected: - int acquired; - - public: - /** - * Should never called directly -- use localWriter singleton below instead. - */ - LocalWriter(); - ~LocalWriter(); - - void open(void); - - unsigned beginEnter(const FunctionSig *sig); - void endEnter(void); - - void beginLeave(unsigned call); - void endLeave(void); - - void flush(void); - }; - - /** - * Singleton. - */ - extern LocalWriter localWriter; -} +} /* namespace trace */ #endif /* _TRACE_WRITER_HPP_ */