jvmtiError eventFilter_setStepFilter(HandlerNode *node, jint index, jthread thread, jint size, jint depth) { jvmtiError error; JNIEnv *env = getEnv(); StepFilter *filter = &FILTER(node, index).u.Step; if (index >= FILTER_COUNT(node)) { return AGENT_ERROR_ILLEGAL_ARGUMENT; } if (NODE_EI(node) != EI_SINGLE_STEP) { return AGENT_ERROR_ILLEGAL_ARGUMENT; } /* Create a thread ref that will live beyond */ /* the end of this call */ saveGlobalRef(env, thread, &(filter->thread)); error = stepControl_beginStep(env, filter->thread, size, depth, node); if (error != JVMTI_ERROR_NONE) { tossGlobalRef(env, &(filter->thread)); return error; } FILTER(node, index).modifier = JDWP_REQUEST_MODIFIER(Step); filter->depth = depth; filter->size = size; return JVMTI_ERROR_NONE; }
/* Deletes the global reference that commonRef_idToRef() created */ void commonRef_idToRef_delete(JNIEnv *env, jobject ref) { if ( ref==NULL ) { return; } tossGlobalRef(env, &ref); }
/* Deletes the global reference that commonRef_idToRef() created */ void commonRef_idToRef_delete(JNIEnv *env, jobject ref) { if ( ref==NULL ) return; if ( env==NULL ) env = getEnv(); tossGlobalRef(env, &ref); }
static void handleSuspendThreadCommand(JNIEnv* env, SuspendThreadCommand *command) { /* * For the moment, there's nothing that can be done with the * return code, so we don't check it here. */ (void)threadControl_suspendThread(command->thread, JNI_TRUE); tossGlobalRef(env, &(command->thread)); }
/** * 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; }
static void handleFrameEventCommandSingle(JNIEnv* env, PacketOutputStream *out, FrameEventCommandSingle *command) { if (command->typeKey) { (void)outStream_writeByte(out, JDWP_EVENT(METHOD_EXIT_WITH_RETURN_VALUE)); } else { (void)outStream_writeByte(out, eventIndex2jdwp(command->ei)); } (void)outStream_writeInt(out, command->id); (void)outStream_writeObjectRef(env, out, command->thread); writeCodeLocation(out, command->clazz, command->method, command->location); if (command->typeKey) { (void)outStream_writeValue(env, out, command->typeKey, command->returnValue); if (isObjectTag(command->typeKey) && command->returnValue.l != NULL) { tossGlobalRef(env, &(command->returnValue.l)); } } tossGlobalRef(env, &(command->thread)); tossGlobalRef(env, &(command->clazz)); }
static void tossEventInfoRefs(JNIEnv *env, EventInfo *evinfo) { char sig; if ( evinfo->thread != NULL ) { tossGlobalRef(env, &(evinfo->thread)); } if ( evinfo->clazz != NULL ) { tossGlobalRef(env, &(evinfo->clazz)); } if ( evinfo->object != NULL ) { tossGlobalRef(env, &(evinfo->object)); } switch (evinfo->ei) { case EI_FIELD_MODIFICATION: if ( evinfo->u.field_modification.field_clazz != NULL ) { tossGlobalRef(env, &(evinfo->u.field_modification.field_clazz)); } sig = evinfo->u.field_modification.signature_type; if ((sig == JDWP_TAG(ARRAY)) || (sig == JDWP_TAG(OBJECT))) { if ( evinfo->u.field_modification.new_value.l != NULL ) { tossGlobalRef(env, &(evinfo->u.field_modification.new_value.l)); } } break; case EI_FIELD_ACCESS: if ( evinfo->u.field_access.field_clazz != NULL ) { tossGlobalRef(env, &(evinfo->u.field_access.field_clazz)); } break; case EI_EXCEPTION: if ( evinfo->u.exception.catch_clazz != NULL ) { tossGlobalRef(env, &(evinfo->u.exception.catch_clazz)); } break; default: break; } }
static void handleReportInvokeDoneCommand(JNIEnv* env, ReportInvokeDoneCommand *command) { invoker_completeInvokeRequest(command->thread); tossGlobalRef(env, &(command->thread)); }