I’m trying to do some native (MingGW) unit tests, and one isn’t behaving as I’d expect so I’m trying to debug it.
As I debug through the unit tests, the instruction pointer/yellow current line in VSC isn’t always where I think it should be.
As I start debugging, it first breaks at the start of main (as per my understanding of how
the default for debug_init_break
works. OK
Then it breaks inside setUp()
, not an issue, but unexpected - ive no breakpoint set
Then it breaks inside my code where I’ve no breakpoint set
From then on it sort of follows the execution I’d expect, but the call stack keeps jumping about, it “returns” earlier than the source files define - so I’m assuming some sort of optimisation has occurred here.
Setting -O
in debug_build_flags
to anything other than -Og
seems to prevent the debugger from attaching Is that to be expected? Incidentally, sometimes the debugger doesnt attach using the default build flags - i can’t determine why.
[env:native]
platform = native
build_type = debug
debug_test = mytest
; debug_build_flags = -O0 -ggdb3 -g3
Any ideas? Many thanks, loving PIO otherwise!