@@ -197,10 +197,10 @@ Now proceed to *flash* (load) the program onto the microcontroller using the
197
197
``` console
198
198
(gdb) load
199
199
Loading section .vector_table, size 0x400 lma 0x8000000
200
- Loading section .text, size 0x1e70 lma 0x8000400
201
- Loading section .rodata, size 0x61c lma 0x8002270
202
- Start address 0x800144e , load size 10380
203
- Transfer rate: 17 KB/sec, 3460 bytes/write.
200
+ Loading section .text, size 0x1518 lma 0x8000400
201
+ Loading section .rodata, size 0x414 lma 0x8001918
202
+ Start address 0x08000400 , load size 7468
203
+ Transfer rate: 13 KB/sec, 2489 bytes/write.
204
204
```
205
205
206
206
The program is now loaded. This program uses semihosting so before we do any
@@ -219,78 +219,56 @@ Like before we can skip all the way to `main` using a breakpoint and the
219
219
220
220
``` console
221
221
(gdb) break main
222
- Breakpoint 1 at 0x8000d18: file examples/hello.rs, line 15.
222
+ Breakpoint 1 at 0x8000490: file examples/hello.rs, line 11.
223
+ Note: automatically using hardware breakpoints for read-only addresses.
223
224
224
225
(gdb) continue
225
226
Continuing.
226
- Note: automatically using hardware breakpoints for read-only addresses.
227
227
228
- Breakpoint 1, main () at examples/hello.rs:15
229
- 15 let mut stdout = hio::hstdout().unwrap();
228
+ Breakpoint 1, hello::__cortex_m_rt_main_trampoline () at examples/hello.rs:11
229
+ 11 #[entry]
230
230
```
231
231
232
232
> ** NOTE** If GDB blocks the terminal instead of hitting the breakpoint after
233
233
> you issue the ` continue ` command above, you might want to double check that
234
234
> the memory region information in the ` memory.x ` file is correctly set up
235
235
> for your device (both the starts * and* lengths).
236
236
237
- Advancing the program with ` next ` should produce the same results as before .
237
+ Step into the main function with ` step ` .
238
238
239
239
``` console
240
- (gdb) next
241
- 16 writeln!(stdout, "Hello, world!").unwrap();
242
-
243
- (gdb) next
244
- 19 debug::exit(debug::EXIT_SUCCESS);
240
+ (gdb) step
241
+ halted: PC: 0x08000496
242
+ hello::__cortex_m_rt_main () at examples/hello.rs:13
243
+ 13 hprintln!("Hello, world!").unwrap();
245
244
```
246
245
247
- At this point you should see "Hello, world!" printed on the OpenOCD console,
246
+ After advancing the program with ` next ` you should see "Hello, world!" printed on the OpenOCD console,
248
247
among other stuff.
249
248
250
- ``` text
251
- $ openocd
252
- (..)
253
- Info : halted: PC: 0x08000e6c
254
- Hello, world!
255
- Info : halted: PC: 0x08000d62
256
- Info : halted: PC: 0x08000d64
257
- Info : halted: PC: 0x08000d66
258
- Info : halted: PC: 0x08000d6a
259
- Info : halted: PC: 0x08000a0c
260
- Info : halted: PC: 0x08000d70
261
- Info : halted: PC: 0x08000d72
262
- ```
263
-
264
- Issuing another ` next ` will make the processor execute ` debug::exit ` . This acts
265
- as a breakpoint and halts the process:
266
-
267
249
``` console
268
- (gdb) next
269
-
270
- Program received signal SIGTRAP, Trace/breakpoint trap.
271
- 0x0800141a in __syscall ()
272
- ```
273
-
274
- It also causes this to be printed to the OpenOCD console:
275
-
276
- ``` text
277
250
$ openocd
278
251
(..)
279
- Info : halted: PC: 0x08001188
280
- semihosting: *** application exited ***
281
- Warn : target not halted
282
- Warn : target not halted
283
- target halted due to breakpoint, current mode: Thread
284
- xPSR: 0x21000000 pc: 0x08000d76 msp: 0x20009fc0, semihosting
252
+ Info : halted: PC: 0x08000502
253
+ Hello, world!
254
+ Info : halted: PC: 0x080004ac
255
+ Info : halted: PC: 0x080004ae
256
+ Info : halted: PC: 0x080004b0
257
+ Info : halted: PC: 0x080004b4
258
+ Info : halted: PC: 0x080004b8
259
+ Info : halted: PC: 0x080004bc
285
260
```
286
-
287
- However, the process running on the microcontroller has not terminated and you
288
- can resume it using ` continue ` or a similar command.
261
+ The message is only displayed once as the program is about to enter the infinite loop defined in line 19: ` loop {} `
289
262
290
263
You can now exit GDB using the ` quit ` command.
291
264
292
265
``` console
293
266
(gdb) quit
267
+ A debugging session is active.
268
+
269
+ Inferior 1 [Remote target] will be detached.
270
+
271
+ Quit anyway? (y or n)
294
272
```
295
273
296
274
Debugging now requires a few more steps so we have packed all those steps into a
0 commit comments