0

Someone was confused and thought this question was about a stack trace - I'm not asking about a stack trace, which is the call stack from a specific point in execution - I'm asking for the execution path, which necessarily includes the call stack from every method call in program execution synthesized into an arbitrary representation (usually a tree).

I'm wondering if there is an open source library that has tools for inspecting a method's execution path.

Ideally there would be some object constructed containing data regarding the execution path, like:

MyClass.myMethod() -> SomeClass.someMethod()
                   -> SomeClass.someMethod2()
                   -> OtherClass.otherMethod() -> FourthClass.fourMethod()

Where this is some sort of n-tree, or something. Ideally I'd have access to method names, parameter types, etc.

does anything like this exist? I expect I could build something like this with reflect, but I'd be happy if someone else already has.

  • By "execution path" you mean stack trace ? – Jean-François Savard Apr 20 '15 at 01:44
  • 1
    Nope. A stack trace is the call stack from a specific point in the execution path. An execution path is the entire thing. I.e. the call stack has different heights during program execution, and a stack trace only provides a segment of it from a single point. – user3015990 Apr 20 '15 at 01:50
  • @ElliotFrisch You might want to see user3015990's answer to my comment. – Jean-François Savard Apr 20 '15 at 01:52
  • Also the ideal implementation would wrap execution in some manner and record typed parameters, object references, and calls to increment/decrement reference counts to objects (assuming there's a reference counting model in place, doesn't have to be the GC, could be some other reference counting machinery for tracking how many references exist to a single object at a specific time) – user3015990 Apr 20 '15 at 01:55
  • Try a profiler? VisualVM might be one way to do it. – Elliott Frisch Apr 20 '15 at 01:56
  • As an additional note: in an abstract sense, a trace of a method's call stack is a pseudo-history of how the program's execution reached the method, not a pseudo-history of the execution that took place after the method was called. – user3015990 Apr 20 '15 at 01:58
  • @ElliottFrisch I thought about a profiler, but I'm wanting to leverage a library like above to build some components for a test library, and I'm not sure visualVM has an API that supports this – user3015990 Apr 20 '15 at 02:02
  • @user3015990 The only thing I've ever seen that *might* do what you're asking for is [Chronon](http://chrononsystems.com/) (it's like a dvr for Java) and **is** a commercial product. – Elliott Frisch Apr 20 '15 at 02:04
  • @ElliottFrisch I'll check it out - one of my current leads is the Eclipse AST library - although it's entirely static, it might provide sufficient information to build this tool providing that the static code is available to be parsed at runtime (in this specific case, it is! =)) – user3015990 Apr 20 '15 at 02:08
  • @ElliotFrisch Yea, Chronon certainly has the internals to solve this, whether it exposes APIs for them or not. – user3015990 Apr 20 '15 at 02:12

0 Answers0