Skip to content

Commit 9de6d55

Browse files
authored
Merge pull request #3386 from gacholio/decomp
Test all cases of exception catch
2 parents 1de0a77 + 20c7aa2 commit 9de6d55

File tree

5 files changed

+68
-15
lines changed

5 files changed

+68
-15
lines changed

runtime/codert_vm/decomp.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,11 @@ fixStackForNewDecompilation(J9VMThread * currentThread, J9StackWalkState * walkS
10181018
Trc_Decomp_addDecompilation_atAllocate(currentThread);
10191019
*pcStoreAddress = (U_8 *) J9_BUILDER_SYMBOL(jitDecompileAfterAllocation);
10201020
break;
1021+
case J9_STACK_FLAGS_JIT_EXCEPTION_CATCH_RESOLVE:
1022+
/* Decompile during jitReportExceptionCatch */
1023+
Trc_Decomp_addDecompilation_atExceptionCatch(currentThread);
1024+
*pcStoreAddress = (U_8 *) J9_BUILDER_SYMBOL(jitDecompileAtExceptionCatch);
1025+
break;
10211026
default:
10221027
Trc_Decomp_addDecompilation_atCurrentPC(currentThread);
10231028
*pcStoreAddress = (U_8 *) J9_BUILDER_SYMBOL(jitDecompileAtCurrentPC);

runtime/tests/jvmtitests/agent/agent.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ runTest(agentEnv *env, char * options)
135135
test = getTest(env->testName);
136136

137137
if (NULL != test) {
138-
rc = test->fn(env, NULL);
138+
rc = test->fn(env, env->testArgs);
139139
} else {
140140
error(env, JVMTI_ERROR_ILLEGAL_ARGUMENT, "Unknown testcase: [%s]\n", env->testName);
141141
rc = JNI_ERR;

runtime/tests/jvmtitests/agent/error.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static agentError *
151151
__error(agentEnv * env, jvmtiError err, agentErrorType errType, char *file, const char *fnname, int line, char * errorMsg)
152152
{
153153
agentError *e;
154-
char *errorName;
154+
char *errorName = "Unknown JVMTI error";
155155
JVMTI_ACCESS_FROM_AGENT(env);
156156

157157

runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/decompResolveFrame/decomp003.c

+40-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
static agentEnv * env;
2828
static jmethodID catchMethod = NULL;
2929
static jlocation catchLocation = 0;
30-
30+
31+
static int singleStep = 1;
32+
static int stepInCatch = 0;
33+
3134
static void JNICALL
3235
cbSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location)
3336
{
@@ -94,14 +97,20 @@ cbExceptionCatch(jvmtiEnv *jvmti_env,
9497
if (JVMTI_ERROR_NONE != err) {
9598
error(env, err, "Failed to disable exception catch event");
9699
}
100+
if (stepInCatch) {
101+
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL);
102+
if ( err != JVMTI_ERROR_NONE ) {
103+
error(env, err, "Failed to enable step event");
104+
}
105+
}
97106
}
98107

99108

100109
jint JNICALL
101110
decomp003(agentEnv * _env, char * args)
102111
{
103112
JVMTI_ACCESS_FROM_AGENT(_env);
104-
jvmtiError err;
113+
jvmtiError err = JVMTI_ERROR_NONE;
105114
jvmtiEventCallbacks callbacks;
106115
jvmtiCapabilities capabilities;
107116

@@ -111,8 +120,21 @@ decomp003(agentEnv * _env, char * args)
111120
return JNI_ERR;
112121
}
113122

123+
if (NULL != args) {
124+
if (0 == strcasecmp(args, "nostep")) {
125+
singleStep = 0;
126+
} else if (0 == strcasecmp(args, "stepincatch")) {
127+
stepInCatch = 1;
128+
} else {
129+
error(env, err, "Unknown option");
130+
return JNI_ERR;
131+
}
132+
}
133+
114134
memset(&capabilities, 0, sizeof(jvmtiCapabilities));
115-
capabilities.can_generate_single_step_events = 1;
135+
if (singleStep) {
136+
capabilities.can_generate_single_step_events = 1;
137+
}
116138
capabilities.can_generate_exception_events = 1;
117139
err = (*jvmti_env)->AddCapabilities(jvmti_env, &capabilities);
118140
if (err != JVMTI_ERROR_NONE) {
@@ -121,7 +143,9 @@ decomp003(agentEnv * _env, char * args)
121143
}
122144

123145
memset(&callbacks, 0, sizeof(jvmtiEventCallbacks));
124-
callbacks.SingleStep = cbSingleStep;
146+
if (singleStep) {
147+
callbacks.SingleStep = cbSingleStep;
148+
}
125149
callbacks.Exception = cbException;
126150
callbacks.ExceptionCatch = cbExceptionCatch;
127151
err = (*jvmti_env)->SetEventCallbacks(jvmti_env, &callbacks, sizeof(jvmtiEventCallbacks));
@@ -141,10 +165,12 @@ Java_com_ibm_jvmti_tests_decompResolveFrame_decomp003_startStepping(JNIEnv *jni_
141165
JVMTI_ACCESS_FROM_AGENT(env);
142166
jvmtiError err = JVMTI_ERROR_NONE;
143167

144-
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL);
145-
if ( err != JVMTI_ERROR_NONE ) {
146-
error(env, err, "Failed to enable step event");
147-
return JNI_FALSE;
168+
if (singleStep && !stepInCatch) {
169+
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL);
170+
if ( err != JVMTI_ERROR_NONE ) {
171+
error(env, err, "Failed to enable step event");
172+
return JNI_FALSE;
173+
}
148174
}
149175
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, thread);
150176
if (JVMTI_ERROR_NONE != err) {
@@ -161,10 +187,12 @@ Java_com_ibm_jvmti_tests_decompResolveFrame_decomp003_stopStepping(JNIEnv *jni_e
161187
JVMTI_ACCESS_FROM_AGENT(env);
162188
jvmtiError err = JVMTI_ERROR_NONE;
163189

164-
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL);
165-
if ( err != JVMTI_ERROR_NONE ) {
166-
error(env, err, "Failed to disable step event failed");
167-
return JNI_FALSE;
190+
if (singleStep) {
191+
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL);
192+
if ( err != JVMTI_ERROR_NONE ) {
193+
error(env, err, "Failed to disable step event failed");
194+
return JNI_FALSE;
195+
}
168196
}
169197
err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, thread);
170198
if (JVMTI_ERROR_NONE != err) {

test/functional/cmdLineTests/jvmtitests/decompilationtests.xml

+21-1
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,31 @@
4545
<return type="success" value="0"/>
4646
</test>
4747

48-
<test id="decomp003">
48+
<test id="decomp003-XINT">
49+
<command>$EXE$ $JVM_OPTS$ -Xint $AGENTLIB$=test:decomp003 -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
50+
<return type="success" value="0"/>
51+
</test>
52+
53+
<test id="decomp003-NON-FSD">
54+
<command>$EXE$ $JVM_OPTS$ -Xjit:count=0,limit={*.jit*},tryToInline={*.jit*} $AGENTLIB$=test:decomp003,args:nostep -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
55+
<return type="success" value="0"/>
56+
</test>
57+
58+
<test id="decomp003-FSD-NO-DECOMP">
59+
<command>$EXE$ $JVM_OPTS$ -Xjit:count=0,limit={*.jit*},tryToInline={*.jit*},forcefullspeeddebug $AGENTLIB$=test:decomp003,args:nostep -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
60+
<return type="success" value="0"/>
61+
</test>
62+
63+
<test id="decomp003-FSD-EXISTING-DECOMP">
4964
<command>$EXE$ $JVM_OPTS$ -Xjit:count=0,limit={*.jit*},tryToInline={*.jit*} $AGENTLIB$=test:decomp003 -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
5065
<return type="success" value="0"/>
5166
</test>
5267

68+
<test id="decomp003-FSD-DECOMP-DURING-EVENT">
69+
<command>$EXE$ $JVM_OPTS$ -Xjit:count=0,limit={*.jit*},tryToInline={*.jit*} $AGENTLIB$=test:decomp003,args:stepincatch -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
70+
<return type="success" value="0"/>
71+
</test>
72+
5373
<test id="decomp004">
5474
<command>$EXE$ $JVM_OPTS$ -Xjit:count=0,limit={*.jit*} $AGENTLIB$=test:decomp004 -cp $Q$$JAR$$Q$ $TESTRUNNER$</command>
5575
<return type="success" value="0"/>

0 commit comments

Comments
 (0)