如何生成Java调用图 [英] How to generate a Java call graph
问题描述
我想分析和理解一个Java应用程序,我认为一个调用图将是非常有用的。如何生成一个?我正在使用Eclipse。
获取callstack
1)如果您可以调试,应用程序只需放置一个断点(双击代码的左边距),并等待停止。如果您不在那里,请转到调试透视图,并打开调用堆栈视图/面板。它有调用堆栈:)
2)如果要在某处打印此堆栈跟踪,请使用例外:
异常aux = new异常(我在这里); //不要投掷!
aux.printStackTrace(); //如果你想要在stdout
或
异常aux = new异常(我在这里); //不要投掷!
StringWriter sw = new StringWriter();
aux.printStackTrace(new PrintWriter(sw));
String result = sw.toString(); //如果你想要一个字符串
获取方法参考
您可以通过右键单击引用,工作区来获取对方法的所有引用。它将搜索您当前打开的项目中的所有调用。非常非常有用。
剖析应用
profiler选项)
Eclipse TPTP提供概要分析:
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. Getting callstack 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) If you want to print this stack trace somewhere use an Exception: or Obtaining method references 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. Profiling an app (thanks those who had answered the profiler option) Eclipse TPTP provides profiling: http://www.eclipse.org/tptp/home/project_info/general/whatisTPTP.php 这篇关于如何生成Java调用图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!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