问题描述
限时送ChatGPT账号..我想分析和理解某个 Java 应用程序,我认为调用图会非常有用.我如何生成一个?我正在使用 Eclipse.
I'd like to analyze and understand a certain Java app and I think a call graph would be very useful. How do I generate one? I'm using Eclipse.
推荐答案
获取调用堆栈
1) 如果您可以调试,应用程序只需放置一个断点(双击代码的左边距)并等待它停止.如果您不在那里,请转到 Debug Perspective,然后打开 Call stack View/Panel.它有调用堆栈:)
1) If you can debug the application simply put a breakpoint (double click over the left margin of the code) and wait it to stop. Go to Debug Perspective if you're not there, and open the Call stack View/Panel. It has the call stack :)
2) 如果您想在某处打印此堆栈跟踪,请使用异常:
2) If you want to print this stack trace somewhere use an Exception:
Exception aux = new Exception("I'm here"); // not for throwing!
aux.printStackTrace(); // if you want it in stdout
或
Exception aux = new Exception("I'm here"); // not for throwing!
StringWriter sw = new StringWriter();
aux.printStackTrace(new PrintWriter(sw));
String result = sw.toString(); // if you want it in a string
获取方法引用
您可以通过右键单击引用"、工作区"来获取对方法的所有引用.它将搜索您当前打开的项目中的所有调用.非常非常有用.
You can obtain all references to a method by right-clicking, References, Workspace. It will search all callings in your current open projects. Very very useful.
分析应用
(感谢回答分析器选项的人)
(thanks those who had answered the profiler option)
Eclipse TPTP 提供分析:
Eclipse TPTP provides profiling:
http://www.eclipse/tptp/home/project_info/general/whatisTPTP.php
这篇关于如何生成 Java 调用图,基于 Eclipse 的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论