X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=trace_writer.hpp;h=dfb76b2508a4bac02f455b9d570cc733c5492f9a;hb=3a8ffad2f31f4438e19dd5a0f1c068e1fdffdeea;hp=eb81f233f604bef706d1149d867d13ef1748e2fc;hpb=5ce45e7f614c7540f4d3d4f86db7a499f138d01e;p=apitrace diff --git a/trace_writer.hpp b/trace_writer.hpp index eb81f23..dfb76b2 100644 --- a/trace_writer.hpp +++ b/trace_writer.hpp @@ -55,7 +55,6 @@ namespace Trace { Writer(); ~Writer(); - void open(void); bool open(const char *filename); void close(void); @@ -105,6 +104,42 @@ namespace Trace { void inline _writeString(const char *str); }; + + /** + * 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; } #endif /* _TRACE_WRITER_HPP_ */