Jump to content
TrinityCore

[Howto] Setup Debugging & Enable 'Edit And Continue' In Visual Studio (Updated 2014-9-27)


MrSmite
 Share

Recommended Posts

How to Setup Debugging & Enable 'edit And Continue' in Visual Studio

aka: How to Setup Debugging & Enable 'edit And Continue' in Visual Studio 2008

 

Update 2014-9-27:

  • Updated the guide to remove ace.dll requirement due to BOOST support added in rev 3ba49277d
     
  • 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.

    To do this:
    • Make sure you are on DEBUG configuration
    • Right click on a project (eg: authserver) and select Properties
    • Expand the Linker category
    • Click on Advanced
    • Scroll down to Image Has Safe Exception Handlers
    • Set it to NO
    • Click Apply
    • Repeat for all other projects in the solution. If a project doesn't have a Linker category, skip it
       

Update History:

  • Update 2014-7-7:

    Updated guide to include VS2013 specific items (labeled VS2013: 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.
     
  • Update 2014-6-24:

    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).

 

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:

  • ace.dll - Not required for sources after rev 3ba49277d due to BOOST support
  • libeay32.dll
  • libmysql.dll
  • ssleay32.dll

* 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


To enable 'edit and continue' the projects need a few parameter tweaks
  • Select 'Debug' for your 'Solution Configuration'
  • Right-Click on the first project (not the 'solution' itself) and select 'properties'
  • Select 'C/C++' and then select 'General'
  • Change 'debug information format' to 'program database for edit and continue'
  • Select 'linker' and then select 'General'
  • Make sure 'enable incremental linking' is set to 'yes'
  • Click 'Apply'

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


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

  • Right-Click the 'authserver' project and select 'properties'
  • Select 'debugging'
    • In 'command arguments', enter: -c <path_to_authserver.conf>
      • example: -c d:trinitycoreauthserver.conf
    • In 'working directory', enter the path to where you have all the dlls (ace, libmysql.dll, etc.)

      Example: d:trinitycorebin
       
    • VS2013: In 'Environment', define PATH to include the path to your DLL files (usually same path as in 'Working Directory')

      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;item2;item3)
  • Right-Click the 'worldserver' project and select 'properties'
  • Select 'debugging'
    • In 'command arguments', enter: -c <path_to_worldserver.conf>
      • example:-c d:trinitycoreworldserver.conf
    • In 'working directory', enter the path to where you have all the dlls (ace, libmysql.dll, etc.)

      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)
       
    • VS2013: In 'Environment', define PATH to include the path to your DLL files (usually same path as in 'Working Directory')

      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;item2;item3)
  • Right-Click the 'Solution TrinityCore' at the top of the project list and select 'properties'
  • Select 'startup project'
  • Select 'multiple startup projects'
  • Change both 'authserver' and 'worldserver' to 'Start'

 

Step 3: Enable 'edit and continue' (and other 'Debugging' menu settings)

  • Click 'Tools' and choose 'Options'
  • Expand 'Debugging'
  • Choose 'edit and continue'
    • Place a check in 'Enable Edit and Continue'
    • VS2013: Place a check in 'Enable native Edit and Continue'
  • Choose 'General'
    • 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

 

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.

Edited by MrSmite
  • Upvote 6
Link to comment
Share on other sites

  • 9 months later...

Update 2012-11-20
 
Note: The hotfix download link is to a 3rd party repository so use at your own risk.
 
There is an issue where Edit and Continue displays a message: Edits were made that cannot be compiled but there is no error information in the error window. Microsoft has released a hotfix for VS 2008 SP1. You can read about it here to decide if you want to instal it.
 
This hotfix is not available directly from Microsoft unless you call support, it seems it was written specifically for one customer:
 
 

Thank you for contacting us. This patch was released to address an issue for a specific customer that required a fix targeting Windows XP and Visual Studio 2008 SP1 (English only). Please let us know if you still need the hotfix targeting other languages.


Edit: Updated quote to indicate English only

Edited by MrSmite
Link to comment
Share on other sites

I guess that customer must have felt great.

Depends how much they charged him for the phone support :)

 

Only reason I even bothered to post it was because I got the same error. All I did was change a "return false;" to "return true;" and the compiler bitched at me but wouldn't tell me why.

Link to comment
Share on other sites

All in all, what was the real error of that change anyways?

There wasn't one. I closed Visual Studio to install the hotfix and when I reopened it there was no error during compile. I read on another site that "edit and continue" often reports errors that don't get reported during a full build, especially when your mucking around with return values.

Link to comment
Share on other sites

  • 3 months later...

Hello, yesterday I succesfully installed a Trinity Core server and, using this tutorial (http://www.trinitycore.org/f/topic/5667-howto-setup-debugging-enable-edit-and-continue-in-vs-2008/) I wanted to do some debugging. Only problem: Though I set everything up like in the tutorial, I need to recompile every time I change some line of code, even if its something trivial like changing some spell-id in an "case x:"-statement. I've read that there are some problem with this, but those articles linked in the tut doesn't seem to apply to me. I'm using Visual Studio 2010 x86, on a 64-bit Windows 7 Ultimate - machine. The error I'm getting is saying something about "Changes where made that couldn't be compiled" (VS is german so I can't tell you exactly). Any ideas why this can fail?

Link to comment
Share on other sites

Unfortunately there could be several things wrong. Did you try Google? I found a bunch of discussion about VS 2010 and "Edit and Continue" problems. A few things to consider:

  1. Are you on an x64 machine but building an x86 project? See here.
  2. Are you compiling a debug build?
  3. Do you have all the latest updates for VS 2010?
  4. Are you launching through the debugger or trying to attach to the EXE afterward?

If all else fails, you can always install VS2008, Trinity doesn't need VS2010***.

 

Edit:

 

*** This announcement indicates that as of October 21st, 2013 Trinity will require at least VS 2010.

Link to comment
Share on other sites

Thanks for your quick reply!

Are you on an x64 machine but building an x86 project? See here.
Unfortunately this didn't solve the problem. I tried to google before and came across a lot of posts, specially on stackoverflow, but all of them where about .net-framework consolse aps etc.. , so most of the settings they changed to make it work doesn't even exist for here. Or do they? For example "Projects>Properties>Build -> Optimize Code". Maybe I don't find them, as for the german thing..
Are you compiling a debug build?
Yes, I am.
Do you have all the latest updates for VS 2010?
Yes, I do have, I just checked it.
Are you launching through the debugger or trying to attach to the EXE afterward?
I'm launching through the debugger, pressing "F5" in VS. Thanks for the help anyway, unless you've got some other idea (I see that its hard to "quess" whats going wrong here) I'll try and install VS2008.. fun fact, I already had it installed on my PC, but can't find it anymore.. don't know where it went oO
Link to comment
Share on other sites

Do a search for the directory: Common7IDE, that's where devenv.exe for 2008 gets installed.

This gives me only a ~1.5mb sized folder without any .exe (only three sub-folders with a few archives in it. Seems like I deinstalled it a while ago, weird. Anyway, that way I can download & install the english version, might eventually come in handy for this project. Thanks again!

Link to comment
Share on other sites

So I tried it with VS 2008, but I experience exactly the same issues. Let me summarize what I did, to make sure that I didn't leave anything out.

 

1. I set the build to "Debug".

2. I checked that target is set to "Win32".

3. I set "debug information format" to "program database for edit and continue" for every single project that had this flag (everything except INSTALL, ALL_BUILT and ZERO_CHECK)

4. I checked that "enable incremental linking" is set to "yes"

5. I set the "debugging command paramteres" of the auth and world server to be "-c T:TrinityBuildbinDebugauthserver.conf" (worldserver.conf for latter).

6. I changed the working directory of both of the auth and world server to T:TrinityBuildbinDebug, where they get compiled to, and all the dll's, dbc and maps are.

7. I set up the multiple startup projects" to start both the auth and world server.

8. I checked that "edit and continue" is enabled.

 

So uhm... anything that I forget? I still get this "code changes that cannot be compiled -> "edit", "end", "abort" " - message... or some more ideas which settings I could check?

Edited by Juliean
Link to comment
Share on other sites

I already tried to install the patch but it failed, saying something about that "no software was found to apply this patch to". Trying to install the SP1 gives me a similar message. The source I downloaded the .iso for says that it already has SP1, and the "info" window says I have the "Version 9.0.30729.1 SP". The error-message of the SP1 also states it is not compatible to the Express Edition. Is it possible to apply this patch to an express edition of VS or do I need a higher version (which I don't see where to get it from anymore). Or is it maybe an issue with the languege? I did install it in german after all, too. Thanks in advance!

Link to comment
Share on other sites

What part are you referring to where I said I don't understand german? Granted my englisch isn't all perfect, so I might have confused you, but I'm a native german speaker.

 

As for buying VS, I didn't buy it (at least the 2008 version), I downloaded the free "Express Edition". So my question was: Can I apply this patch to a german express version of VS or do I need an englisch and/or "higher" version of VS for it to work?

Link to comment
Share on other sites

What part are you referring to where I said I don't understand german? Granted my englisch isn't all perfect, so I might have confused you, but I'm a native german speaker.

 

As for buying VS, I didn't buy it (at least the 2008 version), I downloaded the free "Express Edition". So my question was: Can I apply this patch to a german express version of VS or do I need an englisch and/or "higher" version of VS for it to work?

 

Hmm, maybe that patch doesn't work on VS Express.

Link to comment
Share on other sites

Hmm, maybe that patch doesn't work on VS Express.

 

That's what I was afraid of, too.. in that case, where would I get a legal regular copy of VS 2008? I'd already bought one, if not for the fact that it doesn't seem to be selled anymore. Or should I call MS phone service, so they could maybe to make a patch for VS 10, like they did back then?

Edited by Juliean
Link to comment
Share on other sites

That's what I was afraid of, too.. in that case, where would I get a legal regular copy of VS 2008? I'd already bought one, if not for the fact that it doesn't seem to be selled anymore. Or should I call MS phone service, so they could maybe to make a patch for VS 10, like they did back then?

 

Microsoft offered VS 2008 as a 90 day trial but they've axed all my links in favor of VS 2010. You can still download the ISO from various bittorrent sites but you have to wonder if they've been tampered with. Also, if they provide a serial then you're stepping into the warez territory. Just grabbing the ISO is fine because it was offered for free to everyone.

Link to comment
Share on other sites

Hello,

 

I've finally found a non-cracked version of VS2008. I installed it, installed SP1, then installed the hotfix... but still, edit and continue isn't working. For example, I tried to edit this code snippet from unit.cpp:

 

//...
                        if (dummySpell->SpellIconID == 2622)
                        {
                            if (player->GetCurrentRune(i) == RUNE_DEATH ||
                                player->GetBaseRune(i) == RUNE_BLOOD)
                                continue;
                        }
                        else
                        {
                            if (player->GetCurrentRune(i) == RUNE_DEATH ||
                                player->GetBaseRune(i) != RUNE_BLOOD)
                                continue;
                        }

the things I tried out was: commenting the second condition in "if(player->GetCurrentRune(i)..." ; adding an "int i = 0" before the if condition. Both gives me the following error:

 

t:trinitysrcservergameentitiesunitunit.cpp : error C2018: unknown character '0xbf'
t:trinitysrcservergamemapszonescript.h(24) : error C2144: syntax error : 'GameObject' should be preceded by ';'
t:trinitysrcservergamemapszonescript.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-intt:trinitysrcservergameentitiesunitunit.cpp : error C2018: unknown character '0xbf'

 

My VS2008 is englisch 32 bit, edit & continue is enabled. Any additional ideas what I could do? I can't think of working with the trinity core this way, having to compile & wait for the server to start for every little code change I do. Or is there maybe some way to get the server to start faster in debug build? It takes almost 2-3 minutes on my high-end not a year old pc, while in release mode, its like 15-20 seconds. Any help would be highly appreciated!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...