需要一种方法来定期记录调用的每个方法

需要一种方法来定期记录调用的每个方法

本文介绍了需要一种方法来定期记录调用的每个方法/过程/函数的调用堆栈/堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个非常大的应用程序,我想定期将整个调用堆栈记录到当前执行点(不是异常).这里的想法是,我想要一张精确代码路径的地图,它引导我走到现在的地步.我一直在使用 madExcept,使用 jclDebug 进行工具,虽然我可以获得一些调用堆栈,但我似乎无法获得应用程序中进行的每个方法/过程/函数调用以显示在日志中.

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.

推荐答案

当你从一个方法返回时,它会从堆栈中移除.那么想必你的 Partial 调用栈就是所有还没有返回的方法吧?

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?

例如

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 不再在堆栈中,因为它在调用 DoSomethingMore 之前返回.

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

我认为 FastMM4 包含一个堆栈跟踪,所以你可以尝试一下.

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.

这篇关于需要一种方法来定期记录调用的每个方法/过程/函数的调用堆栈/堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 19:58