Skip to content

Commit

Permalink
Add script for remaining stack memory graphing
Browse files Browse the repository at this point in the history
  • Loading branch information
szszszsz committed Jun 21, 2023
1 parent 730b69b commit bd71660
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions utils/nrf-debugging/binary.elf
25 changes: 25 additions & 0 deletions utils/nrf-debugging/gdb-stack.cmds
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set pagination off
set logging file gdb.txt
set logging on

set architecture arm
set endian little
set arm fallback-mode thumb
set arm force-mode thumb
set style enabled off
file binary.elf
target remote :3333


define stepinf
while(1)
p $msp
step
end
end

# Automatically start tracing upon reaching the following line
# b transport.rs:181
# commands
# stepinf
# end
36 changes: 36 additions & 0 deletions utils/nrf-debugging/graph_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from matplotlib import pyplot as plt

"""
Quickly graph gdb msp prints.
rg -F "= (*mut ()) " gdb.txt > gdb.txt.stack
Expected format is like:
...
$38057 = (*mut ()) 0x2001b478
$38058 = (*mut ()) 0x2001b478
...
"""

PATH = 'gdb.txt.stack'

def main():
data = []
with open(PATH, 'r') as f:
for line in f:
num = int(line.split()[-1], 16)
num = num - 0x20000000
num = num // 1024
data.append(num)

print(len(data))
plt.plot(data)
plt.ylabel('free stack memory left [kB]')
plt.xlabel('sample no.')
plt.show()


if __name__ == '__main__':
main()

0 comments on commit bd71660

Please sign in to comment.