2

According to the documentation, I have to use

jvmtiError
SetBreakpoint(jvmtiEnv* env,
            jmethodID method,
            jlocation location)

Basically, I need to iterate over each class, then get each method of each class, and then put a breakpoint on every location. But I want to exclude non-project classes. How to do that? Thank you!

Nfff3
  • 321
  • 8
  • 24
  • What are you trying to achieve by breakpointing one every line? You may be better served by something like code instrumentation – PiRocks May 09 '20 at 15:06
  • I'd like to create a code coverage tool with some other information besides only line numbers. I thought of using JVMTI for that. Code instrumentation would be an option, but probably more complicated. – Nfff3 May 10 '20 at 10:51
  • So the trouble with breakpoints on every line is that you are going to have a lot of breapoints. Each breakpoint comes with significant runtime overhead, so any programs/unittests you run would become several orders of magnitude slower. The so called "correct" way to do this would be instrumentation – PiRocks May 10 '20 at 13:52
  • To exclude non-project classes you would need to know in advance what your project classes are. You could do this by iterating over your project directory/subdirectories and get a list of all classes in your project. The vm doesn't really know the difference between your classes, and classes written by someone else. If you only want to exclude java standard library classes, they all come from a jar called rt.jar (in java 8) – PiRocks May 10 '20 at 13:55
  • 1
    OK, thanks. Indeed, I ran some tests and hitting breakpoints comes with a 7-100x degradation of performance which is huge. So I guess the only way left to do it is via bytecode instrumentation. – Nfff3 May 10 '20 at 14:31

0 Answers0