2

I have a breakpoint that has some logic attached to it that I want to skip if the method it was in was invoked from JDI.

i.e. in the client jvm

foo.barr();

should cause the code associated with the breakpoint to be run but

fooReference.invoke(thread,barrMethod,params,0); 

in the debugger jvm should result in the logic being skipped and the code resumed.

I have two questions:

How does a jdi method invocation appear on the client JVM's java call stack?

If it's not possible to detect an invoke using the call stack is there another method that could be used?

ILOVEPIE
  • 177
  • 1
  • 10
  • How much cooperation can you expect from the called code and the debugging code? I assume passing an extra boolean parameter is not an option. – biziclop Nov 03 '14 at 18:11
  • you are correct there's no cooperation between the called code and the debugging code. I can't add a boolean to the method. Edit: well i could forcibly add a boolean parameter but it would break the code i'm debugging. – ILOVEPIE Nov 03 '14 at 18:13
  • You certainly can't tell from the call stack, as the call stack will be exactly where the thread is suspended. Which means you can look at the stack and not run the method if the caller isn't one of the locations you expect your method to be called from. But if someone stops the thread on the exact line where a method call will normally occur and then uses JDI to simulate the call, there's no way to tell. – biziclop Nov 03 '14 at 18:27
  • I believe there is no way to check how method was called due to JDWP/JDI aren't forcing any details of implementation. But you can turn breakpoint off before JDI invoke and turn it back on after. – Stanislav Lukyanov Nov 03 '14 at 23:02

0 Answers0