< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

520 
521     return JNI_TRUE;
522 }
523 
524 static jboolean
525 getAllThreads(PacketInputStream *in, PacketOutputStream *out)
526 {
527     JNIEnv *env;
528 
529     if (gdata->vmDead) {
530         outStream_setError(out, JDWP_ERROR(VM_DEAD));
531         return JNI_TRUE;
532     }
533 
534     env = getEnv();
535 
536     WITH_LOCAL_REFS(env, 1) {
537 
538         int i;
539         jint threadCount;

540         jthread *theThreads;

541 
542         theThreads = allThreads(&threadCount);
543         if (theThreads == NULL) {







544             outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
545         } else {
546             /* Squish out all of the debugger-spawned threads */
547             threadCount = filterDebugThreads(theThreads, threadCount);
548 
549             (void)outStream_writeInt(out, threadCount);
550             for (i = 0; i <threadCount; i++) {



551                 (void)outStream_writeObjectRef(env, out, theThreads[i]);
552             }
553 
554             jvmtiDeallocate(theThreads);

555         }
556 
557     } END_WITH_LOCAL_REFS(env);
558 
559     return JNI_TRUE;
560 }
561 
562 static jboolean
563 topLevelThreadGroups(PacketInputStream *in, PacketOutputStream *out)
564 {
565     JNIEnv *env;
566 
567     if (gdata->vmDead) {
568         outStream_setError(out, JDWP_ERROR(VM_DEAD));
569         return JNI_TRUE;
570     }
571 
572     env = getEnv();
573 
574     WITH_LOCAL_REFS(env, 1) {

773     /* 12: canUseInstanceFilters */
774     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
775     /* 13: canGetSourceDebugExtension */
776     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_source_debug_extension);
777     /* 14: canRequestVMDeathEvent */
778     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
779     /* 15: canSetDefaultStratum */
780     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
781     /* 16: canGetInstanceInfo */
782     (void)outStream_writeBoolean(out, (jboolean)caps.can_tag_objects);
783     /* 17: canRequestMonitorEvents */
784     (void)outStream_writeBoolean(out, (jboolean)caps.can_generate_monitor_events);
785     /* 18: canGetMonitorFrameInfo */
786     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_owned_monitor_stack_depth_info);
787     /* remaining reserved */
788     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 19 */
789     /* 20 Can get constant pool information */
790     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_constant_pool);
791     /* 21 Can force early return */
792     (void)outStream_writeBoolean(out, (jboolean)caps.can_force_early_return);


793 
794     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 22 */
795     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 23 */
796     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 24 */
797     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 25 */
798     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 26 */
799     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 27 */
800     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 28 */
801     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 29 */
802     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 30 */
803     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 31 */
804     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 32 */
805     return JNI_TRUE;
806 }
807 
808 static int
809 countPaths(char *string) {
810     int cnt = 1; /* always have one */
811     char *pos = string;
812     char *ps;
813 
814     ps = gdata->property_path_separator;

  1 /*
  2  * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

520 
521     return JNI_TRUE;
522 }
523 
524 static jboolean
525 getAllThreads(PacketInputStream *in, PacketOutputStream *out)
526 {
527     JNIEnv *env;
528 
529     if (gdata->vmDead) {
530         outStream_setError(out, JDWP_ERROR(VM_DEAD));
531         return JNI_TRUE;
532     }
533 
534     env = getEnv();
535 
536     WITH_LOCAL_REFS(env, 1) {
537 
538         int i;
539         jint threadCount;
540         jint vthreadCount;
541         jthread *theThreads;
542         jthread *theVThreads;
543 
544         theThreads = allThreads(&threadCount);
545         if (gdata->enumerateVThreads) {
546             theVThreads = threadControl_allVThreads(&vthreadCount);
547         } else {
548             theVThreads = NULL;
549             vthreadCount = 0;
550         }
551 
552         if (theThreads == NULL || (theVThreads == NULL && vthreadCount != 0)) {
553             outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
554         } else {
555             /* Squish out all of the debugger-spawned threads */
556             threadCount = filterDebugThreads(theThreads, threadCount);
557 
558             (void)outStream_writeInt(out, threadCount + vthreadCount);
559             for (i = 0; i < vthreadCount; i++) {
560                 (void)outStream_writeObjectRef(env, out, theVThreads[i]);
561             }
562             for (i = 0; i < threadCount; i++) {
563                 (void)outStream_writeObjectRef(env, out, theThreads[i]);
564             }
565 
566             jvmtiDeallocate(theThreads);
567             jvmtiDeallocate(theVThreads);
568         }
569 
570     } END_WITH_LOCAL_REFS(env);
571 
572     return JNI_TRUE;
573 }
574 
575 static jboolean
576 topLevelThreadGroups(PacketInputStream *in, PacketOutputStream *out)
577 {
578     JNIEnv *env;
579 
580     if (gdata->vmDead) {
581         outStream_setError(out, JDWP_ERROR(VM_DEAD));
582         return JNI_TRUE;
583     }
584 
585     env = getEnv();
586 
587     WITH_LOCAL_REFS(env, 1) {

786     /* 12: canUseInstanceFilters */
787     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
788     /* 13: canGetSourceDebugExtension */
789     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_source_debug_extension);
790     /* 14: canRequestVMDeathEvent */
791     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
792     /* 15: canSetDefaultStratum */
793     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
794     /* 16: canGetInstanceInfo */
795     (void)outStream_writeBoolean(out, (jboolean)caps.can_tag_objects);
796     /* 17: canRequestMonitorEvents */
797     (void)outStream_writeBoolean(out, (jboolean)caps.can_generate_monitor_events);
798     /* 18: canGetMonitorFrameInfo */
799     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_owned_monitor_stack_depth_info);
800     /* remaining reserved */
801     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 19 */
802     /* 20 Can get constant pool information */
803     (void)outStream_writeBoolean(out, (jboolean)caps.can_get_constant_pool);
804     /* 21 Can force early return */
805     (void)outStream_writeBoolean(out, (jboolean)caps.can_force_early_return);
806     /* 22 Supports virtual threads, temporary capability */
807     (void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);
808 

809     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 23 */
810     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 24 */
811     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 25 */
812     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 26 */
813     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 27 */
814     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 28 */
815     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 29 */
816     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 30 */
817     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 31 */
818     (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 32 */
819     return JNI_TRUE;
820 }
821 
822 static int
823 countPaths(char *string) {
824     int cnt = 1; /* always have one */
825     char *pos = string;
826     char *ps;
827 
828     ps = gdata->property_path_separator;
< prev index next >