I have a Java program (jar file) and I wish to print out all the methods called during the execution of that program. So if Class1.main()
calls Class1.foo1()
, initiates Class2, calls Class2.foo2()
and Class2.foo3()
, then I want the output to be something similar to
called Class1.main
called Class1.foo1()
called Class2.<init>
called Class2.foo2()
called Class2.foo3()
Please note that I do not wish to see the active stack trace, e.g the method that's currently active and the methods which led to the call of that method, since it would not print out those methods that aren't related to the call of that method. I wish to see all the methods called during the execution of the program, in the order they're called in.
The answer may take advantage of any technique, though I expect it to use some sort of debugging program, like jdb. The reason for this is because I have already tried to use instrumentation with Javassist (described in my answer to this question) and ran into errors when trying it with more complex programs.