Skip to content

Section 7.2. (mis)Optimization : Can not play the debug session as described in the tutorial #320

Open
@the-cat-that-codes

Description

@the-cat-that-codes

Hi everyone,

I have some troubles at running this section correctly.

First, here are my version of rustup and rustc :

$ rustup --version
rustup 1.23.1 (3df2264a9 2020-11-30)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)`

The problem is that I can not execute step by step (using the gdb next instruction) the binary launched with cargo run --release. Here after is my session :

$ cargo run --release
    Finished release [optimized + debuginfo] target(s) in 0.02s
     Running `arm-none-eabi-gdb -q -x openocd.gdb '/home/XXX/Dev/Rust/Embedded_Discovery/discovery-master/target/thumbv7em-none-eabihf/release/registers'`
Reading symbols from /home/XXX/Dev/Rust/Embedded_Discovery/discovery-master/target/thumbv7em-none-eabihf/release/registers...
0x08000252 in registers::__cortex_m_rt_main () at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/ptr/mod.rs:1150
1150	/rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/ptr/mod.rs: Aucun fichier ou dossier de ce type.
Loading section .vector_table, size 0x194 lma 0x8000000
Loading section .text, size 0x1220 lma 0x8000194
Loading section .rodata, size 0x1b4 lma 0x80013b4
Start address 0x8000194, load size 5480
Transfer rate: 13 KB/sec, 1826 bytes/write.
Breakpoint 1 at 0x8000224: file src/07-registers/src/main.rs, line 9.
Breakpoint 2 at 0x8001078
Breakpoint 3 at 0x80013b2
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at src/07-registers/src/main.rs:9
9	#[entry]
(gdb) s
halted: PC: 0x0800022a
registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:11
11	    aux7::init();
(gdb) n
halted: PC: 0x08000254
halted: PC: 0x08000236
halted: PC: 0x0800023a
halted: PC: 0x0800023e
18	        ptr::write_volatile(GPIOE_BSRR as *mut u32, 1 << 9);
(gdb) n
halted: PC: 0x08000240
halted: PC: 0x08000244
halted: PC: 0x08000246
halted: PC: 0x0800024a
halted: PC: 0x0800024c
halted: PC: 0x08000250
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
halted: PC: 0x08000252
^Chalted: PC: 0x08000252
halted: PC: 0x08000252

Program received signal SIGINT, Interrupt.
0x08000252 in registers::__cortex_m_rt_main () at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/ptr/mod.rs:1150
1150	/rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/ptr/mod.rs: Aucun fichier ou dossier de ce type.

after the second nextinstruction, I enter in the loop rather to go to the next write_volatile ...

If I disassemble, I get :

Loading section .vector_table, size 0x194 lma 0x8000000
Loading section .text, size 0x1220 lma 0x8000194
Loading section .rodata, size 0x1b4 lma 0x80013b4
Start address 0x8000194, load size 5480
Transfer rate: 13 KB/sec, 1826 bytes/write.
Breakpoint 1 at 0x8000224: file src/07-registers/src/main.rs, line 9.
Breakpoint 2 at 0x8001078
Breakpoint 3 at 0x80013b2
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at src/07-registers/src/main.rs:9
9	#[entry]
(gdb) s
halted: PC: 0x0800022a
registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:11
11	    aux7::init();
(gdb) n
halted: PC: 0x08000254
halted: PC: 0x08000236
halted: PC: 0x0800023a
halted: PC: 0x0800023e
18	        ptr::write_volatile(GPIOE_BSRR as *mut u32, 1 << 9);
(gdb) disassemble /m
Dump of assembler code for function registers::__cortex_m_rt_main:
10	fn main() -> ! {
   0x0800022a <+0>:	push	{r7, lr}
   0x0800022c <+2>:	mov	r7, sp

11	    aux7::init();
   0x0800022e <+4>:	bl	0x8000254 <aux7::init>
   0x08000232 <+8>:	movw	r0, #4120	; 0x1018
   0x08000236 <+12>:	mov.w	r1, #512	; 0x200
   0x0800023a <+16>:	movt	r0, #18432	; 0x4800
=> 0x0800023e <+20>:	str	r1, [r0, #0]
   0x08000240 <+22>:	mov.w	r1, #2048	; 0x800
   0x08000244 <+26>:	str	r1, [r0, #0]
   0x08000246 <+28>:	mov.w	r1, #33554432	; 0x2000000
   0x0800024a <+32>:	str	r1, [r0, #0]
   0x0800024c <+34>:	mov.w	r1, #134217728	; 0x8000000
   0x08000250 <+38>:	str	r1, [r0, #0]
   0x08000252 <+40>:	b.n	0x8000252 <registers::__cortex_m_rt_main+40>

End of assembler dump.

I have noticed that the file mod.rs is not found. Could it be the problem ?
I have searched also in the directory that we can see in the tutorial (~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs) but it is not. May anyone explain me what I have missed ?

Many thanks for your responses :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions