Open chemicstry opened 1 year ago
cortex-m-rt exports an __sheap
symbol here: https://github.com/rust-embedded/cortex-m/blob/master/cortex-m-rt/link.x.in#L180
Due to the PROVIDE
it should only be defined when it is referenced, so maybe we can use that to detect the heap instead?
ah that was the original plan, it seems like that didn't work right: https://github.com/knurling-rs/probe-run/issues/31#issuecomment-680075492
Ah I see.
I really liked the watermark idea from the linked issue since it would work with heap and could also report approximate stack usage. Any reasons for not doing that instead? I imagine chips with large memory could be slow, but is that an issue with anything that probe-rs supports?
That is what we implemented
I really liked the watermark idea from the linked issue since it would work with heap and could also report approximate stack usage. Any reasons for not doing that instead? I imagine chips with large memory could be slow, but is that an issue with anything that probe-rs supports?
@chemicstry You can enable this feature with the --measure-stack
option. Also since https://github.com/knurling-rs/probe-run/pull/302, https://github.com/knurling-rs/probe-run/pull/327 and https://github.com/knurling-rs/probe-run/pull/331 it got pretty fast.
So it seems that rust compiler does not emit the
__rust_alloc
symbol, or it gets inlined? I'm not sure what would be the best way to fix this. Adding additional symbols to check like__rust_realloc
might not be fail-proof if they can be inlined too.
It seems that this is the best we can do. But I personally don't know if the symbols __rust_alloc_error_handler
and __rust_realloc
are only present if there is some kind of heap, or if they are also present in other situations. Do you know about this?
It seems that --measure-stack
option works, or at least doesn't give warnings. However, the stack measurement is still broken:
$ probe-run --chip STM32F429ZITx --measure-stack target/thumbv7em-none-eabihf/release/fw-power-switching
(HOST) INFO flashing program (119 pages / 119.00 KiB)
(HOST) INFO success!
(HOST) INFO painting 181.31 KiB of RAM for stack usage estimation
────────────────────────────────────────────────────────────────────────────────
...
────────────────────────────────────────────────────────────────────────────────
(HOST) INFO reading 181.31 KiB of RAM for stack usage estimation
(HOST) INFO program has used at least 181.31/181.31 KiB (100.0%) of stack space
It could be due to an issue with my code, though. I will update once I find more time to investigate this.
Is this example with some kind of heap? Atm, we only handle single-ram chips well.
I'm using heap provided by alloc-cortex-m on STM32F429ZIT6, however probe-run fails to detect heap usage and still installs stack canary, which results in bogus warnings like:
I have narrowed the problem to this heap check, which fails to detect any of the alloc symbols.
Output of
cargo nm --release | grep alloc
:So it seems that rust compiler does not emit the
__rust_alloc
symbol, or it gets inlined? I'm not sure what would be the best way to fix this. Adding additional symbols to check like__rust_realloc
might not be fail-proof if they can be inlined too.