Type visualizers and inheritance

Sysprogs forums Forums VisualGDB Type visualizers and inheritance

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #12138
    Otatiaro
    Participant

    Hello,

    I’m trying to create some type visualizers for our in house framework.

    The first one is Vector3D, which inherits from Vector<3>, and Vector<x> itself inherits from Matrix<x, 1>.

    I followed the tutorial but can’t get the filter to trigger on the “Opsy::Matrix::Vector3D” nor “Opsy::Matrix::Vector<” filters. The only one I managed to get a trigger of is “Opsy::Matrix::Matrix<“.

    I tried with and without namespaces, etc. No result. What is the problem here ?

    Thomas.

     

    #12139
    Otatiaro
    Participant

    Just tried natvis too … can’t get it to work on anything Vector3D, Vector or Matrix, doesn’t work.

    I managed to get a “This is a list” on my Opsy::Data::List<*> type though … but matrices and vectors are really why I want natvis / type visualizers.

    I’m starting to be really frustrated … under Eclipse / Atollic I know I can’t have these tools, VisualGDB claims it offers them, but I can’t use them in real world scenario, it’s really a shame, and there is absolutely NO DOCUMENTATION at all about using them except the tutorials that cover only the ultra basic scenario (no namespace, no inheritance, nothing, well, at least it is C++ and not C …).

    Thomas.

    #12142
    support
    Keymaster

    Hi,

    We are sorry about the inconvenience you are experiencing. We do actually provide a basic reference on the type visualizer-related API: http://visualgdb.com/SDK/reference and the documentation XML files are shipped with VisualGDB, so Visual Studio should automatically display the help for all common methods and types when you are viewing them via IntelliSense.

    Either way, we will try to help you pinpoint this by sharing some insight into how the filters work.

    VisualGDB uses two-step matching to find expression filters. First it checks if the expression type contains any of the triggers exported by the filters. Trigger matching is a simple case-sensitive substring search. I.e. masks like “Vector<*>” won’t work when entered in the triggers.

    The second step of the matching is calling the Probe() method so that the filter can check the expression against an arbitrary set of conditions (e.g. regular expressions). This step is easy to debug by placing a breakpoint inside your Probe() implementation and stepping through it to see why it is not succeeding.

    If you experience troubles with getting your filters loaded, the problem could happen in one of the 3 places:

    • Your filter is being filtered out due to triggers
    • Your filter’s Probe() method does not return a valid value
    • Your filter successfully attaches, but does not actually filter the expression correctly

    You can easily pinpoint the location of the problem by reducing the triggers to something trivial (or just an empty string to get triggered for every variable) and stepping through the Probe() method. Please also check the outer Visual Studio’s Output log for information on thrown exceptions. If your filter accidentally throws an exception during initialization, VisualGDB would simply skip using the filter.

    If this does not help, please let us know what you observe (i.e. which methods of your filter are called and what do you observe in VS) and we will help you sort it out.

    #12152
    Otatiaro
    Participant

    Hello,

    Ok I’ll give it a try, the empty string trick should be documented somewhere, documentation is really ultra basic on the SDK reference. So far I think I got filtered out by the triggers.

    Thomas.

    #12153
    Otatiaro
    Participant

    Ok we made some progress here !

    The probe method is not virtual, so I could not debug it, having an empty string in the TypeListBasedExpressionFilter constructor didn’t help much, so I implemented my own IExpressionFilter, but then I had to decompile the Record property (for the factory to work) to understand what it was doing. I ended up with:

    public class Vector3D : IExpressionFilter
    {
    public bool Probe(IExpression expr, IExpressionEvaluator evaluator, out int score)
    {
    var t = expr.Type;
    var v = expr.Value;
                score = 0;
    return false;
    }
    public IExpression Attach(IExpression expr, IExpressionEvaluator evaluator)
    {
    var type = expr.Type;
                return new StaticExpressionFilter(expr)
    {
    ValueOverride = new ExpressionValue.Custom("This is a vector"),
    };
    }
     public ExpressionFilterRecord Record => new ExpressionFilterRecord
    {
    Filter = this,
    Triggers = new List<string> {string.Empty}
    };
    }

    Then I could put a breakpoint on both probe and attach methods … I was surprised that the breakpoint in attach was triggered but the probe one never triggered, it seems it is not called.
    Anyway, in the attach method I was able to retrieve the type of the expression, guess what, it is “Opsy::Matrix::Vector3D : public Opsy::Matrix::Vector<3>”.
    And using this for the TypeListBasedExpressionFilter actually works (I get a trigger on the DoAttach breakpoint).

    But I’d like to understand why the probe method is never called, having my own implementation of IExpressionFilter could be good for specific scenarii.

    Thomas.

    • This reply was modified 7 years, 3 months ago by support. Reason: formatting
    #12155
    Otatiaro
    Participant

    Now that’s what I’m talking about !

    Attachments:
    You must be logged in to view attached files.
    #12161
    support
    Keymaster

    Hi,

    Thanks, this looks like our bug. VisualGDB should normally filter out the “: public …” part. We will investigate and fix it in one of the next builds (this will break compatibility with the current workaround though).

    Probe() doesn’t get called if only one visualizer matches the expression via triggers. This is done to reduce the overhead that Probe() might cause (by running extra gdb commands).

    #12168
    Otatiaro
    Participant

    Hello,

    Thanks for the insight about why Probe isn’t called (this should be documented somewhere, it is very helpful when you are developing your own visualizers).

    I managed to get pretty much all my classes to visualize correctly, including FIFOs, linked lists, matrices, etc. I do have some lockups when evaluating the default children sometimes, don’t know why.

    A co-worker asked if it was possible to display something else than just text (we are working with screens on some projects, being able to actually display the content of an image buffer would be extra awesome)?

    It is a VERY powerful tool, debugging e.g. a linked list without this can be very time consuming.

    #12179
    support
    Keymaster

    Hi,

    Thanks for your feedback, we will consider adding a new tutorial about troubleshooting the type visualizer issues.

    You can diagnose the lockups by checking the GDB Session window (enable the timing mode to see the time consumed by each command) or the diagnostic gdb logs (can be enabled via Advanced GDB Settings).

    Visual Studio supports custom expression viewers (e.g. see the VS HTML viewer) that are displayed when you click the magnifying glass icon on the expression. VisualGDB does not directly support this, however we could easily add one of the  2 options:

    • Let you export your implementation of the VS interfaces via your type visualizer
    • Extend our type visualizer API to support easy WPF-based custom viewers (this would count as a custom paid feature as it’s very specific and relatively complex).

    Let us know if you would like to proceed. If you would like to get a quote for extending the API, please contact us via the support form.

     

    #12189
    support
    Keymaster

    OK, we have fixed the expression type reporting in this build: http://sysprogs.com/files/tmp/VisualGDB-5.3.7.1748.msi

    It should automatically filter out the base class definition in all cases and only display the actual class name.

    #12191
    Otatiaro
    Participant

    Well if you offer me one paid option and one free option … can I have more info about “let you expert your implementation of the VS interfaces via your type visualizer” ? 😉

    This is not something critical, just it would be very nice to get the visual of what contains an image buffer.

    Thomas.

    PS : so I’ll have to modify my type visualizers accodringly when I switch to the next release. So that I won’t have to create a filter for each template parameter anymore, awesome, thanks.

    #12210
    Otatiaro
    Participant

    Hello,

    I confirm it is fixed on the new version. Thanks.

    Thomas.

     

    #12219
    support
    Keymaster

    Good to know it works.

    With the free option, VS supports custom viewers for watches via the GetCustomViewerList() method. We can easily modify the VisualGDB engine to return an array of DEBUG_CUSTOM_VIEWER structures provided directly by your visualizer. You would then need to figure out how to connect this with the VS internals and let VS load the actual visualizer.

    If you want us to figure this out instead and provide you with a simple WPF-based interface for custom viewers, we can do that for a small fee (please contact sales via the support form to get a quote).

     

    #12222
    Otatiaro
    Participant

    Hello,

    Adding the possibility to return custom viewer via the VisualGDB interface would be nice, I think I can figure out how to build the GUI when needed (it’s documented).

    And it’s a technology I can reuse on other projects too (not only VisualGDB) which is always nice.

    Thomas.

    #12238
    support
    Keymaster

    Hi,

    OK, please try this build: http://sysprogs.com/files/tmp/VisualGDB-5.3.7.1762.msi

    We have added a new field called VSPropertyObject to the ExpressionValue class. You can set it to your own implementation of IDebugProperty3. VisualGDB will forward calls to GetCustomViewerCount(), GetCustomViewerList(), CreateObjectID() and DestroyObjectID() to this object.

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.