1

Currently this is how I generate Step events:

...
capabilities.can_generate_single_step_events  = 1;
...
callbacks.SingleStep            = SingleStep;
jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL);

And then the callback itself:

void JNICALL
SingleStep(jvmtiEnv *jvmti_env,
            JNIEnv* jni_env,
            jthread thread,
            jmethodID method,
            jlocation location){

    sum++;  
    char *name;
    char *sig;
    char *gsig;
    jvmti_env->GetMethodName(method, &name, &sig, &gsig);
    printf("%s %s %s\n",name, sig, gsig);
}

But this generates an event for every instruction executed inside the JVM, even if I have a simple console app with 3 lines of code (and no libraries), it fires 1 million step events. How can add step events only to my own code?

Nfff3
  • 321
  • 8
  • 24

0 Answers0