It's not possible to debug the same version of the exported game as the one you ship. Or at least much harder, because when you export the game, a
release version of the engine is packed with your game data, which is stripped from many checks and debugging information that would slow it down or make it heavier.
If you have a specific problem with your exported game, you can expose the actual problem so it's more clear which kind of failure we'd have to deal with (which OS? Which platform?). It can be a complicated engine bug (release bugs are THE BEST), or it could be a simple script issue like using wrong file paths. For example, it's a common mistake to load files in
res:// which works in editor, but have it fail after export because such file can have been stripped by the export (that's the case of PNG files imported as textures).
There is also something more involved you can try: as mentionned, by default a
release engine version is packaged. But it's possible to package a
debug version instead, as visible in the
Export window options. This requires you to build the engine yourself in debug mode. The documentation has a section describing extensively how to get the source code and compile it: https://docs.godotengine.org/en/stable/development/compiling/index.html
Doing this would then allow you to attach a C++ debugger to your running game and see what's going on.
I've never done that myself with an export template but I know it's a possible option.
One last thing I'm thinking, but I'm not sure about:
If you export your game as
PCK, you get
.pck and an executable file. That executable is actually the engine itself. You could try deleting it, and replacing it with the executable of the editor itself. Then, from a system console, run it with the
-d option to run the game with the command line debugger. I have no idea if that works tho.