How to Setup Debugging & Enable ‘edit And Continue’ in Visual Studio
[SIZE=12px]aka: How to Setup Debugging & Enable ‘edit And Continue’ in Visual Studio 2008[/SIZE]
Update 2014-9-27:
[ul][li]Updated the guide to remove ace.dll requirement due to BOOST support added in rev 3ba49277d[/li]
[li]NOTICE: For now you need to disable linker option /SAFESEH or it will ignore the /EDITANDCONTINUE option that gets set when you change the PDB type.[/li]
To do this:
Make sure you are on DEBUG configuration
[li]Right click on a project (eg: authserver) and select Properties[/li]
[li]Expand the Linker category[/li][li]Click on Advanced[/li][li]Scroll down to Image Has Safe Exception Handlers[/li][li]Set it to NO[/li][li]Click Apply[/li][li]Repeat for all other projects in the solution. If a project doesn’t have a Linker category, skip it[/li]
[/ul]
Update History:
[ul][li]Update 2014-7-7:[/li]
Updated guide to include VS2013 specific items (labeled [SIZE=14px][COLOR=rgb(0,0,205)]VS2013[/SIZE]: in the guide below). These items may also apply to earlier versions however when the guide was written for VS2008 they were not an issue.
Details: The debugger in VS2013 is broken and ignores ‘Working Directory’ when loading dependencies while debugging native C++ projects, causing the debugger to fail to execute the project. Setting the PATH variable in ‘Environment’ fixes the issue.
[li]Update 2014-6-24:[/li]
The announcement thread indicates which version of C++ (eg: Visual Studio) you need to compile TrinityCore. The steps in this guide should be relevant unless MS makes major changes to the debugger.
If you find that there are problems, either start a thread in Help & Support (include “edit and continue” in your subject) or make a comment in this thread (though I don’t know how many people follow this thread).
[/ul]
Some people have reported that this does not work for 64 bit applications.
I struggled with this for a bit and now that I figured it out, I thought I’d pass it along
The Guide:
Before you start, compile the solution in Debug mode at least once to get ‘ace.dll’ and then copy all the following (required) DLLs to any folder, you will point Visual Studio to this later:
[ul][li]ace.dll - Not required for sources after rev 3ba49277d due to BOOST support[/li][li]libeay32.dll[/li][li]libmysql.dll[/li][li]ssleay32.dll[/li][/ul]
- Note: 32-bit names listed, 64-bit names will most likely be different (you should know what to look for)
Step 1: Seting up the projects
[SPOILER]
To enable ‘edit and continue’ the projects need a few parameter tweaks
[ul][li]Select ‘Debug’ for your ‘Solution Configuration’[/li][li]Right-Click on the first project (not the ‘solution’ itself) and select ‘properties’[/li][li]Select ‘C/C++’ and then select ‘General’[/li][li]Change ‘debug information format’ to ‘program database for edit and continue’[/li][li]Select ‘linker’ and then select ‘General’[/li][li]Make sure ‘enable incremental linking’ is set to ‘yes’[/li][li]Click ‘Apply’[/li][/ul]
Repeat the above for each project in the solution. If a project doesn’t have the options to set
then just skip it.
Note: You can leave the dialog open and just left-click the next project
[/SPOILER]Step 2: Setting up the debug executable info
‘Edit and Continue’ is not available for programs debugged with ‘attach to’. You need to launch
them from Visual Studio
[ul][li]Right-Click the ‘authserver’ project and select ‘properties’[/li][li]Select ‘debugging’[/li]In ‘command arguments’, enter: -c <path_to_authserver.conf>
example: -c d:trinitycoreauthserver.conf
[/ul]
[li]In ‘working directory’, enter the path to where you have all the dlls (ace, libmysql.dll, etc.)[/li]
Example: d:trinitycorebin
[li]VS2013: In ‘Environment’, define PATH to include the path to your DLL files (usually same path as in ‘Working Directory’)[/li]
Example: PATH=$(PATH);d:trinitycorebin
Note: The $(PATH) is required so you don’t overwrite other PATH definitions. It can come anywhere in the line, just make sure items are separated with a semicolon (eg: item1[SIZE=18px];[/SIZE]item2[SIZE=18px];[/SIZE]item3)
[li]Right-Click the ‘worldserver’ project and select ‘properties’[/li][li]Select ‘debugging’[/li][ul]In ‘command arguments’, enter: -c <path_to_worldserver.conf>
example:-c d:trinitycoreworldserver.conf
[/ul]
[li]In ‘working directory’, enter the path to where you have all the dlls (ace, libmysql.dll, etc.)[/li]
Example: d:trinitycorebin
- Note: Your DataDir (dbc, maps and vmaps) is relative to the ‘working directory’ so either drop them in the folder with the DLLs and use DataDir=“.” or make sure you modify your CONF properly or the server won’t start
Example:
If the “working directory” is: E:devserverstrinitytestbin
And the dbc, maps and vmaps folders are in: E:devserverstrinityassets
In worldserver.conf you would put: DataDir = “…/…/assets” (just like DOS: the "…" moves up to test then trinity and then worldserver.exe will look in assets)
[li]VS2013: In ‘Environment’, define PATH to include the path to your DLL files (usually same path as in ‘Working Directory’)[/li]
Example: PATH=$(PATH);d:trinitycorebin
Note: The $(PATH) is required so you don’t overwrite other PATH definitions. It can come anywhere in the line, just make sure items are separated with a semicolon (eg: item1[SIZE=18px];[/SIZE]item2[SIZE=18px];[/SIZE]item3)
[li]Right-Click the ‘Solution TrinityCore’ at the top of the project list and select ‘properties’[/li][li]Select ‘startup project’[/li][li]Select ‘multiple startup projects’[/li][li]Change both ‘authserver’ and ‘worldserver’ to ‘Start’[/li]
Step 3: Enable ‘edit and continue’ (and other ‘Debugging’ menu settings)
[ul][li]Click ‘Tools’ and choose ‘Options’[/li][li]Expand ‘Debugging’[/li][li]Choose ‘edit and continue’[/li]Place a check in ‘Enable Edit and Continue’
[li]VS2013: Place a check in ‘Enable native Edit and Continue’[/li][/ul]
[li]Choose ‘General’[/li][ul]VS2013: Uncheck ‘Break all processes when one process breaks’
This seems to be enabled by default in VS2013 and will halt worldserver.exe when the authserver.exe finishes loading
[/ul]
That’s it. Now when you choose ‘Debug → Start Debugging (F5)’, Visual Studio will launch both the authserver and worldserver and when you break execution and make changes, the ‘apply code changes’ will be available allowing you to ‘edit and continue’ instead of having to stop and recompile.
Note: There are some cases you can’t use ‘edit and continue’
Supported Code Changes
Precompiled Header Limitations
For more information, see here Edit and Continue (Visual C++)
Some people have reported that this does not work for 64 bit applications.