Amazon Honor System Click Here to Pay Learn More

MS Visual C++

REMOTE DEBUGGING

By Randall L. Morgan

Copyright 2001 Spurious Alien Propagation

Copyright 2001 Randall L. Morgan

 

Introduction

Software development is an interactive process. Applications are developed in a progressive manner. As features are added, the current version must be debugged before further features are added. If you develop graphical applications, you may often find the need to retrieve debugging information from an application that is controlling the display device and locking out other application from displaying information. Or, perhaps you develop network applications that require two applications to run on two separate machines and communicate together? Often times this makes it difficult to debug the remote application unless you have physical access to both machines. If you develop these types of applications you may find remote debugging will ease your development tasks.

Finding information on using the remote debugging tools that comes with Microsoft’s Visual C++ is a chore. You must sort through Microsoft’s mountain of documentation or fumble through the process via trial and error. This tutorial on using the remote debugging tools in MSVC++ is based on MSVC 6.x with service pack 4. (Microsoft just released service pack 5 today, for there Visual Studio Development tools.)

The use of the remote debugging tools in MSVC requires just a little bit of work to set up. However, once you have things set up, the actual debugging process is the same, with the same familiar Visual Studio tools. The setup process begins with the Remote Target computer. The "remote" as we will refer to it, is the machine that will actually run the executable. When I was working on The Eternal Legacy Server application for Spurious Alien Propagation, I developed all my code at home on a Win98 machine and logged into the SAP Server machine some 60 miles away to debug the Server application. The Server machine was running Win2K and the code that was written for the server application required Windows NT 4.0 or higher. In that scenario, the Remote Host was the SAP server machine.

Now to remote debug an application, you must have at least two machines connected in some form. The second machine is referred to as the Host machine. The host machine runs the MS Visual Studio Development GUI, which must also be setup to run in a remote mode. To set your system up for remote debugging you will need:

  1. Two Computers capable of running MSVC and the application you are developing.
  2. A network connection between the two PCs.
  3. A copy of MSVC (Standard or Professional.)
  4. The IP addresses or network names for the two PCs.

 

Setting-up the Remote Host

To setup the remote host requires that the MSVCMON application be installed. This application is the Visual C/C++ debug monitor. Now, Microsoft could have created a simple application to install this for us, but they did not want to deprive us of the fun of finding all the needed files scattered about our PCs. So, you’ll need to use the Find File utility on your window’s start menu to locate the following files on your machine.

MSVCMON.EXE -- The Debug monitor

MSVCRT.DLL --

TLNOT.DLL --

DM.DLL --

MSVCP60.DLL --

MSDIS110.Dll --

PSAPI.DLL -- (needed for NT and 2k only)

Once you have located these files, copy them to the Windows or WinNt Directory on the remote machine. Then place a copy of the MSVCRT.DLL in the Windows\System32 or WinNt\System32 subdirectory of the remote machine. Once this is done reboot the remote.

 

Setting-up the Host System

The host machine must be prepared to connect to the remote machine. To do this, follow these steps:

  1. Start MSVC, load your project’s workspace, and select Build->Debugger Remote Connection menu item.
  2. The Remote Connection dialog will open.
  3. If the Platform drop-down list is not disabled (i.e.: your version of MSVC allows targeting applications to multiple platforms), select the appropriate platform.
  4. In the Connection Drop-down list, select the Network (TCP/IP) connection type.
  5. Now, select the Settings option and enter the name of the remote machine or the remote’s IP address in the space provided.
  6. If the password field is available, enter your password (Note: this password must match that used on the remote machine.) otherwise leave this field blank.
  7. Select OK and close the Settings Dialog.
  8. Select OK to close the Remote Connection dialog.

 

Now both machines are setup for connecting.

 

Starting a Debugging Session

Now we need to make a few final adjustments to the Project settings before we connect.

  1. Copy the complete project to be debugged to the remote machine. Note the drive and directory your store the project files and note that this directory must be setup as a shared directory.
  2. On the host machine, start MSVC and load the project (if it is not still open), and choose Project->Settings and the Project Settings Dialog box will open.
  3. Choose the Debug tab and select Debug->Category->General.
  4. In the "Executable for Debug Session" enter the path to the project executable file as the host sees it.
  5. Leave the "Working Directory" field blank.
  6. Leave the "Program arguments" field blank unless your application requires arguments to be passed at startup.
  7. In the "Remote executable path and file name" field, type the file path and project executable as the remote sees it.
  8. Now in the Category dropdown list, select "Additional Dlls." Enter the path and file name of any additional dynamic link libraries that your application will use in the "Local Name" and "Remote name" fields of the Modules Dialog. Also, make sure that the "Try to locate other Dlls" is selected. You can often leave the "Local name" and Remote name" fields blank if this is selected. But,it is best to set these up to ensure the proper operation.
  9. Now start the MSVCMON application on the remote host. Double-check your settings for the IP address or machine name.
  10. When the Debug monitor starts, click the "Connect" button. A dialog will appear that says "Connecting…"
  11. Now, on the host system in MSVC, select Build->Start Debug menu item and press F11 on the keyboard or select "Step Into" from the menu options.
  12. Give the systems a minute or two to start communicating across the network. Then start your debugging session as you normally would.

Notes:

I found PCAnywhere to be invaluable during our online project development. Also note that anytime your project files change you must update the files on the remote machine. PCAnywhere or CuteFTP can be used to copy files across a network. There are many other tools as well that may come in handy. If you are running a machine that has it’s IP address dynamically assigned, ipconfig.exe or winIpcfg.exe can be used to locate your assigned IP address. If you have difficulties with your connection ping.exe can be used to test network validity. All these tools and more are most likely already installed on your Window machine. If not, consult the online window’s help files.

Send comments on this article to: Randall_Morgan_1@Compuserve.com

or visit: http://www.alien-propagation.com/

While the Author maintains all rights to this article, I give permission to anyone to reproduce this article in any form for educational purposes as long as no fee is collected for the use of this article. This article is released under the GNU Open Source license. Users must abide by the articles of the license.

HOME

Amazon Honor System Click Here to Pay Learn More