如何制作“调用堆栈图”
创建调用堆栈图
我们最近刚刚投入一个大项目,需要我们深入了解代码(废话)。
我们使用不同的方法来熟悉它,断点等。但是我们发现一种方法是制作应用程序的调用树,最简单/最快的方法是什么?
通过代码? 插件? 手动?
该项目是一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用静态分析器NDepend,您可以获得静态方法< a href="http://www.ndepend.com/Doc_VS_Arch.aspx" rel="nofollow noreferrer">调用图,如下所示。 免责声明:我是该工具的开发人员之一
为此,您只需要将 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
For that you just need to export to the graph the result of a CQLinq code query:
Such a code query, can be generated actually for any method, thanks to the right-click menu illustrated below.
每当我开始一项新工作(这通常是因为我是承包商)时,我会花两到三天的时间阅读存储库中的每个源文件,并在一个简单的文本文件中针对每个类进行注释。 这是相当费力的,但这意味着您可以很好地了解项目如何组合在一起,并且当您需要找到执行某些操作的类时,您有一个可靠的地图。
尽管我在开始项目时喜欢 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.
不是对您问题的直接答案,但 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)
编辑:我相信微软的CLR Profiler 能够显示正在运行的应用程序的调用树。 如果这还不够,我已经留下了下面发布的链接,以防您想开始定制解决方案。
这是一篇 CodeProject 文章,可能会为您指明正确的方向:
的 源代码可供下载 - 也许您可以使用它作为自定义解决方案的起点。
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 source code is available for download - perhaps you can use this as a starting point for a custom solution.
你的意思是这样的: http:// /erik.doernenburg.com/2008/09/call-graph-visualization-with-aspectj-and-dot/
You mean something like this: http://erik.doernenburg.com/2008/09/call-graph-visualisation-with-aspectj-and-dot/
不是要成为卡住的记录,而是如果我让它运行并暂停几次,并且每次捕获调用堆栈,这都会让我真正清楚地了解占用最多时间的调用结构。 然而,它并没有为我提供快速发生的事情的调用结构。
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.