-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
67 lines (51 loc) · 1.49 KB
/
README
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
bash:
$ LD_PRELOAD=<mem_trace.so path> <your program>
or
% export LD_PRELOAD=<mem_trace.so path>
% run your program
after checking the report, reset LD_PRELOAD.
% export LD_PRELOAD=
output:
$ cat mem_trace.out
[0xb7ff72ed] malloc 5 byte(s) lost.
[0xb7f01000] __strdup
[0x8048406] func (test.c:7)
[0x8048432] main (test.c:24)
[0xb7ea0685] __libc_start_main
addr2line doesn't exist:
* To examine caller address
Linux:
$ ./tp
malloc: using trace hooks..ok
free: using trace hooks..ok
caller addr: 0x8048411
$ gdb ./tp
...
(gdb) dissassemble 0x8048411
Dump of assembler code for function main:
0x080483f4 <main+0>: lea 0x4(%esp),%ecx
0x080483f8 <main+4>: and $0xfffffff0,%esp
0x080483fb <main+7>: pushl -0x4(%ecx)
0x080483fe <main+10>: push %ebp
0x080483ff <main+11>: mov %esp,%ebp
0x08048401 <main+13>: push %ecx
0x08048402 <main+14>: sub $0x14,%esp
0x08048405 <main+17>: movl $0x20,(%esp)
0x0804840c <main+24>: call 0x804832c <malloc@plt> <--- HERE!
0x08048411 <main+29>: mov %eax,-0x8(%ebp) <--- mem_trace.so report
...
SunOS:
$ LD_PRELOAD=./mem_trace.so ./tp
malloc: using trace hooks..ok
free: using trace hooks..ok
caller addr: 0x10698
% gdb ./tp
...
(gdb) disass main
Dump of assembler code for function main:
0x00010688 <main+0>: save %sp, -120, %sp
0x0001068c <main+4>: st %i0, [ %fp + 0x44 ]
0x00010690 <main+8>: st %i1, [ %fp + 0x48 ]
0x00010694 <main+12>: mov 0x20, %o0
0x00010698 <main+16>: call 0x20808 <malloc@plt> <--- mem_trace.so report
...