To use the debugger interfaces, a debugger program must call specific methods of the registration interfaces implemented by the Microsoft VM. See the Registration Debugger Interfaces reference for details.
An application registers with the Microsoft VM
CLSID_IRemoteDebugManager, IID_IRemoteDebugManager, and the other debugger GUIDs are defined in the JavaDbg.h file that is installed in the Include directory of the SDK for Java. The JavaDbg.h include file also contains definitions of the debugger interfaces.
The following sample code illustrates how to obtain an IRemoteDebugManager interface pointer to start debugging.
#include <JavaDbg.h> // Initialize OLE on this thread. HRESULT hr = CoInitialize(NULL); if (SUCCEEDED(hr)) { IRemoteDebugManager *pirdm; // Create a RemoteJavaDebugManager to initiate debugging. hr = CoCreateInstance(CLSID_RemoteJavaDebugManager, NULL, CLSCTX_LOCAL_SERVERALL, IID_IRemoteDebugManager, (PVOID *)&pirdm); if (SUCCEEDED(hr)) { // Begin debugging. } // Uninitialize OLE on this thread when done. CoUninitialize();
The debugger implements COM interfaces that receive callback notifications from the VM.
Use the RequestCreateEvent method to achieve any of the following results:
Note If you are logged on to Microsoft® Windows NT® under the system account, GetActiveProcesses may not enumerate all debuggable Java service processes. This is a DCOM security configuration issue, and is addressed in Enumerating Debuggable Service Processes.
When a debugger has obtained an IRemoteProcess for an active Java process (either through enumeration or from receiving a ProcessCreateEvent method call), it can attach to and debug the Java process.
The following sample code illustrates registering to receive a ProcessCreateEvent when a particular Win32 process starts up the Microsoft VM.
// Request notification when the Microsoft VM starts up in Win32 process // dwProcessID. HRESULT hr = m_pirdm->RequestCreateEvent("", dwProcessID);
If the Java application, applet, or COM object was previously started using the Win32 CreateProcess function and was subsequently suspended, it can now be resumed.