< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/ThreadReferenceImpl.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

442     jvmtiError error;
443     jthread thread;
444     jobject throwable;
445     JNIEnv *env;
446 
447     env = getEnv();
448     thread = inStream_readThreadRef(env, in);
449     if (inStream_error(in)) {
450         return JNI_TRUE;
451     }
452     throwable = inStream_readObjectRef(env, in);
453     if (inStream_error(in)) {
454         return JNI_TRUE;
455     }
456 
457     if (threadControl_isDebugThread(thread)) {
458         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
459         return JNI_TRUE;
460     }
461 








462     error = threadControl_stop(thread, throwable);
463     if (error != JVMTI_ERROR_NONE) {
464         outStream_setError(out, map2jdwpError(error));
465     }
466     return JNI_TRUE;
467 }
468 
469 static jboolean
470 interrupt(PacketInputStream *in, PacketOutputStream *out)
471 {
472     jvmtiError error;
473     jthread thread;
474 
475     thread = inStream_readThreadRef(getEnv(), in);
476     if (inStream_error(in)) {
477         return JNI_TRUE;
478     }
479 
480     if (threadControl_isDebugThread(thread)) {
481         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
482         return JNI_TRUE;
483     }
484 








485     error = threadControl_interrupt(thread);
486     if (error != JVMTI_ERROR_NONE) {
487         outStream_setError(out, map2jdwpError(error));
488     }
489     return JNI_TRUE;
490 }
491 
492 static jboolean
493 suspendCount(PacketInputStream *in, PacketOutputStream *out)
494 {
495     jvmtiError error;
496     jint count;
497     jthread thread;
498 
499     thread = inStream_readThreadRef(getEnv(), in);
500     if (inStream_error(in)) {
501         return JNI_TRUE;
502     }
503 
504     if (threadControl_isDebugThread(thread)) {

648             case JDWP_TAG(BOOLEAN):
649                 value.z = inStream_readBoolean(in);
650                 error = JVMTI_FUNC_PTR(gdata->jvmti,ForceEarlyReturnInt)
651                                 (gdata->jvmti, thread, value.z);
652                 break;
653 
654             default:
655                 error =  AGENT_ERROR_INVALID_TAG;
656                 break;
657         }
658     }
659     {
660       jdwpError serror = map2jdwpError(error);
661       if (serror != JDWP_ERROR(NONE)) {
662         outStream_setError(out, serror);
663       }
664     }
665     return JNI_TRUE;
666 }
667 

























668 Command ThreadReference_Commands[] = {
669     {name, "Name"},
670     {suspend, "Suspend"},
671     {resume, "Resume"},
672     {status, "Status"},
673     {threadGroup, "ThreadGroup"},
674     {frames, "Frames"},
675     {getFrameCount, "GetFrameCount"},
676     {ownedMonitors, "OwnedMonitors"},
677     {currentContendedMonitor, "CurrentContendedMonitor"},
678     {stop, "Stop"},
679     {interrupt, "Interrupt"},
680     {suspendCount, "SuspendCount"},
681     {ownedMonitorsWithStackDepth, "OwnedMonitorsWithStackDepth"},
682     {forceEarlyReturn, "ForceEarlyReturn"}

683 };
684 
685 DEBUG_DISPATCH_DEFINE_CMDSET(ThreadReference)

  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

442     jvmtiError error;
443     jthread thread;
444     jobject throwable;
445     JNIEnv *env;
446 
447     env = getEnv();
448     thread = inStream_readThreadRef(env, in);
449     if (inStream_error(in)) {
450         return JNI_TRUE;
451     }
452     throwable = inStream_readObjectRef(env, in);
453     if (inStream_error(in)) {
454         return JNI_TRUE;
455     }
456 
457     if (threadControl_isDebugThread(thread)) {
458         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
459         return JNI_TRUE;
460     }
461 
462     /* vthread fixme: We should just call throught to JVMTI and let the failure come from
463        there, but first we need a test that exercises this code for vthreads. */
464     if (isVThread(thread)) {
465         tty_message("ThreadReferenceImpl::stop() not supported.");
466         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
467         return JNI_TRUE;
468     }
469 
470     error = threadControl_stop(thread, throwable);
471     if (error != JVMTI_ERROR_NONE) {
472         outStream_setError(out, map2jdwpError(error));
473     }
474     return JNI_TRUE;
475 }
476 
477 static jboolean
478 interrupt(PacketInputStream *in, PacketOutputStream *out)
479 {
480     jvmtiError error;
481     jthread thread;
482 
483     thread = inStream_readThreadRef(getEnv(), in);
484     if (inStream_error(in)) {
485         return JNI_TRUE;
486     }
487 
488     if (threadControl_isDebugThread(thread)) {
489         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
490         return JNI_TRUE;
491     }
492 
493     /* vthread fixme: This should work. Need to disable this forced failure,
494        but first we need a test that exercises this code for vthreads. */
495     if (isVThread(thread)) {
496         tty_message("ThreadReferenceImpl::interrupt() not supported.");
497         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
498         return JNI_TRUE;
499     }
500 
501     error = threadControl_interrupt(thread);
502     if (error != JVMTI_ERROR_NONE) {
503         outStream_setError(out, map2jdwpError(error));
504     }
505     return JNI_TRUE;
506 }
507 
508 static jboolean
509 suspendCount(PacketInputStream *in, PacketOutputStream *out)
510 {
511     jvmtiError error;
512     jint count;
513     jthread thread;
514 
515     thread = inStream_readThreadRef(getEnv(), in);
516     if (inStream_error(in)) {
517         return JNI_TRUE;
518     }
519 
520     if (threadControl_isDebugThread(thread)) {

664             case JDWP_TAG(BOOLEAN):
665                 value.z = inStream_readBoolean(in);
666                 error = JVMTI_FUNC_PTR(gdata->jvmti,ForceEarlyReturnInt)
667                                 (gdata->jvmti, thread, value.z);
668                 break;
669 
670             default:
671                 error =  AGENT_ERROR_INVALID_TAG;
672                 break;
673         }
674     }
675     {
676       jdwpError serror = map2jdwpError(error);
677       if (serror != JDWP_ERROR(NONE)) {
678         outStream_setError(out, serror);
679       }
680     }
681     return JNI_TRUE;
682 }
683 
684 static jboolean
685 isVirtual(PacketInputStream *in, PacketOutputStream *out)
686 {
687     JNIEnv *env;
688     jthread thread;
689     jboolean isVirtual;
690 
691     env = getEnv();
692 
693     thread = inStream_readThreadRef(env, in);
694     if (inStream_error(in)) {
695         return JNI_TRUE;
696     }
697 
698     if (threadControl_isDebugThread(thread)) {
699         outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
700         return JNI_TRUE;
701     }
702 
703     isVirtual = JNI_FUNC_PTR(env,IsVirtualThread)(env, thread);
704     (void)outStream_writeBoolean(out, isVirtual);
705 
706     return JNI_TRUE;
707 }
708 
709 Command ThreadReference_Commands[] = {
710     {name, "Name"},
711     {suspend, "Suspend"},
712     {resume, "Resume"},
713     {status, "Status"},
714     {threadGroup, "ThreadGroup"},
715     {frames, "Frames"},
716     {getFrameCount, "GetFrameCount"},
717     {ownedMonitors, "OwnedMonitors"},
718     {currentContendedMonitor, "CurrentContendedMonitor"},
719     {stop, "Stop"},
720     {interrupt, "Interrupt"},
721     {suspendCount, "SuspendCount"},
722     {ownedMonitorsWithStackDepth, "OwnedMonitorsWithStackDepth"},
723     {forceEarlyReturn, "ForceEarlyReturn"},
724     {isVirtual, "IsVirtual"}
725 };
726 
727 DEBUG_DISPATCH_DEFINE_CMDSET(ThreadReference)
< prev index next >