Reputation: 2062
typically I set a breakpoint in my Java application when I want to observe the run.
However sometimes I just want to know if a method is called or not. Therefore a breakpoint does not help me, and I insert a "systrace" statement
System.out.println("method signature");
I thought it would be a nice feature If I could set a breakpoint and when the breakpoint is reached to just print out the systrace message and continue the run.
Do you know if this is possible?
Upvotes: 10
Views: 3048
Reputation: 721
You have to make it a conditional breakpoint with a following condition:
System.out.printf(Thread.currentThread().getStackTrace()[1].getMethodName() + "\n") == null
Works fine in my Eclipse. I'm using printf to make printing code evaluate to boolean. Not sure if there's a way to automate inserting this code into a breakpoint.
Upvotes: 15