Coffeehouse Thread

20 posts

Awesome, Debugger Canvas

Back to Forum: Coffeehouse
  • User profile image
    Maddus Mattus
  • User profile image
    CaRDiaK

    Wow dude, that's amazing! Thanks for sharing, wish I had Ultimate right now  Angel

    We can only see a short distance ahead, but we can see plenty there that needs to be done.
    Last modified
  • User profile image
    ZippyV

    , CaRDiaK wrote

    Wow dude, that's amazing! Thanks for sharing, wish I had Ultimate right now  Angel

    Which company is so crazy to give their employees VS Ultimate?

  • User profile image
    Maddus Mattus

    @ZippyV: mine Wink

    I do have to create architecture diagrams you know,..

    And I do a lot of debugging Wink

  • User profile image
    blowdart

    , ZippyV wrote

    *snip*

    Which company is so crazy to give their employees VS Ultimate?

    Mine. Oh. Wait. Umm I don't count do I?

  • User profile image
    Ian2

    Yay, BizSpark - I have ultimate - going to have a play now.

  • User profile image
    SteveRichter

    this is not very difficult to do. In a visual studio addin you code an DebuggerEvents.OnEnterBreakMode event handler.

                _debugEvents = _applicationObject.Events.DebuggerEvents;
                _debugEvents.OnEnterBreakMode +=
                new _dispDebuggerEvents_OnEnterBreakModeEventHandler(BreakHandler);
    

    Your addin creates a ToolWindow that hosts a WPF user control ( which in turn contains a Canvas ).

    The OnEnterBreakMode event handler accesses the Debugger.CurrentStackFrame from the DTE2 application object:

          var sf = _applicationObject.Debugger.CurrentStackFrame;
    

    From the StackFrame you get a collection of Expression from the Arguments and Locals collections:

          foreach (var item in sf.Locals)
          {
            if (item is EnvDTE.Expression)
            {
              var exprItem = item as EnvDTE.Expression;
            }
          }
    

    Hooking up to the code on the call stack I assume is done with Project Roslyn.

    Working with the values of the variables is a bit limited in my experience. The Expression object.Value property only returns the ToString( ) contents of an object and its members.

     

     

  • User profile image
    androidi

    @Maddus Mattus:

    That's awesome-sauce stuff. Imagine if you could have that with native code and you could drill the stack with source all the way to upper layers of win32/ntdll with up to date source (like MS would open some of the win32 source for debugging like they did for WinForms). I don't really see what MS would lose by doing that, the black hats probably have seen the leaked source codes already and don't need it to hack the OS.

  • User profile image
    magicalclick

    That's really nice, although I really need ultimate version? I only have pro.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    Maddus Mattus

    @androidi:

    I'm more of a managed kind of guy. I havent had my coming out as a C++ developer yet, maybe when I turn 45ish and ponder if .Net is really the way to go, maybe then I can come out of the closet. So I've no idea what it would be like to debug this in native Smiley

    All kidding aside, what would be the advantage of that? You kinda just want that stuff just to work? Why would you want to see it?

    @magicalclick:

    Think this is one of the features wich didnt make 2010, but will make 2011.

  • User profile image
    BitFlipper

    Most excellent. I get an MSDN subscription at work that includes VS Ultimate so I have some "research" to do now... Big Smile

    So does anyone know whether this will work with a mixed project, where I can currently step into unmanaged code from managed code? 

  • User profile image
    JoshRoss

    Can someone run visual studio as an administrator, on window 7, and confirm that the debugger canvas does not function?

    -Josh

  • User profile image
    BitFlipper

    Call stack...? Pfffft. So 2011...

  • User profile image
    10000001

    , ZippyV wrote

    *snip*

    Which company is so crazy to give their employees VS Ultimate?

    , blowdart wrote

    *snip*

    Mine. Oh. Wait. Umm I don't count do I?

    Not that we ever use it (No Java Wahahhhhhhhhhhaaahhahhhaahahhh.....), but:

    Generic Forum Image

    No Java, whahhhhhhhhhhhhhhhhhhhhhhaaaahhhhhhhhhhhhhhhhh.........................................


    Visual Studio would be super great if it had Java, and turned purple and looked and functioned exactly like Eclipse.

    All the really useful plugins that the bleeding edge web companies such as Adobe, Google, Zend and other companies release don't work in Visual Studio.

    The plugin ecosystem on Visual Studio vs. Eclipse is comparable to the plugin ecosystem on Internet Explorer vs. the plugin system on Firefox. Very few participate in the Microsoft dev IDE ecosystem.

  • User profile image
    10000001

    I actually hadn't opened it in months. I take back the copy the Eclipse purple comment I made.

    They already did that.

     Generic Forum Image

     

  • User profile image
    Maddus Mattus

    @JoshRoss: I run it as admin, no problems

  • User profile image
    BitFlipper

    , SteveRichter wrote

    this is not very difficult to do. In a visual studio addin you code an DebuggerEvents.OnEnterBreakMode event handler.

    1
    2
    3
    _debugEvents = _applicationObject.Events.DebuggerEvents;
    _debugEvents.OnEnterBreakMode +=
    new _dispDebuggerEvents_OnEnterBreakModeEventHandler(BreakHandler);

    Your addin creates a ToolWindow that hosts a WPF user control ( which in turn contains a Canvas ).

    The OnEnterBreakMode event handler accesses the Debugger.CurrentStackFrame from the DTE2 application object:

    1
    var sf = _applicationObject.Debugger.CurrentStackFrame;

    From the StackFrame you get a collection of Expression from the Arguments and Locals collections:

    1
    2
    3
    4
    5
    6
    7
    foreach (var item in sf.Locals)
    {
      if (item is EnvDTE.Expression)
      {
        var exprItem = item as EnvDTE.Expression;
      }
    }

    Hooking up to the code on the call stack I assume is done with Project Roslyn.

    Working with the values of the variables is a bit limited in my experience. The Expression object.Value property only returns the ToString( ) contents of an object and its members.

    So unfortunately as it turns out this only works with managed code. It does not look like this is an open source project either.

    Steve, do you think your technique above will also work with unmanaged code? And will it work in non-Ultimate versions?

    While the Debugger Canvas plugin is impressive, its feature set is actually quite limited (there are some bugs too - at some point I could no longer switch/close tabs anymore). I wonder how complex such a project would really be if done from scratch.

  • User profile image
    androidi

    @Maddus Mattus: There may be other advantages but I'm primarily interested in ways in which it could ease diagnosing app compat issues. Imagine if you were debugging some old dll without the source and didn't even see what OS apis it called - well just seeing those OS api calls gives many clues. Now if it's some broken behaviour, you have to digest the API doc and study error codes and such things - if you could just drill down the commented source, you'd have the documentation right there (as the source) rather than having to go back and forth reading the docs and studying error codes. I'd much rather just step through the source code than translate MSDN docs into code in my head first. This might also help malware analysis and understanding the logic of the API without hoping to find "Old new things" blog about it.

    Whether it would ease debugging in windbg for those scenarios where there might be a real OS bug, hard to say, as I try to avoid that since there's no source.

    Also - do above justify the cost of enabling that? If there were just positives then maybe, but there's also potential negatives - like even if there were disclaimers and color coded source for the opened API source, some people might look for opportunities to take dependencies on some particular behaviour which might change in future or find bugs and exploits. I can't really answer this.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.