- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
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:
- 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.
- Select the process from the list of running processes.
- 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.
- Choose a running process from the Processes list. This list displays all processes currently running on the local machine that can be debugged.
- Select a process by highlighting it and clicking OK, or by double-clicking the process.
- 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:
- Current session and application
- Previous execution of the application
- Errors from another application
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.
Profiling Your Application | Next Section

Account Sign In
View your cart