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