]> git.pld-linux.org Git - packages/LeakTracer.git/blame - LeakTracer-caller_addr.patch
- yep, -lstdc++ is needed on amd64.
[packages/LeakTracer.git] / LeakTracer-caller_addr.patch
CommitLineData
e5448ca9
PS
1--- LeakTracer.cc.orig 2005-12-10 23:57:27.000000000 +0000
2+++ LeakTracer.cc 2005-12-11 00:12:19.592655400 +0000
3@@ -86,6 +86,21 @@
4 */
5 #define INITIALSIZE 32768
6
7+static inline
8+const void* caller_address(const void* return_address)
9+{
10+ unsigned long c = (unsigned long)return_address;
11+#if defined(__i386__) || defined(__x86_64__)
12+// x86-32: call [mem] takes 5 bytes.
13+// x86-64: callq/jmpq [mem] takes 5 bytes.
14+ c -= 5;
15+#elif defined(__powerpc__)
16+// ppc32: bl [mem] takes 4 bytes.
17+ c -= 4;
18+#endif
19+ return (const void*)c;
20+}
21+
22 static class LeakTracer {
23 struct Leak {
24 const void *addr;
25@@ -326,7 +341,7 @@
26 leaks[i].addr = p;
27 leaks[i].size = size;
28 leaks[i].type = type;
29- leaks[i].allocAddr=__builtin_return_address(1);
30+ leaks[i].allocAddr = caller_address(__builtin_return_address(1));
31 firstFreeSpot = i+1;
32 // allow to lookup our index fast.
33 int *hashPos = &leakHash[ ADDR_HASH(p) ];
34@@ -410,7 +425,7 @@
35 "S %10p %10p # new%s but delete%s "
36 "; size %zd\n",
37 leaks[i].allocAddr,
38- __builtin_return_address(1),
39+ caller_address(__builtin_return_address(1)),
40 ((!type) ? "[]" : " normal"),
41 ((type) ? "[]" : " normal"),
42 leaks[i].size);
This page took 0.092105 seconds and 4 git commands to generate.