locked
Switch between Debug engines RRS feed

  • Question

  • Hi,

    I wrote a custom debug engine that supposed to debug JIT code being generated during run-time on a x86 host application.

    The JIT code is running on a runtime environment that being loaded by the host application. my custom debug engine communicate with the runtime environment through inter-process communication method.

    I would like to use the default "x86" debug engine of MS in order to debug the C/C++ host application, but when I'm reaching the point where the JIT code starting to run, I would like to switch to my custom debug engine (under the same process) and switch back to the default debug engine once the JIT execution ends.

    I guess that if I run the JIT code under a different process, such switching is possible. but than I'll have to change my run-time environment.

    I was wondering if there is another way do to it, meaning, using the same windows process, but switching between debug engines?

    Thanks,

    Uri


    Uri Levy
    Sunday, May 30, 2010 11:45 AM

All replies

  • Hi Uri,

    Thanks for using MSDN forum.

    If my understanding is correct, you want to debug an application with two debuggers. One is inter-process of debuggee engine and the other is inter-process of SDM engine. Please correct me if I am wrong.

    I never tried that before, but Visual Studio debugger supports multiple debug engines in a single process. You requirement should be supported. I am not sure if SDM can support to switch engines in different contexts.

    Can you let me know what happens if you start debugging the applications with both engines? Thanks.

     


    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    See what's happening in MSDN forum? Follow us at Twitter.
    Tuesday, June 1, 2010 6:52 AM
  •  

    Hi,

    Let me clarify my problem:

    I'm trying to activate my DE after the process was launched (through the default debug engine) using IVsDebugger2.LaunchDebugTargets2.

    The VsDebugTargetInfo2 structure contains the following information:

    VsDebugTargetInfo2 inf = new VsDebugTargetInfo2();
    inf.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(inf);
    inf.bstrArg = null;
    inf.bstrCurDir = null;
    inf.bstrEnv = null;
    inf.bstrOptions = null;
    inf.bstrRemoteMachine = null;
    inf.dlo = (uint)Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
    inf.dwDebugEngineCount = 1;
    inf.guidLaunchDebugEngine = Guid.Empty;
    inf.dwProcessId = (uint)procid;
    inf.bstrExe = '\0' + "0x" + procid.ToString("X"); 
    inf.dwReserved = 0;
    inf.fSendToOutputWindow = 0;
    inf.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_WaitForAttachComplete; IntPtr guidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(deGuid));
        
    Marshal.StructureToPtr(deGuid, guidPtr, false);
    inf.pDebugEngines = guidPtr;

    where procid is the process id to which my DE should attached, and deguid is the Guid of me DE.

    I wrote a VS package that "catch" the point where I want to start using my DE, and than calling to LaunchDebugTargets2:

    IVsDebugger2 debugger = GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger2;
    err = debugger.LaunchDebugTargets2(1, pInfo);

    I keep getting error return value (0x89710080).

    when calling to IVsUIShell.GetErrorInfo I'm getting the following error message:

    "Unable to attach. An attempt was made to perform an initialization operation when initialization has already been completed "

    Thanks,

    Uri

     

     


    Uri Levy
    Wednesday, June 2, 2010 1:10 PM