Skip to content

Commit 9f59ab8

Browse files
committed
Revert to recommand using LLD, mentionning the possible mixed-up debuginfo.
1 parent f021723 commit 9f59ab8

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

src/start/qemu.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -440,26 +440,6 @@ also running the embedded program.
440440

441441
In this section we'll use the `hello` example we already compiled.
442442

443-
Before getting started remotely debugging our app running in QEMU with GDB,
444-
let's modify our app configuration `.cargo/config`, to enable the GNU ARM linker:
445-
446-
```toml
447-
...
448-
rustflags = [
449-
# LLD (shipped with the Rust toolchain) is used as the default linker
450-
#"-C", "link-arg=-Tlink.x", <--- Comment this line
451-
452-
# if you run into problems with LLD switch to the GNU linker by commenting out
453-
# this line
454-
"-C", "linker=arm-none-eabi-ld", #<--- Uncomment this line
455-
```
456-
We do that, as the default linker (LLD) doesn't always play nice with the GNU ARM GDB.
457-
Rebuild the application.
458-
459-
```console
460-
cargo build --example hello
461-
```
462-
463443
The first debugging step is to launch QEMU in debugging mode:
464444

465445
```console
@@ -507,20 +487,45 @@ Reset () at $REGISTRY/cortex-m-rt-0.6.1/src/lib.rs:473
507487
473 pub unsafe extern "C" fn Reset() -> ! {
508488
```
509489

490+
510491
You'll see that the process is halted and that the program counter is pointing
511492
to a function named `Reset`. That is the reset handler: what Cortex-M cores
512493
execute upon booting.
513494

495+
> Note that on some setup, instead of displaying the line `Reset () at $REGISTRY/cortex-m-rt-0.6.1/src/lib.rs:473` as shown above, gdb may print some warnings like :
496+
>
497+
>`core::num::bignum::Big32x40::mul_small () at src/libcore/num/bignum.rs:254`
498+
> ` src/libcore/num/bignum.rs: No such file or directory.`
499+
>
500+
> That's a known glitch. You can safely ignore those warnings, you're most likely at Reset().
501+
502+
514503
This reset handler will eventually call our main function. Let's skip all the
515-
way there using a breakpoint and the `continue` command:
504+
way there using a breakpoint and the `continue` command. To set the breakpoint, let's first take a look where we would like to break in our code, with the `list` command.
516505

517506
```console
518-
break hello::__cortex_m_rt_main
507+
list main
519508
```
509+
This will show the source code, from the file examples/hello.rs.
520510

521511
```text
522-
Breakpoint 1 at 0x410: file examples\hello.rs, line 13.
512+
6 extern crate panic_halt;
513+
7
514+
8 use cortex_m_rt::entry;
515+
9 use cortex_m_semihosting::{debug, hprintln};
516+
10
517+
11 #[entry]
518+
12 fn main() -> ! {
519+
13 hprintln!("Hello, world!").unwrap();
520+
14
521+
15 // exit QEMU
523522
```
523+
We would like to add a breakpoint just before the "Hello, world!", which is on line 13. We do that with the `break` command:
524+
525+
```console
526+
break 13
527+
```
528+
We can now instruct gdb to run up to our main function, with the `continue` command:
524529

525530
```console
526531
continue
@@ -539,8 +544,9 @@ using the `next` command.
539544
``` console
540545
next
541546
```
547+
542548
```text
543-
20 debug::exit(debug::EXIT_SUCCESS);
549+
16 debug::exit(debug::EXIT_SUCCESS);
544550
```
545551

546552
At this point you should see "Hello, world!" printed on the terminal that's

0 commit comments

Comments
 (0)