cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE debugger locks .elf file before post-build command

Igor Petrov
Associate II

I have several projects where my workflow relies on the execution of post-build script that manipulate and modify .elf file produced by the compiler.

However, when I try to debug (to be more specific- relaunch already running debug session) such project I get an error as on the attached screenshot- .elf file is being locked and not possible to modify. Even worse that file gets unlocked only if I close CubeIDE.

Steps to reproduce the error:

1. have any project that could be debugged, for example, simple generated skeleton project

2. Add post-build command that modifies the .elf file, could be something simple as 'move' command

cmd.exe /c "move ${ProjName}.elf moved.elf & move moved.elf ${ProjName}.elf"

3. Start debug session by pressing "green bug" icon. "Enable auto build" and "Shared ST-Link" options must be checked.

4. Restart debug session by pressing "green bug" icon.

The bug does not happen all the time, but may occur after several dozen tries, which make me think there's a race condition in the debugger, and sometimes it tries to access the elf file before make finished post-build command.

The problem occurs on CubeIDE versions 1.6.0 and 1.7.0, probably earlier versions as well.

Is there any way on current 1.7.0 version to avoid elf files being locked? Terminating debug sessions helps, but extra steps and perspective switches are just too annoying.

3 REPLIES 3
KnarfB
Principal III

What are you doing between steps 3 and 4? Post-build has more to do with build, not so much with debug.

Ok, there are more steps. Today I spent 3 hours trying to figure out a reliable sequence of actions and, I guess, I found it.

  1. Be in C/C++ perspective
  2. Build the project
  3. Press "green bug" icon
  4. CubeIDE stats debug session and asks to switch to Debug perspective, accept Switching
  5. Press "Resume" button
  6. Press "green bug" icon again

I captured the entire process on video that you can see here -> https://youtu.be/T2lkSUZ7CKc

KnarfB
Principal III

I see. When you press the green bug button for the 2nd time, the first debug session is still running and still locking the .elf.

The IDE does the post-build step first, before ending the previous debug session, and so the post-build step will fail.

Two workarounds, because I doubt that the behaviour you described will be changed in the future:

If you are not changing the source code, press the "Reset the chip and restart debugging" button (green triangle + yellow back-arrow) instead. This will not re-build/re-load the prog, just re-start the debugging.

If you want to change the source code between debug runs, halt debugging (red square) before editing.

Note also that the IDE/gdb communication is via TCP and it may take some time (seconds) before the connection is fully closed or re-opened, take it easy.

hth

KnarfB