Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

Troubleshooting

If the development environment can't find the executable, make sure that you give the correct directories for the correct computers.

Because Visual C++ 5.0 supports only TCP/IP connection, check for the correct machine name and proper network connection with TCP/IP available.

Attaching to Running Processes

There may be instances when parts of the application you are working on are running in separate processes or even on different machines.

The Attach to Process option attaches the debugger to a running process. This enables you to break into the process and perform debugging operations as you normally would.

To attach to a running process, perform these steps:

  1. In DevStudio, choose Build, Start Debug, Attach Process. If the process you need to connect to is a system process, select the Show System Processes option.
  2. Select the process from the list of running processes.
  3. In DevStudio, choose Build, Start Debug, Attach Process.
  4. If the process you need to connect to is a system process, select the Show System Processes option.
  5. Choose a running process from the Processes list. This list displays all processes currently running on the local machine that can be debugged.
  6. Select a process by highlighting it and clicking OK, or by double-clicking the process.
  7. To detach from a running process, choose Stop Debugging from the Debug menu.

No project or file has to be open to run the Attach to Process tool. Notice the Show Sys tem Processes check box in the window. Checking this box will do exactly what it says.

The Attach to Process dialog box displays three fields: Process, Process ID, and Title (of the process). Clicking on the column names sorts the fields by the chosen field. Clicking and holding on a field separator expands the field for ease of reading.

Note that you must close and reopen the Process dialog box in order to refresh the list.

Using Dr. Watson Logs

Dr. Watson is a tool that helps diagnose system faults. It takes a snapshot of your system when a system fault occurs. Dr. Watson intercepts the software fault(s), identifies the software that faulted, and offers a detailed description of the cause (sometimes). Sometimes Dr. Watson can diagnose the problem complete with a solution. This is the tool used by Microsoft Technical Support to evaluate system problems.

The Dr. Watson application is not loaded by default. To start Dr. Watson automatically on Startup, create a shortcut and place it in the Startup group. The application executable is located at \Windows\DrWatson.exe.

Running Dr. Watson

Double-clicking on the Dr. Watson executable starts Dr. Watson. It then runs in the background and generates a DRWATSON.LOG file in the Windows directory. Dr. Watson monitors window activity and stores it in a log file. This file will contain any important information about any errors that occurred in a Windows session.

The Dr. Watson log file is an appending list of errors that have occurred in Windows. Thus, the file could possibly contain information from the following:

Given this information, it probably is best to rename the log file before starting to debug the application. This ensures that the file contains information resulting from the application alone.

A program that will be run while Dr. Watson is running in the background follows. The program will crash when it tries to divide two numbers by zero. The Dr. Watson log file has been deleted so that it can create a new one.

//Dr. Watson Example
//
//Divide By Zero
//

#include <iostream>

void main ()
{
int x = 0;
int y = 0;
int z = 0;
x = 10;
y = 0;
z = x / y;

}  //End

When the program is run, it crashes as expected. Opening the log file, the results indicate a division by zero was attempted.

Definitely the most useful part of the log file is the stack dump section. This section helps you determine the sequence of functions called and which function caused the General Protection Fault. Dr Watson also shows the exact assembler instruction where the failure occurred and indicates the module information as well.

Share ThisShare This

Informit Network