Closed JayToltTech closed 11 months ago
When restarting a debug session after rebuilding my .elf file, the previous build is started by the debugger unless I clean the build folder first.
Not sure how you 'restarted'. Did you stop and start a new debug session? Or did you just use the re-start button? If it is the later we don't reload the executable. That was not a desirable feature for most users and will not change. You can however force a reload it by using preRestartCommands
... but the symbols may not match any more because that is also done once at the start.
We also are not involved in how/why you build your executables.
Restart is Stop/Start. I have confirmed that the filesystem shows new timestamps on the ELF, so it's not an 'oops I didn't actually build' or 'I built to the wrong place' issue, AFAIK. I've confirmed there isn't a second 'mystery ELF' hanging around in the file system that I can find under the build directory or the source tree. Cortex-Debug is being passed the correct full path to the ELF file which has the updated build timestamp.
The log shows that the elf is being flashed, but the code from the older elf is what is running after the Start.
We don't control that. We don't even cache ANYTHING across a Stop and Start. In fact, our debugger is killed and restarted. So, I am not sure what is wrong with your OS -- are you using a network drive?
Also, if we are reloading, where did we get the older elf from?
It's a mystery to me too! Using a local drive on MacOS with a single disk/volume, no mystery mounts or links or such...
The logs don't show more detail about how Cortex-Debug goes from:
"executable": "/Users/jay/Code/adr_prototype_2307/build/adr-prototype-2307.elf",
to
Resetting target Downloading 16112 bytes @ address 0x00000000 ...
Perhaps something in that path is using a stale open file handle to read bytes?!?
So looking at the logs, it looks like Cortex-Debug passes a file path, not object bytes, to JLinkGDBServer:
Launching gdb-server: JLinkGDBServer -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device ATSAME54P20A Please check TERMINAL tab (gdb-server) for output from JLinkGDBServer ... 10-file-exec-and-symbols "/Users/jay/Code/adr_prototype_2307/build/adr-prototype-2307.elf"
So perhaps this is a bug in JLinkGDBServer rather than Cortex-Debug itself?
OK, I moved to Segger Tools V7.94a from V7.86g and the issue seems to have gone away after a few light tests...
No, it can't even be a bug in JLinkGDBServer. Something else is at play.
For instance, on a Mac, if you move a file to trash, it is not really gone. If you use the same path name, it will serve things from the trash without you even knowing it.
I don't have a clue what is exactly happening on your computer. I am going to close this because I am 99.9% sure it is not our problem.
@JayToltTech did you ever find out why this is happening for you? Sounds a lot like a problem I have. We are using Windows though.
Describe the bug
When restarting a debug session after rebuilding my .elf file, the previous build is started by the debugger unless I clean the build folder first.
To Reproduce
Build file use VSCode CMake Build or terminal
cmake -S . -B build -G Ninja; ninja -C build -j 10
VSCode 'Run and Debug' with below config:
View output using JLinkRTTViewer which is show build date from
printf("Built on %s at %s\r\n", __DATE__, __TIME__);
I have confirmed that the ELF is modified by viewing the file system. For whatever odd reason, it will not flash until I clean
rm -rf build
and then rebuild first.Expected behavior
After build, new ELF is flashed before debugger session is started.
Environment (please complete the following information):
VSCode 1.85.0 Cortex-Debug v1.12.1 Segger JLink Plus Compact Microchip SAME54Xplained MacOS 14.1.2 gcc version 13.2.1 20231009 (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) GNU gdb (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.90.20231008-git
launch.json
Attach text from
Debug Console
gdb-server console spew:
Output from JLinkRTTViewer with build date of 15:02
Output from
ls -l build
showing the new (but unflashed) .elf file from 15:15