changeset 53016:c278c84199ab fibers

Enable delivering more events to the debugger on fibers. Previously this was only done for BREAKPOINT and SINGLE_STEP events, but now it is done for all events.
author cjplummer
date Thu, 13 Dec 2018 22:49:45 -0800
parents 30562b08e2dc
children 12235211dae8
files src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c
diffstat 1 files changed, 15 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c	Wed Dec 12 19:28:02 2018 -0800
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c	Thu Dec 13 22:49:45 2018 -0800
@@ -284,7 +284,7 @@
 }
 
 static void
-writeSingleStepEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
+writeThreadOrFiber(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
 {
     /*
      * Write the fiber ref if the event matched a fiber filter, or if the event was not
@@ -293,19 +293,19 @@
      */
     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)
 {
-    /*
-     * 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);
+    writeThreadOrFiber(env, out, evinfo);
     writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location);
 }
 
@@ -316,7 +316,7 @@
 
     fieldClassTag = referenceTypeTag(evinfo->u.field_access.field_clazz);
 
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
+    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);
@@ -333,7 +333,7 @@
 
     fieldClassTag = referenceTypeTag(evinfo->u.field_modification.field_clazz);
 
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
+    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);
@@ -347,7 +347,7 @@
 static void
 writeExceptionEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
 {
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
+    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);
@@ -358,20 +358,14 @@
 static void
 writeThreadEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
 {
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
-}
-
-static void
-writeFiberEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
-{
-    (void)outStream_writeObjectRef(env, out, evinfo->fiber);
+    writeThreadOrFiber(env, out, evinfo);
 }
 
 static void
 writeMonitorEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
 {
     jclass klass;
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
+    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) {
@@ -410,7 +404,7 @@
     }
     status = classStatus(evinfo->clazz);
 
-    (void)outStream_writeObjectRef(env, out, evinfo->thread);
+    writeThreadOrFiber(env, out, evinfo);
     (void)outStream_writeByte(out, classTag);
     (void)outStream_writeObjectRef(env, out, evinfo->clazz);
     (void)outStream_writeString(out, signature);
@@ -457,7 +451,7 @@
             /* 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.
              */
-            writeFiberEvent(env, out, evinfo);
+            writeThreadEvent(env, out, evinfo);
             break;
         case EI_CLASS_LOAD:
         case EI_CLASS_PREPARE: