< prev index next >

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

Print this page
@@ -90,10 +90,14 @@
  
  typedef struct SourceNameFilter {
      char *sourceNamePattern;
  } SourceNameFilter;
  
+ typedef struct PlatformThreadsFilter {
+     char unused;  // to avoid an empty struct
+ } PlatformThreadsFilter;
+ 
  typedef struct Filter_ {
      jbyte modifier;
      union {
          struct ClassFilter ClassOnly;
          struct LocationFilter LocationOnly;

@@ -105,10 +109,11 @@
          struct InstanceFilter InstanceOnly;
          struct StepFilter Step;
          struct MatchFilter ClassMatch;
          struct MatchFilter ClassExclude;
          struct SourceNameFilter SourceNameOnly;
+         struct PlatformThreadsFilter PlatformThreadsOnly;
      } u;
  } Filter;
  
  /* The filters array is allocated to the specified filterCount.
   * Theoretically, some compiler could do range checking on this

@@ -538,10 +543,18 @@
                    return JNI_FALSE;
                }
                break;
            }
  
+         case JDWP_REQUEST_MODIFIER(PlatformThreadsOnly): {
+             jboolean isVirtual = JNI_FUNC_PTR(env, IsVirtualThread)(env, thread);
+             if (isVirtual) {
+                 return JNI_FALSE;
+             }
+             break;
+         }
+ 
          default:
              EXIT_ERROR(AGENT_ERROR_ILLEGAL_ARGUMENT,"Invalid filter modifier");
              return JNI_FALSE;
          }
      }

@@ -959,10 +972,24 @@
      filter->sourceNamePattern = sourceNamePattern;
      return JVMTI_ERROR_NONE;
  
  }
  
+ jvmtiError eventFilter_setPlatformThreadsOnlyFilter(HandlerNode *node, jint index)
+ {
+     PlatformThreadsFilter *filter = &FILTER(node, index).u.PlatformThreadsOnly;
+     if (index >= FILTER_COUNT(node)) {
+         return AGENT_ERROR_ILLEGAL_ARGUMENT;
+     }
+     if (NODE_EI(node) != EI_THREAD_START && NODE_EI(node) != EI_THREAD_END) {
+         return AGENT_ERROR_ILLEGAL_ARGUMENT;
+     }
+     FILTER(node, index).modifier = JDWP_REQUEST_MODIFIER(PlatformThreadsOnly);
+     return JVMTI_ERROR_NONE;
+ 
+ }
+ 
  /***** JVMTI event enabling / disabling *****/
  
  /**
   * Return the Filter that is of the specified type (modifier).
   * Return NULL if not found.

@@ -1238,10 +1265,12 @@
          case EI_THREAD_END:
          case EI_VM_INIT:
          case EI_VM_DEATH:
          case EI_CLASS_PREPARE:
          case EI_GC_FINISH:
+         case EI_VIRTUAL_THREAD_START:
+         case EI_VIRTUAL_THREAD_END:
              return error;
  
          case EI_FIELD_ACCESS:
          case EI_FIELD_MODIFICATION:
              error = setWatchpoint(node);

@@ -1297,10 +1326,12 @@
          case EI_THREAD_END:
          case EI_VM_INIT:
          case EI_VM_DEATH:
          case EI_CLASS_PREPARE:
          case EI_GC_FINISH:
+         case EI_VIRTUAL_THREAD_START:
+         case EI_VIRTUAL_THREAD_END:
              return error;
  
          case EI_FIELD_ACCESS:
          case EI_FIELD_MODIFICATION:
              error = clearWatchpoint(node);

@@ -1369,12 +1400,13 @@
      Filter *filter = FILTERS_ARRAY(node);
  
      for (i = 0; i < FILTER_COUNT(node); ++i, ++filter) {
          switch (filter->modifier) {
              case JDWP_REQUEST_MODIFIER(ThreadOnly):
-                 tty_message("ThreadOnly: thread(%p)",
-                             filter->u.ThreadOnly.thread);
+                 tty_message("ThreadOnly: thread(%p) isVThread(%d)",
+                             filter->u.ThreadOnly.thread,
+                             isVThread(filter->u.ThreadOnly.thread));
                  break;
              case JDWP_REQUEST_MODIFIER(ClassOnly): {
                  char *class_name;
                  classSignature(filter->u.ClassOnly.clazz, &class_name, NULL);
                  tty_message("ClassOnly: clazz(%s)",

@@ -1425,19 +1457,23 @@
              case JDWP_REQUEST_MODIFIER(ClassExclude):
                  tty_message("ClassExclude: classPattern(%s)",
                              filter->u.ClassExclude.classPattern);
                  break;
              case JDWP_REQUEST_MODIFIER(Step):
-                 tty_message("Step: size(%d) depth(%d) thread(%p)",
+                 tty_message("Step: size(%d) depth(%d) thread(%p) isVThread(%d)",
                              filter->u.Step.size,
                              filter->u.Step.depth,
-                             filter->u.Step.thread);
+                             filter->u.Step.thread,
+                             isVThread(filter->u.Step.thread));
                  break;
              case JDWP_REQUEST_MODIFIER(SourceNameMatch):
                  tty_message("SourceNameMatch: sourceNamePattern(%s)",
                              filter->u.SourceNameOnly.sourceNamePattern);
                  break;
+             case JDWP_REQUEST_MODIFIER(PlatformThreadsOnly):
+                 tty_message("PlatformThreadsOnly: enabled");
+                 break;
              default:
                  EXIT_ERROR(AGENT_ERROR_ILLEGAL_ARGUMENT, "Invalid filter modifier");
                  return;
          }
      }
< prev index next >