PDB are not pointing to the right sources generated with il2cpp

When building a project (mainly with il2cpp), all source and PDB files are moved from a temporary “Temp\StagingArea” folder to the specified build folder.

The problem is that the generated Pdb files indicate that the sources are in Temp\StagingArea, which is initially correct but no longer after the build is complete. So we have PDBs in the build folder with all the source files, but the PDBs point to the old source file location ("Temp\StagingArea") which no longer exists.

Is this considered a bug?
Is there a way not to delete the Temp folder after build/closing editor, so that I can move all generated sources there with PDB without losing them? So after that we have some good PDBs (or we just build the project in the Temp folder without losing them after closing Unity?)

Thanks!

This is by design (sort of). The compiler will embed the full path to source code when building, and we build code inside the Temp folder. However, what kind of issues are you seeing because of this? You should be able to point your debugger to the new location where the source files are moved and that should allow you to still step through the code.

The problem is that if I need to debug later with these pdbs or find the source dynamically, I have to do a pre-process debugging or a post-process build… Why should I have to point the debugger to the new location each time I need to debug it ? are there any use cases that prevent the “fix”?

It’s not every time you need to debug it. You only need to do it once and Visual Studio should remember it. Generally, people back up the directory where the source code is, and when it needs to be debugged or crash dumps investigated later, the source paths wouldn’t match anyway as you don’t even have to do it on the same machine it was built.

The reason the code is built in staging area folder rather than your final destination is because we don’t want to overwrite your old build until we are sure that the new one will succeed. Otherwise, you could end up with half built project in the output folder and that would be very, very confusing.

For more pleasant local debugging, you can use the “Generate Visual Studio Solution” build option, which will spit out a project that you can open in Visual Studio. It will contain all the source code right there and you will be able to debug it by just pressing F5.

1 Like