00001 #ifndef __TRACE_MEMORY_H__ 00002 #define __TRACE_MEMORY_H__ 00003 00004 #include "charm++.h" 00005 #include "trace.h" 00006 #include "trace-common.h" 00007 #include <errno.h> 00008 00011 class MemEntry { 00012 friend class TraceMemory; 00013 private: 00014 int type; 00015 void *where; 00016 int size; 00017 int stackSize; 00018 00019 public: 00020 MemEntry(); 00021 void write(FILE *fp); 00022 void set(int t, void *w, int s) { 00023 type = t; 00024 where = w; 00025 size = s; 00026 stackSize = 0; 00027 } 00028 void setStack(int ss, void **s) { 00029 stackSize = ss; 00030 memcpy(this+1, s, ss*sizeof(void*)); 00031 } 00032 }; 00033 00038 class TraceMemory : public Trace { 00039 private: 00040 bool firstTime; 00041 bool recordStack; 00042 bool traceDisabled; 00043 int logBufSize; 00044 int usedBuffer; 00045 char *logBuffer; 00046 00047 void checkFlush(int add); 00048 void flush(); 00049 public: 00050 TraceMemory(char **argv); 00051 00052 void traceBegin(); 00053 void traceClose(); 00054 void malloc(void *where, int size, void **stack, int stackSize); 00055 void free(void *where, int size); 00056 }; 00057 00058 #endif