Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to auto rename the PDB to avoid blocking debug symbols #1331

Closed

Conversation

DmitriySalnikov
Copy link
Contributor

@DmitriySalnikov DmitriySalnikov commented Dec 11, 2023

Fixes godotengine/godot#82536 but only for godot-cpp and scons.
Other language binds should make similar fixes to the build system to support Hot-Reload and debugging on Windows.

The main problem with PDB is that the name of this file is written to the DLL during the build and you can't just rename it. You can move the PDB and DLL to another folder or place them in different folders and specify pdb folder in Visual Studio and everything will work. But you can't change the name of the PDB, so that it can't be used automatically for debugging. Maybe I'm wrong and there is a more elegant solution.

To solve this problem, I added a new file methods.py, as in Godot, in which the msvc_try_rename_pdb function is located. This function checks whether renaming can be applied and outputs a new path to the console.

The search for an unblocked name takes place in _get_unblocked_file_name. In this function, I first find all the PDBs except the newest one, in order to save it if the project has not been modified, since scons will not restore it when deleted. Then I try to delete these files and search for the first unblocked name based on the template {"full/library_name"}_{index}.pdb.
And at the end of msvc_try_rename_pdb I explicitly specify the /PDB: for the linker.

This function is registered via env.AddMethod in godotcpp.py and can be called in a user script, for example in a test script.

I also updated .gdextension file to 4.2 and reloadable = true, because there is nowhere else to find how to activate hot-reloading.

Demo:

pdb_rename.mp4

@DmitriySalnikov DmitriySalnikov requested a review from a team as a code owner December 11, 2023 03:57
@kone9
Copy link

kone9 commented Dec 11, 2023

I talk about this here too, but with visual studio for debug mode.
Although I couldn't solve it, I investigated several things.

#1327 (comment)

#1327 (comment)

@Bromeon
Copy link
Contributor

Bromeon commented Dec 11, 2023

Thanks for this!

Fixes godotengine/godot#82536 but only for godot-cpp and scons.
Other language binds should make similar fixes to the build system to support Hot-Reload and debugging on Windows.

Out of curiosity, is it not possible to fix this upstream?

Requiring the same fix from every binding will put quite a burden on binding developers and may lead to inconsistent experience (or even the perception that hot reloading is still flawed)...

@DmitriySalnikov
Copy link
Contributor Author

Actually, you can do something like:

# if the build script is outside of godot-cpp
$ python -c "import sys; sys.path.insert(0, 'godot-cpp/tools'); import methods; print(methods._get_unblocked_file_name('bin\libexample.win.dll', 'pdb'))"
bin\libexample.win_0.pdb

# if the build script inside of godot-cpp
$ python -c "from tools import methods; print(methods._get_unblocked_file_name('bin\libexample.win.dll', 'pdb'))"

But it still requires python installed and the ability in the build system to run applications and get output from them.
This method of calling python is already used here in CMake.

If, for example, in Rust this is possible, then you can call a Python script and get a new PDB name. But if you don't want to or can't call python, then rewriting the script shouldn't be a problem.

@dsnopek dsnopek added this to the 4.x milestone Dec 22, 2023
@dsnopek dsnopek added enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup labels Dec 22, 2023
@dsnopek
Copy link
Collaborator

dsnopek commented Dec 22, 2023

Thanks!

I think it makes sense to finish pursuing the idea for rewriting the path to the PDB file from your experiments on this issue, before going any further with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Locked PDB file blocks GDExtension compilation when Editor is launched within debugging
6 participants