BUG: Can't Debug LibMain with VC++ Debugger

Last reviewed: July 22, 1997
Article ID: Q104240
1.00 1.50 WINDOWS kbtool kbbuglist

The information in this article applies to:

  • The Microsoft Visual Workbench included with: Microsoft Visual C++ for Windows, versions 1.0 and 1.5

SYMPTOMS

When debugging a Windows dynamic-linked library (DLL) with the Visual Workbench debugger, the debugger will not step into LibMain. The Visual C++ (VC++) debugger also ignores any breakpoint inside LibMain.

RESOLUTION

A possible workaround is to add an interrupt 3 call to force the debugger to break inside LibMain, and then begin debugging from the interrupt 3 call. The code would resemble the following:

   _asm int 3

The debugger stops at the statement. It is important to perform a "restart" of the debugger each time after the program is executed. The restart forces the debugger to reload the libraries when you begin debugging. Reloading the libraries causes LibMain() to be called.

An alternative workaround is to use CodeView for Windows. CodeView performs correctly when breakpoints are set in LibMain.

STATUS

Microsoft has confirmed this to be a problem in the Visual Workbench debugger in Visual C++ for Windows version 1.0. This problem does not occur if the DLL is loaded dynamically at run time using the Windows function LoadLibrary(). This problem also does not occur in Visual C++ 32-bit edition.

MORE INFORMATION

To reproduce the problem, you can set a breakpoint in the SELECT.C sample program included in Visual C++. In VC++ 1.0 for Windows, this sample is located in C:\MSVC\SAMPLES\SELECT.


Additional reference words: 1.00 1.50
KBCategory: kbtool kbbuglist
KBSubcategory: VWBIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.