0

Given a Java or JavaScript program, after its execution, print out a sequence of calls. The calls are in invocation order. E.g.

main()
{  A();
}

A()
{  B();
   C();
}

Then the call trace should be:

main -> A() -> B() -> C()

Is there any tool that can profile and output this kind of information? It seems this is common a need for debugging or performance tuning.

I noticed that some profilers can do this, but I prefer a simpler/easy-to-use one.

Thanks!

JackWM
  • 10,085
  • 22
  • 65
  • 92

4 Answers4

2

An IDE will the job for you. For example, eclipse is a widely used IDE for java programming and if you using it, you can know the hierarchy of calls which lead to a call to specific method.

Try selecting a method, right click and select 'Open call Hieracrhy' or Ctrl+Alt+H. This is not the kind of profiler you might be looking, but will help you in knowing the call hierarchy.

Anuj Balan
  • 7,629
  • 23
  • 58
  • 92
1

In Java putting:

new Throwable().printStackTrace();

Will get you the trace upto the call.

JayabalanAaron
  • 360
  • 3
  • 13
0

If you want to trace a function in JavaScript, you can use the Developer Tools in Webkit browsers, or Firebug.

Or you can do this:

function A(){
    debugger;
    B();
    C();
}

Note: Java is not JavaScript.

enter image description here

Community
  • 1
  • 1
Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
0

Take a look at this question. Its similar to what you are looking for, "simpler/easy-to-use one"

Community
  • 1
  • 1
Rakesh
  • 4,264
  • 4
  • 32
  • 58