Tutorial: Debugging OLE Client-Server CombinationsLast reviewed: July 22, 1997Article ID: Q117558 |
1.50
WINDOWS
kbtool
The information in this article applies to:
SUMMARYWhen building object linking and embedding (OLE) servers, you may want to debug them in the context of being activated by an OLE container or to debug both the container and the server at the same time. The "Tutorial" in the "MORE INFORMATION" section, below, shows you how to debug and set breakpoints in an OLE server when the main debuggee is an OLE container. Because Windows NT does not allow hard-mode debugging, and because you cannot run CodeView under Windows NT, you cannot perform simultaneous OLE client-server debugging using Visual C++, version 1.5, on Windows NT. However, you can still debug clients and servers under Windows NT as single applications on a standalone basis using the integrated debugger.
MORE INFORMATIONThis tutorial guides you through a simple debugging session using the samples that come with Visual C++:
Tutorial
the "OK" button. At this point, the debugger should have stopped at your breakpoint in the SCRIBBLE.CPP file. You can now debug the SCRIBBLE server. NOTE: We could have set the breakpoint anywhere, including within the SCRIBBLE class constructors.11.Press F5 again. The SCRIBBLE server continues its initialization, and then control returns to CONTAIN.EXE. The debugger should stop at the breakpoint in the CONTRVW.CPP file.12.Step through CONTRVW’s code, using F8 to see the embedded SCRIBBLE object become active.13.Press F5 to continue running the SCRIBBLE.EXE file, activated in place within the CONTAIN.EXE file. If you do not readily see CONTAIN.EXE on your screen, you may need to switch focus to CONTAIN.EXE manually. You can also arrange Visual C++ and CONTAIN.EXE so that their windows do not overlap.14.Close the CONTAIN.EXE file. When debugging OLE clients and servers simultaneously, remember that if both the client and the server(s) were statically linked using the MFC libraries, there will be at least two copies of MFC code in memory (perhaps more if you have nested embedded objects supplied by different servers). Therefore, if you set a breakpoint in MFC library code through its sources in \MSVC\MFC\SRC, you may get unexpected behavior. For example, if you set a breakpoint within AfxOleInit() in file \MSVC\MFC\SRC\OLEINIT.CPP, the debugger may not be able to tell whether you want to break at the breakpoint under the following conditions:
To tell the debugger where you want it to break, you must use the context operator to specify in which module the breakpoint should be set. For the AfxOleInit example just mentioned, you could use the following expression to set the breakpoint in the server:
{,oleinit.cpp,server.exe} AfxOleInitThis expression names the source file and module (in memory) where the debugger inserts the int 3 that sets the breakpoint. If the Integrated Development Environment (IDE) debugger is used, you need to type this expression into the Location field in the dialog box you get from choosing Breakpoints from the Debug menu. (The above breakpoint has AfxOleInit as the location, which causes a break on the opening brace of AfxOleInit. A line number can just as well be used in this case.) If Codeview is used, type the expression into the Location field in the dialog box you get from choosing Breakpoints from the Data menu. 15.Set a breakpoint at AfxOleInit in the SCRIBBLE server as described above. 16.Restart the CONTAIN.EXE file and observe that this breakpoint is only hit when the SCRIBBLE.EXE file calls AfxOleInit, not when CONTAIN.EXE calls AfxOleInit. As an alternative, CodeView for Windows allows you to differentiate between multiple module copies by choosing Open Module from the File menu. Use this command to select in which module you want to set the breakpoint (CodeView lists all copies of each of the MFC modules in memory). The Visual C++ IDE debugger is somewhat limited in its ability to handle complex debugging sessions, such as containers calling multiple servers. If you find you are experiencing problems, try using CodeView instead. If you want to use CodeView for Windows as the debugger, load debugging information for your servers and/or DLLs by running the following command (without quotes) from the Program Manager or by choosing Run from the File Manager File menu:
"CVW <options, if any> [/Loleserver.exe] oleclient.exe"The square brackets indicate that the enclosed parameter can be specified 0 or more times, allowing you to load (/L) symbolic information for several servers or DLLs (or both). Unless the OLE client, server(s), and DLLs reside in the current directory (or in the directories listed in the PATH environment or in the Windows directories), the full path to these files is needed on the command line above this command.
REFERENCESFor more information, please read the "Debugging OLE Applications" section (pages 136 to 141) in the "Visual C++, version 1.5, OLE 2.0 Classes" manual. For more detailed information on the syntax and use of the context operator, please refer to chapter 4 of the "Codeview Debugger User's Guide". In addition, Visual C++, version 1.5, supplies a variety of utilities in the OLE 2.01 Toolkit. These are designed to help you test and debug your OLE applications. For more information on these tools, please refer to the "Tools" section of the OLE 2.01 Toolkit Release Notes (open the icon in the Toolkit program group).
|
Additional reference words: kbinf 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |