aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2008-02-14 19:29:00 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2008-02-14 19:29:00 +0000
commit84781c10a768b91a02151b202c76b52b1c5789c2 (patch)
treefe9879beb735cdba183b8ba7aaf64c8cb1d739a3 /lib
parent194615a88fac0c4259b3c2217c8e13372b7c3b86 (diff)
downloadenigma2-84781c10a768b91a02151b202c76b52b1c5789c2.tar.gz
enigma2-84781c10a768b91a02151b202c76b52b1c5789c2.zip
write memleak info to /var/tmp/enigma2_mem.out instead of stdout
Diffstat (limited to 'lib')
-rw-r--r--lib/base/eerror.cpp19
-rw-r--r--lib/base/eerror.h13
2 files changed, 16 insertions, 16 deletions
diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp
index 4093d012..1e4d348f 100644
--- a/lib/base/eerror.cpp
+++ b/lib/base/eerror.cpp
@@ -20,14 +20,16 @@ void DumpUnfreed()
if(!allocList)
return;
+ FILE *f = fopen("/var/tmp/enigma2_mem.out", "w");
size_t len = 1024;
char *buffer = (char*)malloc(1024);
for(i = allocList->begin(); i != allocList->end(); i++)
{
unsigned int tmp;
- printf("%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n",
+ fprintf(f, "%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n",
i->second.file, i->second.line, (void*)i->second.address, i->second.size, i->second.type, i->second.btcount);
totalSize += i->second.size;
+
char **bt_string = backtrace_symbols( i->second.backtrace, i->second.btcount );
for ( tmp=0; tmp < i->second.btcount; tmp++ )
{
@@ -47,24 +49,25 @@ void DumpUnfreed()
int state;
abi::__cxa_demangle(tmp1.c_str(), buffer, &len, &state);
if (!state)
- printf("%d %s%s\n", tmp, buffer,tmp2.c_str());
+ fprintf(f, "%d %s%s\n", tmp, buffer,tmp2.c_str());
else
- printf("%d %s\n", tmp, bt_string[tmp]);
+ fprintf(f, "%d %s\n", tmp, bt_string[tmp]);
}
}
}
else
- printf("%d %s\n", tmp, bt_string[tmp]);
+ fprintf(f, "%d %s\n", tmp, bt_string[tmp]);
}
}
free(bt_string);
- printf("\n");
+ if (i->second.btcount)
+ fprintf(f, "\n");
}
free(buffer);
- printf("-----------------------------------------------------------\n");
- printf("Total Unfreed: %d bytes\n", totalSize);
- fflush(stdout);
+ fprintf(f, "-----------------------------------------------------------\n");
+ fprintf(f, "Total Unfreed: %d bytes\n", totalSize);
+ fflush(f);
};
#endif
diff --git a/lib/base/eerror.h b/lib/base/eerror.h
index e7c33a0b..6040565e 100644
--- a/lib/base/eerror.h
+++ b/lib/base/eerror.h
@@ -21,7 +21,7 @@ typedef struct
{
unsigned int address;
unsigned int size;
- char *file;
+ const char *file;
void *backtrace[BACKTRACE_DEPTH];
unsigned char btcount;
unsigned short line;
@@ -41,11 +41,11 @@ static inline void AddTrack(unsigned int addr, unsigned int asize, const char
allocList = new(AllocList);
info.address = addr;
- info.file = strdup(fname);
+ info.file = fname;
info.line = lnum;
info.size = asize;
info.type = type;
- info.btcount = backtrace( info.backtrace, BACKTRACE_DEPTH );
+ info.btcount = 0; //backtrace( info.backtrace, BACKTRACE_DEPTH );
singleLock s(memLock);
(*allocList)[addr]=info;
};
@@ -62,14 +62,11 @@ static inline void RemoveTrack(unsigned int addr, unsigned int type)
if ( i->second.type != type )
i->second.type=3;
else
- {
- free(i->second.file);
allocList->erase(i);
- }
}
};
-inline void * operator new(unsigned int size, const char *file, int line)
+inline void * operator new(size_t size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
AddTrack((unsigned int)ptr, size, file, line, 1);
@@ -82,7 +79,7 @@ inline void operator delete(void *p)
free(p);
};
-inline void * operator new[](unsigned int size, const char *file, int line)
+inline void * operator new[](size_t size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
AddTrack((unsigned int)ptr, size, file, line, 2);