• Home
Name Date Size #Lines LOC

..--

test/03-May-2024-159129

README.mdD03-May-20241.1 KiB4525

heap_print_script.pyD03-May-20247.7 KiB240186

README.md

1Script supports 2 custom commands:
2
31) watch_heap : sets break point at dynamic memory allocation and keeps track of it
42) print_ptr : prints the memory pointed by raw pointer in hex format.
5
6                eg:
7                (gdb) print_ptr malloc_ptr
8                Type : int *
9                Starting Address: 0x55555556aeb0
10                Length : 40
11                0x01 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x03 0x00 0x00 0x00
12                0x04 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x06 0x00 0x00 0x00
13                0x07 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x09 0x00 0x00 0x00
14                0x0a 0x00 0x00 0x00
15
16    If print_ptr is used after free/delete[], then it would print "No address mapping found!"
17
18
19Tests:
20
21To run the test
22
23In the heap_print dir,
24
25Compile :
26
27g++ -O0 -g test/sample_heap_test.cc -o test/sample_heap_test.o
28
29And then Run:
30
31$ gdb
32$ source test/test_heap_print_script.py
33
34
35Future Goals:
36
37To handle pointer offset, for eg, (gdb) print_ptr malloc_ptr + 3
38
39To handle custom allacator, may be watch_heap command could take in arguements
40and sets additional break points.
41
42
43
44
45