-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgdb-init
More file actions
174 lines (148 loc) · 3.71 KB
/
Copy pathgdb-init
File metadata and controls
174 lines (148 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
set pagination off
define connect
# "TARGET_ADDRESS" is replaced with appropriate value
# via regex in Makefile
target extended-remote {{TARGET_ADDRESS}}
end
define ub
update-breakpoints
end
document ub
Short for "update-breakpoints"
end
define update-breakpoints
shell make gen-breakpoints --no-print-directory
delete
source breakpoints.txt
tb main
#break _unhandled_exception
echo Tip: Can be set manually: break Reset_Handler\n
end
document update-breakpoints
Generate hardcoded breakpoints by using "// debugger" lines
end
define wwindow
shell touch watch-window.txt
echo Watch Window: \n
echo --------------------------------\n
source watch-window.txt
end
document wwindow
Get pre-defined variable contents from watch-window.txt
end
define cheatsheet
dont-repeat
#tui-close
shell make help-cmd-debugger --no-print-directory | less
end
define restart-server
echo FORCE RESTARTING GDB SERVER\n
disconnect
shell make stop-gdb-server --no-print-directory
# gdb server will restart by itself in 1 second
shell sleep 3s
connect
end
set $use_tui = {{USE_TUI}}
define reload
dont-repeat
if $use_tui > 0
tui-close
end
echo --------------------------------\n
echo +++ compiling code...\n
shell make --no-print-directory; echo "set \$retval = $?" > /tmp/gdb-retval
source /tmp/gdb-retval
shell rm /tmp/gdb-retval
if $retval > 0
echo !!! compilation failed!\n
echo --------------------------------\n
else
echo +++ flashing the binary...\n
# for the application code
load {{ELF_FILE}}
# for the symbol table
file {{ELF_FILE}}
echo done.\n
# send a hard reset signal through NRST pin
reset-mcu
if $use_tui > 0
# display TUI on startup
tui-open
echo ----------------------------------------\n
echo ... "reload" when source code is changed\n
echo ... "update-breakpoints" ("ub") to refresh the breakpoints\n
echo ... "tui-open/tui-close" to show/hide the Terminal UI. \n
echo ... "cheatsheet" for full cheatsheet\n
echo ----------------------------------------\n
end
continue
end
end
define reload-without-compile
dont-repeat
if $use_tui > 0
tui-close
end
echo +++ flashing the binary...\n
# for the application code
load {{ELF_FILE}}
# for the symbol table
file {{ELF_FILE}}
echo done.\n
# send a hard reset signal through NRST pin
reset-mcu
continue
end
define reset-mcu
#tui-close
monitor reset halt
# START STLINK SPECIFIC
monitor jtag_reset # send NRST signal, see https://github.com/texane/stlink/issues/774
# END STLINK SPECIFIC
update-breakpoints
if $use_tui > 0
tui-open
end
end
document reset-mcu
Resets MCU state by sending a physical signal to the NRST pin.
end
define restart-app
reset-mcu
end
document restart-app
Alias for "reset-mcu"
end
define exit
kill
quit
end
define tui-open
dont-repeat
#layout src
#focus cmd
tui enable
echo ------------------------------------------\n
echo Close above TUI by "tui-close" command. \n
echo ------------------------------------------\n
end
document tui-open
Show the code around currently hit breakpoint
end
define tui-close
tui disable
end
document tui-close
Close the Terminal User Interface.
end
# --- initialize ---
connect
if $use_tui > 0
reload
else
echo ------------------------\n
echo Please manually "reload"\n
echo "cheatsheet" for full cheatsheet\n
echo ------------------------\n
end