1 /*
2 * Copyright (c) 2003, 2022, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
34 static jvmtiEventCallbacks callbacks;
35 static jmethodID mid;
36 static frame_info expected_platform_frames[] = {
37 {"Lgetstacktr05$TestThread;", "chain4", "()V"},
38 {"Lgetstacktr05$TestThread;", "chain3", "()V"},
39 {"Lgetstacktr05$TestThread;", "chain2", "()V"},
40 {"Lgetstacktr05$TestThread;", "chain1", "()V"},
41 {"Lgetstacktr05$TestThread;", "run", "()V"},
42 {"Ljava/lang/Thread;", "runWith", "(Ljava/lang/Object;Ljava/lang/Runnable;)V"},
43 {"Ljava/lang/Thread;", "run", "()V"},
44 };
45
46 static frame_info expected_virtual_frames[] = {
47 {"Lgetstacktr05$TestThread;", "chain4", "()V"},
48 {"Lgetstacktr05$TestThread;", "chain3", "()V"},
49 {"Lgetstacktr05$TestThread;", "chain2", "()V"},
50 {"Lgetstacktr05$TestThread;", "chain1", "()V"},
51 {"Lgetstacktr05$TestThread;", "run", "()V"},
52 {"Ljava/lang/VirtualThread;", "runWith", "(Ljava/lang/Object;Ljava/lang/Runnable;)V"},
53 {"Ljava/lang/VirtualThread;", "run", "(Ljava/lang/Runnable;)V"},
54 {"Ljava/lang/VirtualThread$VThreadContinuation;", "lambda$new$0", "(Ljava/lang/VirtualThread;Ljava/lang/Runnable;)V"},
55 {"Ljava/lang/VirtualThread$VThreadContinuation$$Lambda;", "run", "()V"},
56 {"Ljdk/internal/vm/Continuation;", "enter0", "()V"},
57 {"Ljdk/internal/vm/Continuation;", "enter", "(Ljdk/internal/vm/Continuation;Z)V"},
58 };
59
60
61 void JNICALL
62 Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread, jmethodID method, jlocation location) {
63 jint frame_count = 0;
64
65 if (mid != method) {
66 jni->FatalError("ERROR: didn't know where we got called from");
67 }
68
69 LOG(">>> (bp) checking frame count ...\n");
70
71 check_jvmti_status(jni, jvmti_env->GetFrameCount(thread, &frame_count), "GetFrameCount failed.");
72 int expected_number_of_stack_frames = jni->IsVirtualThread(thread)
73 ? ((int) (sizeof(expected_virtual_frames) / sizeof(frame_info)))
74 : ((int) (sizeof(expected_platform_frames) / sizeof(frame_info)));
75 if (frame_count != expected_number_of_stack_frames + 1) {
|
1 /*
2 * Copyright (c) 2003, 2023, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
34 static jvmtiEventCallbacks callbacks;
35 static jmethodID mid;
36 static frame_info expected_platform_frames[] = {
37 {"Lgetstacktr05$TestThread;", "chain4", "()V"},
38 {"Lgetstacktr05$TestThread;", "chain3", "()V"},
39 {"Lgetstacktr05$TestThread;", "chain2", "()V"},
40 {"Lgetstacktr05$TestThread;", "chain1", "()V"},
41 {"Lgetstacktr05$TestThread;", "run", "()V"},
42 {"Ljava/lang/Thread;", "runWith", "(Ljava/lang/Object;Ljava/lang/Runnable;)V"},
43 {"Ljava/lang/Thread;", "run", "()V"},
44 };
45
46 static frame_info expected_virtual_frames[] = {
47 {"Lgetstacktr05$TestThread;", "chain4", "()V"},
48 {"Lgetstacktr05$TestThread;", "chain3", "()V"},
49 {"Lgetstacktr05$TestThread;", "chain2", "()V"},
50 {"Lgetstacktr05$TestThread;", "chain1", "()V"},
51 {"Lgetstacktr05$TestThread;", "run", "()V"},
52 {"Ljava/lang/VirtualThread;", "runWith", "(Ljava/lang/Object;Ljava/lang/Runnable;)V"},
53 {"Ljava/lang/VirtualThread;", "run", "(Ljava/lang/Runnable;)V"},
54 {"Ljava/lang/VirtualThread$VThreadContinuation$1;", "run", "()V"},
55 {"Ljdk/internal/vm/Continuation;", "enter0", "()V"},
56 {"Ljdk/internal/vm/Continuation;", "enter", "(Ljdk/internal/vm/Continuation;Z)V"},
57 };
58
59
60 void JNICALL
61 Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread, jmethodID method, jlocation location) {
62 jint frame_count = 0;
63
64 if (mid != method) {
65 jni->FatalError("ERROR: didn't know where we got called from");
66 }
67
68 LOG(">>> (bp) checking frame count ...\n");
69
70 check_jvmti_status(jni, jvmti_env->GetFrameCount(thread, &frame_count), "GetFrameCount failed.");
71 int expected_number_of_stack_frames = jni->IsVirtualThread(thread)
72 ? ((int) (sizeof(expected_virtual_frames) / sizeof(frame_info)))
73 : ((int) (sizeof(expected_platform_frames) / sizeof(frame_info)));
74 if (frame_count != expected_number_of_stack_frames + 1) {
|