Home | History | Annotate | Download | only in lightsymbols
      1 #ifndef __LIGHT_SYMBOLS__
      2 #define __LIGHT_SYMBOLS__
      3 #define LS_TRACE(functionName,fileId,lineNumber) LightSymbol __lstr(functionName,fileId,lineNumber);
      4 
      5 #include <stdio.h>
      6 #include <string.h>
      7 #include <stdlib.h>
      8 
      9 //#include <pthread.h>
     10 #include <windows.h>
     11 
     12 typedef char* SZ;
     13 
     14 #define LIGHT_SYMBOLS_FILE "LIGHT_SYMBOLS_FILE"
     15 
     16 class LightSymbol {
     17   const char* sym;
     18   int fileId;
     19   int lineNumber;
     20 
     21   LightSymbol* parentFrame;
     22 
     23   typedef LightSymbol* PLightSymbol;
     24 
     25   static PLightSymbol lsFrames[1000];
     26   static HANDLE handleFrames[1000];
     27   static SZ* fileNames;
     28   static bool busted;
     29 
     30 public:
     31   LightSymbol(const char* sym, int fileId, int lineNumber);
     32 
     33   ~LightSymbol();
     34 
     35   static bool GetCallStack(char* sz, int len, const char* separator);
     36 
     37 private:
     38 
     39   static LightSymbol** getThreadFrameContainer();
     40 
     41   bool GetCallStackCore(char* sz, int len, const char* separator) const ;
     42 
     43   static LightSymbol* GetCurrentFrame() ;
     44 
     45   static void SetCurrentFrame(LightSymbol* ls) ;
     46 
     47   static const char* trim(char* sz) ;
     48 };
     49 
     50 #endif
     51