Commit | Line | Data |
---|---|---|
dc2de456 AG |
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 | ||
cdefb14d AG |
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 | ||
1547904b AG |
60 | define freespace |
61 | printf "free space: %d bytes\n", (unsigned int)$sp - '_sbrk::heap' | |
62 | end | |
63 | ||
64 | document freespace | |
65 | Displays the free space. | |
66 | ||
67 | This is the amount of space between the heap and stack that is currently | |
68 | unused. | |
69 | end | |
70 | ||
71 | ||
72 | ||
cdefb14d AG |
73 | define maxstacksize |
74 | set var $fill_curr=(unsigned int*)'_sbrk::heap' | |
75 | while ($fill_curr < $sp && *$fill_curr == 0xdeadbeef) | |
76 | set var $fill_curr = $fill_curr + 1 | |
77 | end | |
78 | ||
79 | if ($fill_curr == '_sbrk::heap') | |
80 | printf "No free space between heap and stack detected!\n" | |
81 | else | |
82 | printf "maximum stack size: %d bytes\n", 0x10008000 - (unsigned int)$fill_curr | |
83 | end | |
84 | end | |
85 | ||
86 | document maxstacksize | |
87 | Displays the maximum stack amount of stack used. | |
88 | This can take awhile to run as it walks the area between the top of heap and | |
89 | the current top of stack to look for where initial fill values have been | |
90 | overwritten by stack writes. | |
91 | end | |
92 | ||
93 | ||
94 | ||
dc2de456 AG |
95 | define crashdump |
96 | set pagination off | |
97 | set logging on | |
98 | bt | |
99 | list | |
100 | disass | |
101 | set var $ptr=0x10000000 | |
102 | while $ptr < 0x10008000 | |
103 | x/4wa $ptr | |
104 | set var $ptr+=16 | |
105 | end | |
106 | info registers | |
107 | set logging off | |
108 | set pagination on | |
109 | end | |
cdefb14d AG |
110 | |
111 | document crashdump | |
112 | Dumps a full crash dump to gdb.txt | |
113 | end |