/** * Free up global refs held by the filter. * free things up at the JNI level if needed. */ static jvmtiError clearFilters(HandlerNode *node) { JNIEnv *env = getEnv(); jint i; jvmtiError error = JVMTI_ERROR_NONE; Filter *filter = FILTERS_ARRAY(node); for (i = 0; i < FILTER_COUNT(node); ++i, ++filter) { switch (filter->modifier) { case JDWP_REQUEST_MODIFIER(ThreadOnly): if ( filter->u.ThreadOnly.thread != NULL ) { tossGlobalRef(env, &(filter->u.ThreadOnly.thread)); } break; case JDWP_REQUEST_MODIFIER(LocationOnly): tossGlobalRef(env, &(filter->u.LocationOnly.clazz)); break; case JDWP_REQUEST_MODIFIER(FieldOnly): tossGlobalRef(env, &(filter->u.FieldOnly.clazz)); break; case JDWP_REQUEST_MODIFIER(ExceptionOnly): if ( filter->u.ExceptionOnly.exception != NULL ) { tossGlobalRef(env, &(filter->u.ExceptionOnly.exception)); } break; case JDWP_REQUEST_MODIFIER(InstanceOnly): if ( filter->u.InstanceOnly.instance != NULL ) { tossGlobalRef(env, &(filter->u.InstanceOnly.instance)); } break; case JDWP_REQUEST_MODIFIER(ClassOnly): tossGlobalRef(env, &(filter->u.ClassOnly.clazz)); break; case JDWP_REQUEST_MODIFIER(ClassMatch): jvmtiDeallocate(filter->u.ClassMatch.classPattern); break; case JDWP_REQUEST_MODIFIER(ClassExclude): jvmtiDeallocate(filter->u.ClassExclude.classPattern); break; case JDWP_REQUEST_MODIFIER(Step): { jthread thread = filter->u.Step.thread; error = stepControl_endStep(thread); if (error == JVMTI_ERROR_NONE) { tossGlobalRef(env, &(filter->u.Step.thread)); } break; } } } if (error == JVMTI_ERROR_NONE) { FILTER_COUNT(node) = 0; /* blast so we don't clear again */ } return error; }
/** * Free up global refs held by the filter. * free things up at the JNI level if needed. */ static jint clearFilters(HandlerNode *node) { JNIEnv *env = getEnv(); jint i; jint error = JVMDI_ERROR_NONE; Filter *filter = FILTERS_ARRAY(node); for (i = 0; i < FILTER_COUNT(node); ++i, ++filter) { switch (filter->modifier) { case JDWP_REQUEST_MODIFIER(ThreadOnly): { jthread threadOnly = filter->u.ThreadOnly.thread; if (threadOnly != NULL) { (*env)->DeleteGlobalRef(env, threadOnly); } break; } case JDWP_REQUEST_MODIFIER(LocationOnly): { jclass clazz = filter->u.LocationOnly.clazz; (*env)->DeleteGlobalRef(env, clazz); break; } case JDWP_REQUEST_MODIFIER(FieldOnly): { jclass clazz = filter->u.FieldOnly.clazz; (*env)->DeleteGlobalRef(env, clazz); break; } case JDWP_REQUEST_MODIFIER(ExceptionOnly): { (*env)->DeleteGlobalRef(env, filter->u.ExceptionOnly.exception); break; } case JDWP_REQUEST_MODIFIER(InstanceOnly): { (*env)->DeleteGlobalRef(env, filter->u.InstanceOnly.instance); break; } case JDWP_REQUEST_MODIFIER(ClassOnly): { (*env)->DeleteGlobalRef(env, filter->u.ClassOnly.clazz); break; } case JDWP_REQUEST_MODIFIER(ClassMatch): { jdwpFree(filter->u.ClassMatch.classPattern); break; } case JDWP_REQUEST_MODIFIER(ClassExclude): { jdwpFree(filter->u.ClassExclude.classPattern); break; } case JDWP_REQUEST_MODIFIER(Step): { jthread thread = filter->u.Step.thread; error = stepControl_endStep(thread); if (error == JVMDI_ERROR_NONE) { (*env)->DeleteGlobalRef(env, thread); } break; } } } if (error == JVMDI_ERROR_NONE) { FILTER_COUNT(node) = 0; /* blast so we don't clear again */ } return error; }