How to manually debug crashes with VisualStudio
-
Go to Debug -> Options and Settings… ClickMe
Go inside Debugging -> General ClickMe
[v] Show disassembly if source is not available
-
On UserInterface -> Properties ClickMe
Go inside Linker -> Debugging ClickMe
- Generate Debug Info -> Yes (/DEBUG)
- ~Map Exports -> Yes (/MAPINFO:EXPORTS)~ (not required)
- Debuggable Assembly -> Yes (/ASSEMBLYDEBUG)
-
Compile and execute the launcher.
-
Debug -> Attach to Process… ClickMe
metin2client.exe -> Attach ClickMe
-
When you will get a crash (or “??????”) you will get the Call Stack ClickMe
-
To disable all: ClickMe
On UserInterface -> Properties
Go inside Linker -> Debugging
- Generate Debug Info -> No
- Map Exports -> No
- Debuggable Assembly -> No (/ASSEMBLYDEBUG:DISABLE)
Note: Whether the target is set on Release or Debug, it’s irrelevant
How to start a debugging session without attaching
-
Go to the Solution’s property and choose UserInterface as the main project. ClickMe
-
On UserInterface -> Properties -> Debug, change the working directory to your client path. ClickMe
-
Now 1) press the green arrow or 2) f5 or 3) Debug->Start debug (visual studio will ask admin privileges due to the launcher’s manifests) and enjoy the debugging.
How to copy the built launcher and start a debugging session automatically elsewhere
Lazy to copy the launcher from bin to client (local debugging path), then start the debugger? This can be automated.
-
On UserInterface -> Properties -> General -> Output Directory, the path must have
\\slashes and NO/ones. -
On UserInterface -> Properties -> Build Events -> Post compilation events -> Command-line: ClickMe
copy /y "$(TargetPath)" "$(LocalDebuggerWorkingDirectory)$(TargetFileName)"
Now you can press Play (F5) directly.
Issues
-
The debugger can’t attach properly to the launcher if the “python” module of Visual Studio has been installed from Visual Studio Installer.
-
If it doesn’t start the debugger at all, disable the Microsoft Symbols from Debug -> Debug -> Symbols ClickMe
-
If the debug target can’t read the .pdb files (Debug -> Windows -> Modules Window)
-
For Debug target:
Try on UserInterface -> Properties -> Linker -> Debug -> Generate database ->
$(IntDir)$(TargetName).pdb -
For Release target:
Try on UserInterface -> Properties -> Linker -> Debug -> Generate database ->
$(TargetDir)$(TargetName).pdb
-