Merge branch 'edge' into track_allocs
[clinton/Smoothieware.git] / .gdbinit
1 define heapwalk
2 set var $chunk_curr=(unsigned int)__smoothieHeapBase
3 set var $chunk_number=1
4 while ($chunk_curr < '_sbrk::heap')
5 set var $chunk_size=*(unsigned int*)($chunk_curr+4) & ~1
6 set var $chunk_next=$chunk_curr + $chunk_size
7 set var $chunk_inuse=*(unsigned int*)($chunk_next+4) & 1
8 set var $chunk_tag=*(unsigned int*)$chunk_next
9 printf "Allocation: %u Address: 0x%08X Size:%u ", $chunk_number, $chunk_curr+8, $chunk_size-4
10 if ($chunk_inuse)
11 info line *($chunk_tag)
12 else
13 printf "FREE CHUNK\n"
14 end
15 set var $chunk_curr=$chunk_next
16 set var $chunk_number=$chunk_number+1
17 end
18 end
19
20 document heapwalk
21 Walks the heap and dumps each chunk encountered.
22 It will also lists the line and source filename from where the chunk was
23 allocated if not a freed chunk. Requires that HEAP_WALK be set to a value of 1
24 in the Smoothie makefile.
25 end
26
27
28
29
30 define heapsize
31 if ($argc > 0)
32 set var $heap_base=(unsigned int)$arg0
33 else
34 set var $heap_base=(unsigned int)__smoothieHeapBase
35 end
36 printf "heap size: %d bytes\n", ('_sbrk::heap' - $heap_base)
37 end
38
39 document heapsize
40 Displays the current heap size.
41 Can provide an optional argument specifying the location of the base address
42 for the heap. This isn't required if you have HEAP_WALK enabled in the makefile
43 but if that features isn't enabled, you will want to run
44 "maintenance info section .heap" to determine this base address and then
45 pass it as an argument to this comand.
46 end
47
48
49
50 define stacksize
51 printf "stack size: %d bytes\n", 0x10008000 - (unsigned int)$sp
52 end
53
54 document stacksize
55 Displays the current stack size.
56 end
57
58
59
60 define maxstacksize
61 set var $fill_curr=(unsigned int*)'_sbrk::heap'
62 while ($fill_curr < $sp && *$fill_curr == 0xdeadbeef)
63 set var $fill_curr = $fill_curr + 1
64 end
65
66 if ($fill_curr == '_sbrk::heap')
67 printf "No free space between heap and stack detected!\n"
68 else
69 printf "maximum stack size: %d bytes\n", 0x10008000 - (unsigned int)$fill_curr
70 end
71 end
72
73 document maxstacksize
74 Displays the maximum stack amount of stack used.
75 This can take awhile to run as it walks the area between the top of heap and
76 the current top of stack to look for where initial fill values have been
77 overwritten by stack writes.
78 end
79
80
81
82 define crashdump
83 set pagination off
84 set logging on
85 bt
86 list
87 disass
88 set var $ptr=0x10000000
89 while $ptr < 0x10008000
90 x/4wa $ptr
91 set var $ptr+=16
92 end
93 info registers
94 set logging off
95 set pagination on
96 end
97
98 document crashdump
99 Dumps a full crash dump to gdb.txt
100 end