Remove bitmask from within for loop.
[clinton/Smoothieware.git] / .gdbinit
CommitLineData
dc2de456
AG
1define 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
18end
19
cdefb14d
AG
20document heapwalk
21Walks the heap and dumps each chunk encountered.
22It will also lists the line and source filename from where the chunk was
23allocated if not a freed chunk. Requires that HEAP_WALK be set to a value of 1
24in the Smoothie makefile.
25end
26
27
28
29
30define 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)
37end
38
39document heapsize
40Displays the current heap size.
41Can provide an optional argument specifying the location of the base address
42for the heap. This isn't required if you have HEAP_WALK enabled in the makefile
43but if that features isn't enabled, you will want to run
44"maintenance info section .heap" to determine this base address and then
45pass it as an argument to this comand.
46end
47
48
49
50define stacksize
51 printf "stack size: %d bytes\n", 0x10008000 - (unsigned int)$sp
52end
53
54document stacksize
55Displays the current stack size.
56end
57
58
59
60define 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
71end
72
73document maxstacksize
74Displays the maximum stack amount of stack used.
75This can take awhile to run as it walks the area between the top of heap and
76the current top of stack to look for where initial fill values have been
77overwritten by stack writes.
78end
79
80
81
dc2de456
AG
82define 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
96end
cdefb14d
AG
97
98document crashdump
99Dumps a full crash dump to gdb.txt
100end