< prev index next >

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

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
--- 1,7 ---
  /*
!  * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

*** 535,25 ***
  
      WITH_LOCAL_REFS(env, 1) {
  
          int i;
          jint threadCount;
          jthread *theThreads;
  
          theThreads = allThreads(&threadCount);
!         if (theThreads == NULL) {
              outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
          } else {
              /* Squish out all of the debugger-spawned threads */
              threadCount = filterDebugThreads(theThreads, threadCount);
  
!             (void)outStream_writeInt(out, threadCount);
!             for (i = 0; i <threadCount; i++) {
                  (void)outStream_writeObjectRef(env, out, theThreads[i]);
              }
  
              jvmtiDeallocate(theThreads);
          }
  
      } END_WITH_LOCAL_REFS(env);
  
      return JNI_TRUE;
--- 535,38 ---
  
      WITH_LOCAL_REFS(env, 1) {
  
          int i;
          jint threadCount;
+         jint vthreadCount;
          jthread *theThreads;
+         jthread *theVThreads;
  
          theThreads = allThreads(&threadCount);
!         if (gdata->enumerateVThreads) {
+             theVThreads = threadControl_allVThreads(&vthreadCount);
+         } else {
+             theVThreads = NULL;
+             vthreadCount = 0;
+         }
+ 
+         if (theThreads == NULL || (theVThreads == NULL && vthreadCount != 0)) {
              outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
          } else {
              /* Squish out all of the debugger-spawned threads */
              threadCount = filterDebugThreads(theThreads, threadCount);
  
!             (void)outStream_writeInt(out, threadCount + vthreadCount);
!             for (i = 0; i < vthreadCount; i++) {
+                 (void)outStream_writeObjectRef(env, out, theVThreads[i]);
+             }
+             for (i = 0; i < threadCount; i++) {
                  (void)outStream_writeObjectRef(env, out, theThreads[i]);
              }
  
              jvmtiDeallocate(theThreads);
+             jvmtiDeallocate(theVThreads);
          }
  
      } END_WITH_LOCAL_REFS(env);
  
      return JNI_TRUE;

*** 788,12 ***
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 19 */
      /* 20 Can get constant pool information */
      (void)outStream_writeBoolean(out, (jboolean)caps.can_get_constant_pool);
      /* 21 Can force early return */
      (void)outStream_writeBoolean(out, (jboolean)caps.can_force_early_return);
  
-     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 22 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 23 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 24 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 25 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 26 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 27 */
--- 801,13 ---
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 19 */
      /* 20 Can get constant pool information */
      (void)outStream_writeBoolean(out, (jboolean)caps.can_get_constant_pool);
      /* 21 Can force early return */
      (void)outStream_writeBoolean(out, (jboolean)caps.can_force_early_return);
+     /* 22 Supports virtual threads, temporary capability */
+     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
  
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 23 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 24 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 25 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 26 */
      (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 27 */
< prev index next >