0 votes

I was able to put breakpoints and debug the engine code from visual studio using tutorials linked below, so the engine opens from visual studio but as soon as I open any project, I cannot debug anymore from visual studio. Is there a way to debug the C++ modules with breakpoints?



asked Mar 8 in Engine by anubha (51 points)

1 Answer

+1 vote
Best answer

If you don't specify command line arguments, Godot will launch in Project Manager mode. When you launch a project from there, it closes, which makes the debugger detach.

If you want to debug the editor or a game straight away, you should change the execution directory to be your project's directory, and add command line arguments, as explained here: https://docs.godotengine.org/en/stable/development/cpp/introduction_to_godot_development.html#debugging-the-editor-with-gdb
(it says "GDB" but it's the same with Visual Studio, there is a project settings option that lets you specify those arguments).

-e will make Godot run in editor mode. Omitting it will run the game from its main scene.
If the game has no main scene, or if you want to run a particular scene, add its relative path to the command line, like scenes/level1.tscn.

I don't know if the doc has a section explicitely showing that for Visual Studio, but here is how it looks like in QtCreator for debugging the editor on a project:
enter image description here

answered Mar 8 by Zylann (26,153 points)
selected Mar 9 by anubha

Thanks for your answer, now the debugger doesn't detach as soon as opening project and project opens directly. I could catch the breakpoint on the bindmethods in my module in C++ but the breakpoints on the methods itself aren't hit:

code snippet

The breakpoint in bindmethods() and the constructor is hit, but not inside the process() or UpdateMotionFromInput(), any idea what is going wrong?

Maybe they aren't actually called? (I can't see your snippet)

I just read this thread: reddit thread
So I tried running game directly without the editor by removing the -e option and now all breakpoints work :)
Will just run the game directly bypassing the editor whenever I need to debug then. Thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.