如何制作“调用堆栈图”

发布于 2024-07-16 21:53:03 字数 230 浏览 4 评论 0原文

创建调用堆栈图

我们最近刚刚投入一个大项目,需要我们深入了解代码(废话)。

我们使用不同的方法来熟悉它,断点等。但是我们发现一种方法是制作应用程序的调用树,最简单/最快的方法是什么?

通过代码? 插件? 手动?

该项目是一个 C# Windows 应用程序。

Creating a call stack diagram

We have just recently been thrown into a big project that requires us to get into the code (duh).

We are using different methods to get acquainted with it, breakpoints etc. However we found that one method is to make a call tree of the application, what is the easiest /fastest way to do this?

By code? Plugins? Manually?

The project is a C# Windows application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

盛夏已如深秋| 2024-07-23 21:53:03

使用静态分析器NDepend,您可以获得静态方法< a href="http://www.ndepend.com/Doc_VS_Arch.aspx" rel="nofollow noreferrer">调用图,如下所示。 免责声明:我是该工具的开发人员之一

Call graph

为此,您只需要将 CQLinq 代码查询的结果导出到图表

代码查询导出

这样的代码查询,实际上可以为任何方法生成,这要归功于下图所示的右键菜单。

选择直接或间接使用我的方法

With the static analyzer NDepend, you can obtain a static method call graph, like the one below. Disclaimer: I am one of the developers of the tool

Call graph

For that you just need to export to the graph the result of a CQLinq code query:

code query exporting

Such a code query, can be generated actually for any method, thanks to the right-click menu illustrated below.

Select methods that use me directly or indirectly

恋你朝朝暮暮 2024-07-23 21:53:03

每当我开始一项新工作(这通常是因为我是承包商)时,我会花两到三天的时间阅读存储库中的每个源文件,并在一个简单的文本文件中针对每个类进行注释。 这是相当费力的,但这意味着您可以很好地了解项目如何组合在一起,并且当您需要找到执行某些操作的类时,您有一个可靠的地图。

尽管我在开始项目时喜欢 UML/图表,但我个人认为在检查现有代码时它们一点用处都没有。

Whenever I start a new job (which is frequently as I am a contractor) I spend two to three days reading through every single source file in the repository, and keep notes against each class in a simple text file. It is quite laborious but it means that you get a really good idea how the project fits together and you have a trusty map when you need to find the class that does somethnig.

Altought I love UML/diagramming when starting a project I, personally, do not find them at all useful when examining existing code.

素食主义者 2024-07-23 21:53:03

不是对您问题的直接答案,但 NDepend 是一个获得 100 英尺视图的好工具代码库,它使您能够深入了解类(以及许多其他功能)之间的关系

Not a direct answer to your question, but NDepend is a good tool to get a 100ft view of a codebase, and it enables you to drill down into the relationships between classes (and many other features)

高跟鞋的旋律 2024-07-23 21:53:03

编辑:我相信微软的CLR Profiler 能够显示正在运行的应用程序的调用树。 如果这还不够,我已经留下了下面发布的链接,以防您想开始定制解决方案。


这是一篇 CodeProject 文章,可能会为您指明正确的方向:

此处提供的下载是视觉效果
Studio 2008 C# 项目的简单
列出用户函数调用的实用程序
C# 代码中的树。

这个调用树列表器似乎工作正常
对于我的编码风格,但会
对于其他一些人来说可能不可靠
编码风格。 这里提供
有两个想法:首先,一些
程序员可能会发现它很有用;
其次,如果
熟悉 C# 的人
解析将通过以下方式升级它
合并准确的 C# 解析器
并产生一个改进的实用程序
无论编码风格如何,都是可靠的

的 源代码可供下载 - 也许您可以使用它作为自定义解决方案的起点。

Edit: I believe the Microsoft's CLR Profiler is capable of displaying a call tree for a running application. If that is not sufficient I have left the link I posted below in case you would like to start on a custom solution.


Here is a CodeProject article that might point you in the right direction:

The download offered here is a Visual
Studio 2008 C# project for a simple
utility to list user function call
trees in C# code.

This call tree lister seems to work OK
for my style of coding, but will
likely be unreliable for some other
styles of coding. It is offered here
with two thoughts: first, some
programmers may find it useful as is;
second, I would be appreciative if
someone who is up-to-speed on C#
parsing would upgrade it by
incorporating an accurate C# parser
and turn out an improved utility that
is reliable regardless of coding style

The source code is available for download - perhaps you can use this as a starting point for a custom solution.

断爱 2024-07-23 21:53:03

不是要成为卡住的记录,而是如果我让它运行并暂停几次,并且每次捕获调用堆栈,这都会让我真正清楚地了解占用最多时间的调用结构。 然而,它并没有为我提供快速发生的事情的调用结构。

Not to be a stuck record, but if I get it running and pause it a few times, and each time capture the call stack, that gives me a real good picture of the call structure that accounts for the most time. It doesn't give me the call structure for things that happen real fast, however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文