Proteus has some problem with path handling. The symptom: it receives the .elf file, simulation is working, but the source view window is empty. The reason that the .elf file doesn’t include the source code, it just points to the source files with relative paths. In some cases Proteus fails with the path. There is a workaround:
When you double click on the uC in Proteus, and browse for the .elf file, the path in the box looks something like this:
..\..\..\..\0work\bubuws\bubu\Debug\bubu.elf
Proteus somehow fails with these
..\..\..\
Replace it with the absolute path, for example c:\0work\bubuws\bubu\Debug\bubu.elf
I didn’t tried with PIO, but it is working with the .elf from STM32CubeIde.
With the .elf from Keil one more step required: copy the .elf one folder up. For example copy it from c:\0work\bubuws\bubu\Debug\bubu.elf to c:\0work\bubuws\bubu\bubu.elf and pick it from here with Proteus.
One more thing: the .elf has to include dwarf2 debug information. In case of the GCC toolset use
-gdwarf-2,
in Keil use
–gdwarf2.