Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/back/ThreadGroupReferenceImpl.c
38765 views
/*1* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "util.h"26#include "ThreadGroupReferenceImpl.h"27#include "inStream.h"28#include "outStream.h"2930static jboolean31name(PacketInputStream *in, PacketOutputStream *out)32{33JNIEnv *env;34jthreadGroup group;3536env = getEnv();3738group = inStream_readThreadGroupRef(env, in);39if (inStream_error(in)) {40return JNI_TRUE;41}4243WITH_LOCAL_REFS(env, 1) {4445jvmtiThreadGroupInfo info;4647(void)memset(&info, 0, sizeof(info));48threadGroupInfo(group, &info);49(void)outStream_writeString(out, info.name == NULL ? "" : info.name);50if ( info.name != NULL )51jvmtiDeallocate(info.name);5253} END_WITH_LOCAL_REFS(env);5455return JNI_TRUE;56}5758static jboolean59parent(PacketInputStream *in, PacketOutputStream *out)60{61JNIEnv *env;62jthreadGroup group;6364env = getEnv();6566group = inStream_readThreadGroupRef(env, in);67if (inStream_error(in)) {68return JNI_TRUE;69}7071WITH_LOCAL_REFS(env, 1) {7273jvmtiThreadGroupInfo info;7475(void)memset(&info, 0, sizeof(info));76threadGroupInfo(group, &info);77(void)outStream_writeObjectRef(env, out, info.parent);78if ( info.name != NULL )79jvmtiDeallocate(info.name);8081} END_WITH_LOCAL_REFS(env);8283return JNI_TRUE;84}8586static jboolean87children(PacketInputStream *in, PacketOutputStream *out)88{89JNIEnv *env;90jthreadGroup group;9192env = getEnv();9394group = inStream_readThreadGroupRef(env, in);95if (inStream_error(in)) {96return JNI_TRUE;97}9899WITH_LOCAL_REFS(env, 1) {100101jvmtiError error;102jint threadCount;103jint groupCount;104jthread *theThreads;105jthread *theGroups;106107error = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadGroupChildren)(gdata->jvmti, group,108&threadCount,&theThreads,109&groupCount, &theGroups);110if (error != JVMTI_ERROR_NONE) {111outStream_setError(out, map2jdwpError(error));112} else {113114int i;115116/* Squish out all of the debugger-spawned threads */117threadCount = filterDebugThreads(theThreads, threadCount);118119(void)outStream_writeInt(out, threadCount);120for (i = 0; i < threadCount; i++) {121(void)outStream_writeObjectRef(env, out, theThreads[i]);122}123(void)outStream_writeInt(out, groupCount);124for (i = 0; i < groupCount; i++) {125(void)outStream_writeObjectRef(env, out, theGroups[i]);126}127128jvmtiDeallocate(theGroups);129jvmtiDeallocate(theThreads);130}131132} END_WITH_LOCAL_REFS(env);133134return JNI_TRUE;135}136137void *ThreadGroupReference_Cmds[] = { (void *)3,138(void *)name,139(void *)parent,140(void *)children };141142143