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:
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:
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.
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.comor 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.