1
2
3
4
5
6 #ifndef SOULNG_UTIL_TRACE_INCLUDED
7 #define SOULNG_UTIL_TRACE_INCLUDED
8 #include <soulng/util/UtilApi.hpp>
9 #include <stdint.h>
10 #include <string>
11 #include <vector>
12
13 namespace soulng { namespace util {
14
15 enum class EntryKind : int8_t
16 {
17 begin= 0, end= 1, message= 2
18 };
19
20 struct TraceEntry
21 {
22 TraceEntry(EntryKind kind_, char threadId_, int32_t id_, int64_t nanosecs_);
23 EntryKind kind;
24 char threadId;
25 int32_t id;
26 int64_t nanosecs;
27 };
28
29 void BeginTracing();
30 void EndTracing();
31 void SetThreadId(char threadId_);
32 int32_t GetTraceFunctionId(const std::string& functionFullName);
33 const std::string& GetTraceFunctionName(int32_t traceFunctionId);
34 const std::string& GetTraceMessageName(int32_t traceMessageId);
35 void AddTraceEntry(EntryKind kind, int32_t id);
36 std::vector<TraceEntry> ReadTrace(const std::string& traceFilePath);
37 void ReadTraceTable();
38 void WriteTraceTable();
39 void InitTrace();
40 void DoneTrace();
41
42 class Tracer
43 {
44 public:
45 Tracer(int32_t traceFunctionId_);
46 ~Tracer();
47 private:
48 int32_t traceFunctionId;
49 };
50
51 } }
52
53 #endif // SOULNG_UTIL_TRACE_INCLUDED