27
27
static agentEnv * env ;
28
28
static jmethodID catchMethod = NULL ;
29
29
static jlocation catchLocation = 0 ;
30
-
30
+
31
+ static int singleStep = 1 ;
32
+ static int stepInCatch = 0 ;
33
+
31
34
static void JNICALL
32
35
cbSingleStep (jvmtiEnv * jvmti_env , JNIEnv * jni_env , jthread thread , jmethodID method , jlocation location )
33
36
{
@@ -94,14 +97,20 @@ cbExceptionCatch(jvmtiEnv *jvmti_env,
94
97
if (JVMTI_ERROR_NONE != err ) {
95
98
error (env , err , "Failed to disable exception catch event" );
96
99
}
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
+ }
97
106
}
98
107
99
108
100
109
jint JNICALL
101
110
decomp003 (agentEnv * _env , char * args )
102
111
{
103
112
JVMTI_ACCESS_FROM_AGENT (_env );
104
- jvmtiError err ;
113
+ jvmtiError err = JVMTI_ERROR_NONE ;
105
114
jvmtiEventCallbacks callbacks ;
106
115
jvmtiCapabilities capabilities ;
107
116
@@ -111,8 +120,21 @@ decomp003(agentEnv * _env, char * args)
111
120
return JNI_ERR ;
112
121
}
113
122
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
+
114
134
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
+ }
116
138
capabilities .can_generate_exception_events = 1 ;
117
139
err = (* jvmti_env )-> AddCapabilities (jvmti_env , & capabilities );
118
140
if (err != JVMTI_ERROR_NONE ) {
@@ -121,7 +143,9 @@ decomp003(agentEnv * _env, char * args)
121
143
}
122
144
123
145
memset (& callbacks , 0 , sizeof (jvmtiEventCallbacks ));
124
- callbacks .SingleStep = cbSingleStep ;
146
+ if (singleStep ) {
147
+ callbacks .SingleStep = cbSingleStep ;
148
+ }
125
149
callbacks .Exception = cbException ;
126
150
callbacks .ExceptionCatch = cbExceptionCatch ;
127
151
err = (* jvmti_env )-> SetEventCallbacks (jvmti_env , & callbacks , sizeof (jvmtiEventCallbacks ));
@@ -141,10 +165,12 @@ Java_com_ibm_jvmti_tests_decompResolveFrame_decomp003_startStepping(JNIEnv *jni_
141
165
JVMTI_ACCESS_FROM_AGENT (env );
142
166
jvmtiError err = JVMTI_ERROR_NONE ;
143
167
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
+ }
148
174
}
149
175
err = (* jvmti_env )-> SetEventNotificationMode (jvmti_env , JVMTI_ENABLE , JVMTI_EVENT_EXCEPTION , thread );
150
176
if (JVMTI_ERROR_NONE != err ) {
@@ -161,10 +187,12 @@ Java_com_ibm_jvmti_tests_decompResolveFrame_decomp003_stopStepping(JNIEnv *jni_e
161
187
JVMTI_ACCESS_FROM_AGENT (env );
162
188
jvmtiError err = JVMTI_ERROR_NONE ;
163
189
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
+ }
168
196
}
169
197
err = (* jvmti_env )-> SetEventNotificationMode (jvmti_env , JVMTI_DISABLE , JVMTI_EVENT_EXCEPTION , thread );
170
198
if (JVMTI_ERROR_NONE != err ) {
0 commit comments