aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/LightSymbolsUtil/lightsymbols/lightsymbols.h
blob: 02494e63b5481675f2c763a1d0e39158db066eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __LIGHT_SYMBOLS__
#define __LIGHT_SYMBOLS__
#define LS_TRACE(functionName,fileId,lineNumber) LightSymbol __lstr(functionName,fileId,lineNumber);

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//#include <pthread.h>
#include <windows.h>

typedef char* SZ;

#define LIGHT_SYMBOLS_FILE "LIGHT_SYMBOLS_FILE"

class LightSymbol {
  const char* sym;
  int fileId;
  int lineNumber;

  LightSymbol* parentFrame;

  typedef LightSymbol* PLightSymbol;

  static PLightSymbol lsFrames[1000];
  static HANDLE handleFrames[1000];
  static SZ* fileNames;
  static bool busted;

public:
  LightSymbol(const char* sym, int fileId, int lineNumber);

  ~LightSymbol();

  static bool GetCallStack(char* sz, int len, const char* separator);

private:

  static LightSymbol** getThreadFrameContainer();

  bool GetCallStackCore(char* sz, int len, const char* separator) const ;

  static LightSymbol* GetCurrentFrame() ;

  static void SetCurrentFrame(LightSymbol* ls) ;

  static const char* trim(char* sz) ;
};

#endif