Options

Code Window : click on method

LexiconLexicon Posts: 76 Bronze 3
Hi,

in the code window the ability to click on a method name and jump to the correct point in code is broken.
 Public Shared Function NewQuestions(ByVal filename As String) As jazzQuestions
        If filename = "" Then Return New jazzQuestions
        If IO.File.Exists(filename) Then
            Return New jazzQuestions(filename)
        Else
            Return New jazzQuestions()
        End If
    End Function


first problem is that in the above example, there is only a hyperlink on the method New JazzQuestions(filename), there should also be one on New JazzQuestions()

second problem, when I click on the hyperlink over JazzQuestions(filename), it takes me to line 13 which is just a class level declaration of a private variable, the actual method is some 1400 lines later.
Paul.

Comments

  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Hi Paul,


    Thanks for getting in touch. ANTS Profiler will only provide click navigation in the source code view for methods that were executed. This is because to provide click navigation for all methods would require a complete model of the code being executed, which we don't construct since it would impede performance and increase the profiler overhead.

    I suspect therefore, the reason that you're not seeing a hyperlink for the no-args constructor is that it wasn't executed in the NewQuestions method. As for why it's taking you to line 13, I suspect this is because this probably was the first line of code that was executed during that constructor call. Static variables are initialised the first time a class is used, so I'm assuming this is what happened here. Similarly, member variables that are initialised outside of a constructor are also collapsed into the constructor call for execution purposes (note the way the VS debugger steps through these initialisations before stepping into a constructor body).

    Obviously this isn't made entirely clear, however it's difficult to determine what the correct behaviour should be since a class or instance level initialisation outside of a constructor could be very expensive. Also, I suspect the lack of a complete code model may possibly limit what we can do here.

    At any rate I'll add this to the list of things we can look into improving. Hope that's useful information.


    Thanks,
    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
  • Options
    LexiconLexicon Posts: 76 Bronze 3
    Hi Bart,

    thanks for the feedback, in fact the method was executed, and was identified as a problem area.

    It would seem it is related to something a little strange

    in the call tree I have an entry

    Integra.jazzQuestions..ctor(string filename)

    it is when I click on this method in the call tree that it takes me to the variable list.

    Where things are a little outside the box is that I do not have a public constructor on the class, rather two private methods that get called by the shared function NewQuestions, due to the nature of the class. This would explain the behavior of the call tree click, but it would not explain the faulty hyperlink inside the method.

    If it makes more sense I can set up a tech session or camtasia video file to show what is happening.

    The quick answer to the question is really, do you parse the source code and provide links, or do you base it from the executed code ?

    if it is the latter, then I do not see a clear solution.
    Paul.
  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Hi Paul,


    Thanks for the offer of setting up a remote session; it might well prove useful. Let me have a chat to Stephen about it and we'll see if we can sort it out. Andrew, who wrote the click navigation, is away today so I'll ask him about this when he's back in the office.

    The answer as to how we do it is a bit of both. Our source code view provides us with an AST for the currently loaded source file (for both C# and VB at any rate). From this we can grab all the methods, and for each method the execution info. We then try to stitch the execution info together with the code in the method based on method names, class names etc., but because we don't have a full code model for the profiled application this isn't 100% accurate. The problem is that without full type information for everything, any matching we do is necessarily going to be a bit on the fuzzy side.

    It could be that there's just a problem resolving the target because there are two calls to a method with the same name, however that would be surprising because the parameter counts are different, and in any case the method calls would appear at different IL offsets, which would map to different lines in the source file. When you click on the version that takes a string, do you get a popup appearing with two different methods on it, or does it just take you straight to the source code?


    Thanks,


    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
  • Options
    LexiconLexicon Posts: 76 Bronze 3
    Hi Bart,

    http://www.usher.net.au/redgate/ants_code_link_issue/ants_code_link_issue.htm

    The above link show a short video of the problem with two examples, you will see from it that there are no popups.

    let me know if I can provide more information.
    Paul.
  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Hi Paul,


    Thanks for this! That's certainly helped. Here's what I think is going on:

    1) Here you click on NewQuestions and inspect the line level timings.

    You can navigate to jazzQuestions(filename), but not jazzQuestions(), but if you look in the source code view, you can see that jazzQuestions() has no hit count, and no line level timing. This suggests that either it has never been executed, or that it was not profiled because it falls into the category of trivial functions. Even if the latter were the case I'd still expect to see a line level timing for it, unless it was executed only once, or only once within each 250ms data chunk collected by the profiler. You can verify whether or not this is the case by going to Tools > Options, and unchecking "Avoid profiling extremely trivial functions", but be warned, this will increase the amount of memory the profiler uses, so I'd turn it off again later. If you find that timing information is included for this line, and hopefully you'll then be able to navigate to jazzQuestions(), then it's being excluded, otherwise it's not being executed. EDIT: I've just rewatched this and noticed that the hit count for the 'IF filename = ""' statement on line 429 is only 1, so NewQuestions is only being executed once, which means that jazzQuestions() definitely isn't being executed.

    Now, clicking on jazzQuestions(filename) takes you to the first member variable initialisation, and not the constructor itself. This is because we don't have a proper model of the code, but we do know what's executed, and using the PDB file we can map back onto the source code. Since these initialisations are executed as part of the jazzQuestions(filename) call (note the presence of line level timings), and in fact are executed before the body of this call, you are taken to the first member variable initialisation. The same applies when you click on the constructor in the tree view.

    2) Clicking on the constructor for the Question class.

    Again, the same thing applies with member variable initialisations. It's a little odd, but these are executed before the body of the constructor, and effectively form part of the constructor call. You'd see this clearly if you stepped through the code with a debugger.

    Hope that clears everything up, and thanks for posting the video: it made it much easier for me to see what was happening. If you need anything else, let me know.


    Thanks,


    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
Sign In or Register to comment.