< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c

Print this page

        

*** 282,312 **** debugMonitorNotifyAll(commandQueueLock); debugMonitorExit(commandQueueLock); } static void writeSingleStepEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! (void)outStream_writeObjectRef(env, out, evinfo->thread); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); } static void writeBreakpointEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! (void)outStream_writeObjectRef(env, out, evinfo->thread); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); } static void writeFieldAccessEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { jbyte fieldClassTag; fieldClassTag = referenceTypeTag(evinfo->u.field_access.field_clazz); ! (void)outStream_writeObjectRef(env, out, evinfo->thread); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeByte(out, fieldClassTag); (void)outStream_writeObjectRef(env, out, evinfo->u.field_access.field_clazz); (void)outStream_writeFieldID(out, evinfo->u.field_access.field); (void)outStream_writeObjectTag(env, out, evinfo->object); --- 282,324 ---- debugMonitorNotifyAll(commandQueueLock); debugMonitorExit(commandQueueLock); } static void + writeThreadOrFiber(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) + { + /* + * Write the fiber ref if the event matched a fiber filter, or if the event was not + * filtered by thread, and came in on a carrier thread running a fiber. In either + * case evinfo->matchesFiber will be true. + */ + jthread thread = (evinfo->matchesFiber ? evinfo->fiber : evinfo->thread); + (void)outStream_writeObjectRef(env, out, thread); + } + + static void writeSingleStepEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! writeThreadOrFiber(env, out, evinfo); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); } static void writeBreakpointEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! writeThreadOrFiber(env, out, evinfo); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); } static void writeFieldAccessEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { jbyte fieldClassTag; fieldClassTag = referenceTypeTag(evinfo->u.field_access.field_clazz); ! writeThreadOrFiber(env, out, evinfo); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeByte(out, fieldClassTag); (void)outStream_writeObjectRef(env, out, evinfo->u.field_access.field_clazz); (void)outStream_writeFieldID(out, evinfo->u.field_access.field); (void)outStream_writeObjectTag(env, out, evinfo->object);
*** 319,329 **** { jbyte fieldClassTag; fieldClassTag = referenceTypeTag(evinfo->u.field_modification.field_clazz); ! (void)outStream_writeObjectRef(env, out, evinfo->thread); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeByte(out, fieldClassTag); (void)outStream_writeObjectRef(env, out, evinfo->u.field_modification.field_clazz); (void)outStream_writeFieldID(out, evinfo->u.field_modification.field); (void)outStream_writeObjectTag(env, out, evinfo->object); --- 331,341 ---- { jbyte fieldClassTag; fieldClassTag = referenceTypeTag(evinfo->u.field_modification.field_clazz); ! writeThreadOrFiber(env, out, evinfo); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeByte(out, fieldClassTag); (void)outStream_writeObjectRef(env, out, evinfo->u.field_modification.field_clazz); (void)outStream_writeFieldID(out, evinfo->u.field_modification.field); (void)outStream_writeObjectTag(env, out, evinfo->object);
*** 333,361 **** } static void writeExceptionEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! (void)outStream_writeObjectRef(env, out, evinfo->thread); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeObjectTag(env, out, evinfo->object); (void)outStream_writeObjectRef(env, out, evinfo->object); writeCodeLocation(out, evinfo->u.exception.catch_clazz, evinfo->u.exception.catch_method, evinfo->u.exception.catch_location); } static void writeThreadEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! (void)outStream_writeObjectRef(env, out, evinfo->thread); } static void writeMonitorEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { jclass klass; ! (void)outStream_writeObjectRef(env, out, evinfo->thread); (void)outStream_writeObjectTag(env, out, evinfo->object); (void)outStream_writeObjectRef(env, out, evinfo->object); if (evinfo->ei == EI_MONITOR_WAIT || evinfo->ei == EI_MONITOR_WAITED) { /* clazz of evinfo was set to class of monitor object for monitor wait event class filtering. * So get the method class to write location info. --- 345,373 ---- } static void writeExceptionEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! writeThreadOrFiber(env, out, evinfo); writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location); (void)outStream_writeObjectTag(env, out, evinfo->object); (void)outStream_writeObjectRef(env, out, evinfo->object); writeCodeLocation(out, evinfo->u.exception.catch_clazz, evinfo->u.exception.catch_method, evinfo->u.exception.catch_location); } static void writeThreadEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { ! writeThreadOrFiber(env, out, evinfo); } static void writeMonitorEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo) { jclass klass; ! writeThreadOrFiber(env, out, evinfo); (void)outStream_writeObjectTag(env, out, evinfo->object); (void)outStream_writeObjectRef(env, out, evinfo->object); if (evinfo->ei == EI_MONITOR_WAIT || evinfo->ei == EI_MONITOR_WAITED) { /* clazz of evinfo was set to class of monitor object for monitor wait event class filtering. * So get the method class to write location info.
*** 390,400 **** if (error != JVMTI_ERROR_NONE) { EXIT_ERROR(error,"signature"); } status = classStatus(evinfo->clazz); ! (void)outStream_writeObjectRef(env, out, evinfo->thread); (void)outStream_writeByte(out, classTag); (void)outStream_writeObjectRef(env, out, evinfo->clazz); (void)outStream_writeString(out, signature); (void)outStream_writeInt(out, map2jdwpClassStatus(status)); jvmtiDeallocate(signature); --- 402,412 ---- if (error != JVMTI_ERROR_NONE) { EXIT_ERROR(error,"signature"); } status = classStatus(evinfo->clazz); ! writeThreadOrFiber(env, out, evinfo); (void)outStream_writeByte(out, classTag); (void)outStream_writeObjectRef(env, out, evinfo->clazz); (void)outStream_writeString(out, signature); (void)outStream_writeInt(out, map2jdwpClassStatus(status)); jvmtiDeallocate(signature);
*** 432,441 **** --- 444,466 ---- break; case EI_THREAD_START: case EI_THREAD_END: writeThreadEvent(env, out, evinfo); break; + case EI_FIBER_SCHEDULED: + case EI_FIBER_TERMINATED: + /* Note that when we wrote the evinfo->ei byte above, it was mapped to an EI_THREAD_XXX event + * by eventIndex2jdwp(), so we didn't actually write the FIBER ei byte. + */ + writeThreadEvent(env, out, evinfo); + break; + case EI_FIBER_MOUNT: + case EI_FIBER_UNMOUNT: + case EI_CONTINUATION_RUN: + case EI_CONTINUATION_YIELD: + EXIT_ERROR(AGENT_ERROR_INVALID_EVENT_TYPE, "invalid event index"); + break; case EI_CLASS_LOAD: case EI_CLASS_PREPARE: writeClassEvent(env, out, evinfo); break; case EI_MONITOR_CONTENDED_ENTER:
*** 812,824 **** --- 837,851 ---- /* Change all references to global in the EventInfo struct */ static void saveEventInfoRefs(JNIEnv *env, EventInfo *evinfo) { jthread *pthread; + jthread *pfiber; jclass *pclazz; jobject *pobject; jthread thread; + jthread fiber; jclass clazz; jobject object; char sig; JNI_FUNC_PTR(env,ExceptionClear)(env);
*** 827,836 **** --- 854,869 ---- pthread = &(evinfo->thread); thread = *pthread; *pthread = NULL; saveGlobalRef(env, thread, pthread); } + if ( evinfo->fiber != NULL ) { + pfiber = &(evinfo->fiber); + fiber = *pfiber; + *pfiber = NULL; + saveGlobalRef(env, fiber, pfiber); + } if ( evinfo->clazz != NULL ) { pclazz = &(evinfo->clazz); clazz = *pclazz; *pclazz = NULL; saveGlobalRef(env, clazz, pclazz);
*** 890,899 **** --- 923,935 ---- { char sig; if ( evinfo->thread != NULL ) { tossGlobalRef(env, &(evinfo->thread)); } + if ( evinfo->fiber != NULL ) { + tossGlobalRef(env, &(evinfo->fiber)); + } if ( evinfo->clazz != NULL ) { tossGlobalRef(env, &(evinfo->clazz)); } if ( evinfo->object != NULL ) { tossGlobalRef(env, &(evinfo->object));
*** 1042,1057 **** return suspendPolicy; } void eventHelper_recordEvent(EventInfo *evinfo, jint id, jbyte suspendPolicy, ! struct bag *eventBag) { JNIEnv *env = getEnv(); CommandSingle *command = bagAdd(eventBag); if (command == NULL) { ! EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"badAdd(eventBag)"); } command->singleKind = COMMAND_SINGLE_EVENT; command->u.eventCommand.suspendPolicy = suspendPolicy; command->u.eventCommand.id = id; --- 1078,1093 ---- return suspendPolicy; } void eventHelper_recordEvent(EventInfo *evinfo, jint id, jbyte suspendPolicy, ! struct bag *eventBag) { JNIEnv *env = getEnv(); CommandSingle *command = bagAdd(eventBag); if (command == NULL) { ! EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"bagAdd(eventBag)"); } command->singleKind = COMMAND_SINGLE_EVENT; command->u.eventCommand.suspendPolicy = suspendPolicy; command->u.eventCommand.id = id;
< prev index next >