delphistack-tracecallstackmadexceptjedi-code-library

Need a way to periodically log the call stack/stack trace for EVERY method/procedure/function called


I'm working on a very large application where periodically I'd like to log the ENTIRE call stack up until the current execution point (not on an exception). The idea here is that I want a map of the exact code path that led me to the point that I am. I have been working with madExcept, tooled around with jclDebug and while I can get some of the call stack, I can't seem to get EVERY method/procedure/function call that is made in the application to show up in the log.

I've got stack frames turned on, debug info, etc enabled on the project. I even tried turning on stack frames on individual methods that weren't getting included in the call stack to no avail.

Is what I'm trying to do even possible? I'm really trying to avoid having to add logging code all over our millions of lines of code in order to log the code path.


Solution

  • When you return from a method it is removed from the stack. So presumably your Partial call stack is every method that has not yet returned?

    e.g.

    DoSomething
    begin
        MiniSubMethod
        DomeSomethingMore
        begin
            InnerDoSomething
            begin
                ShowCallStack
            end
        end
    end
    

    I would think in this situation the call stack would be

    InnerDoSomething  
    DoSomethingMore  
    DoSomething  
    

    MiniSubMethod is no longer on the stack as it returned before DoSomethingMore was called.

    I think FastMM4 includes a Stack Trace so you could try that.

    You would definitely need some kind of logging/stack trace instead of just the call stack.