Sunday, April 4, 2010

Remote Debugging In Visual Studio

How to debug an issue which is replicated in a test machine but not in your debugger. That's where Remote Debugger comes  handy!

Target Machine - Test machine where issue is replicated.
Host  Machine - Machine where Visual Studio Debugger is present ( Source Code present in debug mode).

The concept applied in Remote Debugger is " Application which is running in target machine is attached to our  host machine through visual debugger". When once the process/application is attached to the host machine the debugger (Visual Studio) considers the apllication to be running locally on the target machine.

Steps followed to set up Remote Debugger:

Note:
  • Before setting up remote debugger make sure that the build EXE is the exact match of the source code  present in host machine. 
  • Make sure the .pdb file which is generated is present in host machine . This  .pdb file is generated automatically on building an EXE.
Steps to be followed in Target Machine:
  • Copy the [drive]:\Program Files\ Microsoft Visual Studio9.0\Common7\IDE\Remote Debugger folder present in host machine  into Target Machine(any drive).
  • Launch your application in Target Machine.
  • Launch msvsmon.exe in Target Machine. This msvsmon.exe is present in Remote Debbuer folder which you have copied in the target machine.
  • When you run the msvsmon.exe you will get a pop regarding security issues  which is set to guest only.Click "yes".
  • Next you might get a pop up regarding configuration of firewall.Select second or third option to allow the host machine to attach to the process/application running in the that machine.
  • Next go to tool/options . On the group box select No Authenitication and click on Allow any user to debug .
  • Make note of the server name and port which will be required from the host side. Click OK .
Steps to be followed in host machine:
  • On Host machine go  Visual Studio ->Tools->AttachTo Process (Ctrl-Alt-P).Change Transport to Remote( Native Only with no authentication).
  • Browse for target machine on your network in the Qualifier Input.
  • It will automatically show all the process attched in that machine or select Show process from all users.
  • Then select the process/EXE to which you would want to debug .Select Attach .
When once the process is attched to our host machine we would be able to debug as usual. Happy Debugging!



No comments:

Post a Comment