author | iignatyev |
Tue, 07 Aug 2018 13:51:30 -0700 | |
changeset 51357 | f689461b1684 |
permissions | -rw-r--r-- |
51357
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
1 |
/* |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
4 |
* |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
8 |
* |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
14 |
* |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
18 |
* |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
22 |
*/ |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
23 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
24 |
#include <string.h> |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
25 |
#include <stdio.h> |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
26 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
27 |
#include "jvmti.h" |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
28 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
29 |
#define CLASS_NAME "Lcompiler/jsr292/cr8026328/Test8026328;" |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
30 |
#define METHOD_NAME "main" |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
31 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
32 |
static jvmtiEnv *jvmti = NULL; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
33 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
34 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
35 |
void JNICALL |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
36 |
classprepare(jvmtiEnv* jvmti_env, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
37 |
JNIEnv* jni_env, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
38 |
jthread thread, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
39 |
jclass klass) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
40 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
41 |
char* buf; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
42 |
(*jvmti)->GetClassSignature(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
43 |
klass, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
44 |
&buf, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
45 |
NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
46 |
if (strcmp(CLASS_NAME, buf) == 0) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
47 |
jint nMethods; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
48 |
jmethodID* methods; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
49 |
int i; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
50 |
(*jvmti)->GetClassMethods(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
51 |
klass, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
52 |
&nMethods, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
53 |
&methods); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
54 |
for (i = 0; i < nMethods; i++) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
55 |
char* name; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
56 |
(*jvmti)->GetMethodName(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
57 |
methods[i], |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
58 |
&name, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
59 |
NULL, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
60 |
NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
61 |
if (strcmp(METHOD_NAME, name) == 0) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
62 |
printf("Setting breakpoint\n"); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
63 |
fflush(stdout); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
64 |
(*jvmti)->SetBreakpoint(jvmti, methods[i], 0); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
65 |
} |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
66 |
} |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
67 |
} |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
68 |
} |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
69 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
70 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
71 |
void JNICALL |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
72 |
breakpoint(jvmtiEnv* jvmti_env, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
73 |
JNIEnv* jni_env, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
74 |
jthread thread, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
75 |
jmethodID method, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
76 |
jlocation location) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
77 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
78 |
jclass declaring_class; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
79 |
char* name; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
80 |
char* cname; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
81 |
(*jvmti)->GetMethodName(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
82 |
method, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
83 |
&name, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
84 |
NULL, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
85 |
NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
86 |
(*jvmti)->GetMethodDeclaringClass(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
87 |
method, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
88 |
&declaring_class); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
89 |
(*jvmti)->GetClassSignature(jvmti, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
90 |
declaring_class, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
91 |
&cname, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
92 |
NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
93 |
printf("Hit breakpoint at %s::%s:%d\n", cname, name, (int) location); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
94 |
fflush(stdout); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
95 |
} |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
96 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
97 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
98 |
JNIEXPORT jint JNICALL |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
99 |
Agent_OnLoad(JavaVM* vm, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
100 |
char* options, |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
101 |
void* reserved) { |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
102 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
103 |
jvmtiCapabilities capa; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
104 |
jvmtiEventCallbacks cbs = {0}; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
105 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
106 |
(*vm)->GetEnv(vm, (void**)&jvmti, JVMTI_VERSION_1_0); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
107 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
108 |
memset(&capa, 0, sizeof(capa)); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
109 |
capa.can_generate_breakpoint_events = 1; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
110 |
capa.can_generate_single_step_events = 1; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
111 |
(*jvmti)->AddCapabilities(jvmti, &capa); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
112 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
113 |
cbs.ClassPrepare = classprepare; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
114 |
cbs.Breakpoint = breakpoint; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
115 |
(*jvmti)->SetEventCallbacks(jvmti, &cbs, sizeof(cbs)); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
116 |
(*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
117 |
(*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
118 |
printf("Loaded agent\n"); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
119 |
fflush(stdout); |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
120 |
|
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
121 |
return 0; |
f689461b1684
8031761: [TESTBUG] Add a regression test for JDK-8026328
iignatyev
parents:
diff
changeset
|
122 |
} |