Microsoft SDK for Java

Registering with the Debugger Manager

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

  1. Call the COM library function CoCreateInstance or CoCreateInstanceEx.

  2. Pass in CLSID_RemoteJavaDebugManager, which is the class identifier (CLSID) of the debug manager.

  3. Pass in IID_IRemoteDebugManager, which is the interface identifier (IID) of the IRemoteDebugManager interface.

    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();
    
  4. Register with the Microsoft VM's debugger manager, passing in its callback interface pointer, through which the VM will communicate with the debugger.

    The debugger implements COM interfaces that receive callback notifications from the VM.

  5. Call the RegisterCallback method on this interface to register for Java process startup notification.

  6. Call RequestCreateEvent to request being informed when a Microsoft VM starts a new Java process.

    Use the RequestCreateEvent method to achieve any of the following results:

  7. Obtain an IJavaEnumRemoteProcess enumerator for the active Java processes by calling GetActiveProcesses.

    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.

  8. Debug a specific process using IRemoteProcess to register a callback to receive notifications and information from the Microsoft VM regarding that process.

    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.

© 1999 Microsoft Corporation. All rights reserved. Terms of use.