locked
programatically display the callstack of a dump RRS feed

  • Question

  • Hello

    I have a dmp file and want to display the callstack with C#. In VS2005, I did something like

    System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.80.0", true);
    dte = (EnvDTE.DTE)System.Activator.CreateInstance(t, true);
    dte.MainWindow.Visible = true;
    dte.ExecuteCommand("File.OpenFile","crashdump.dmp");
    dte.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance", "");
    

    In VS2010, after adopting the correct ProgID, ExecuteCommand("ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance" doesn't work anymore. How can I involve the Debugger programatically such that I can see the callstack?

    best regards, Kusi

     

    • Moved by eryang Wednesday, May 11, 2011 3:44 AM (From:Visual Studio Debugger)
    Tuesday, May 10, 2011 1:01 PM

Answers

  • Yes, the item still exists, but in VS2010 it throws the COMException 'Command "ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance" is not available.' I found this solution on the web for vs2005, I'm not aware of any other commands. I also had a look in the Menu->Tools->Options->Keyboard for a list of commands with the keywords "debug" or "dump" but I'm not sure if any of these loads the dmp file.

    In VS2005, you HAD to call "step into new instance" in order to examine the callstack. In VS2010, you need to click on Actions->Debug with native only. There doesn't seem an exposed COM-call for this function?

    best regards

    Kusi

    Thursday, May 12, 2011 2:10 PM

All replies

  • Move to VS Extension forum for better support.
    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 11, 2011 3:43 AM
  • I would have to look into it tomorrow (the machine I am on right now doesn't have VS installed and I am going to bed soon), but it seems very odd that you are locating a debugger command of some random-ish context menu.  Wouldn't it be more logical to locate said command off the Debug menu?  Or just dispatch the command using the GUID/DWORD so you don't have to rely on say the ClassViewProject context menu having some random debugging command on it?

    Ryan

    Wednesday, May 11, 2011 6:04 AM
  • Well, the item still exists on the menu, what do you mean by 'doesn't work anymore'?  Is ExecuteCommand throwing any exceptions?

    Ryan

    Wednesday, May 11, 2011 5:59 PM
  • Yes, the item still exists, but in VS2010 it throws the COMException 'Command "ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance" is not available.' I found this solution on the web for vs2005, I'm not aware of any other commands. I also had a look in the Menu->Tools->Options->Keyboard for a list of commands with the keywords "debug" or "dump" but I'm not sure if any of these loads the dmp file.

    In VS2005, you HAD to call "step into new instance" in order to examine the callstack. In VS2010, you need to click on Actions->Debug with native only. There doesn't seem an exposed COM-call for this function?

    best regards

    Kusi

    Thursday, May 12, 2011 2:10 PM
  • I am guessing it is unavailable as 2010 has a load / process kind of behavior for solutions so it is likely that you call to File.Open returns but the solution is not ready to be fully interacted with yet.  You may want to try hooking into the solution events and seeing if the command is available say after the OnAfterSolutionLoad event fires.

    Ryan

    Thursday, May 12, 2011 3:03 PM
  • In this case you should take away the command "ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance" from  Menu->Tools->Options->Keyboard. Unfortunately, the benefit for me is too small to investigate further and invest more time in this matter. Thanks for helping anyways!

     

    best regards

    Markus

    Friday, May 13, 2011 2:08 PM
  • No, the command itself is still valid your code just needs to know when it is proper to invoke it, a command not being available is not unexpected. For instance Close Solution is not available if there is no solution open.

    Ryan

    Friday, May 13, 2011 2:16 PM
  • Do you know by any chance WHEN "ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance" is proper to invoke?

    What I'm doing now: I programmatically open the dump with "File.OpenFile", then I manually click "Debug with Native Only" in the "Actions" Panel. Does somebody know the command for "Debug with Native Only"?

    best regards Kusi

    Monday, May 16, 2011 8:18 AM
  • I *think* this might work (though you will have to try it out).

    DTE2 dte = (DTE2)GetService(typeof(SDTE));
    Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte;
    
    IntPtr rawPtr;
    Guid iid = typeof(IOleCommandTarget).GUID;
    ErrorHandler.ThrowOnFailure(sp.QueryService(typeof(SUIHostCommandDispatcher).GUID, ref iid, out rawPtr));
    try
    {
      IOleCommandTarget cmdTarget = (IOleCommandTarget)Marshal.GetObjectForIUnknown(rawPtr);
      Guid razorGuid = new Guid("5289D302-2432-4761-8C45-051C64BD00C4");
      const int cmdIdRazorDmpSummaryPageDebugWithNativeEngine = 0x00000500;
      //const int cmdIdRazorDmpSummaryPageDebugWithInteropEngine = 0x00000501;
    
      cmdTarget.Exec(ref razorGuid, cmdIdRazorDmpSummaryPageDebugWithNativeEngine, (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero);
    }
    finally
    {
      Marshal.Release(rawPtr);
    }
    

     Ryan

    Wednesday, May 18, 2011 11:59 PM