1 /*
2 * Copyright (c) 2003, 2017, 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 *
239 return get_frame_pops()->contains(fp);
240 }
241
242
243 class VM_GetCurrentLocation : public VM_Operation {
244 private:
245 JavaThread *_thread;
246 jmethodID _method_id;
247 int _bci;
248
249 public:
250 VM_GetCurrentLocation(JavaThread *thread) {
251 _thread = thread;
252 }
253 VMOp_Type type() const { return VMOp_GetCurrentLocation; }
254 void doit() {
255 ResourceMark rmark; // _thread != Thread::current()
256 RegisterMap rm(_thread, false);
257 // There can be a race condition between a VM_Operation reaching a safepoint
258 // and the target thread exiting from Java execution.
259 // We must recheck the last Java frame still exists.
260 if (!_thread->is_exiting() && _thread->has_last_Java_frame()) {
261 javaVFrame* vf = _thread->last_java_vframe(&rm);
262 assert(vf != NULL, "must have last java frame");
263 Method* method = vf->method();
264 _method_id = method->jmethod_id();
265 _bci = vf->bci();
266 } else {
267 // Clear current location as the target thread has no Java frames anymore.
268 _method_id = (jmethodID)NULL;
269 _bci = 0;
270 }
271 }
272 void get_current_location(jmethodID *method_id, int *bci) {
273 *method_id = _method_id;
274 *bci = _bci;
275 }
276 };
277
278 void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool enabled) {
279 assert(event_type == JVMTI_EVENT_SINGLE_STEP || event_type == JVMTI_EVENT_BREAKPOINT,
280 "must be single-step or breakpoint event");
281
282 // Current location is used to detect the following:
283 // 1) a breakpoint event followed by single-stepping to the same bci
284 // 2) single-step to a bytecode that will be transformed to a fast version
285 // We skip to avoid posting the duplicate single-stepping event.
286
287 // If single-stepping is disabled, clear current location so that
288 // single-stepping to the same method and bcp at a later time will be
289 // detected if single-stepping is enabled at that time (see 4388912).
|
1 /*
2 * Copyright (c) 2003, 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.
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 *
239 return get_frame_pops()->contains(fp);
240 }
241
242
243 class VM_GetCurrentLocation : public VM_Operation {
244 private:
245 JavaThread *_thread;
246 jmethodID _method_id;
247 int _bci;
248
249 public:
250 VM_GetCurrentLocation(JavaThread *thread) {
251 _thread = thread;
252 }
253 VMOp_Type type() const { return VMOp_GetCurrentLocation; }
254 void doit() {
255 ResourceMark rmark; // _thread != Thread::current()
256 RegisterMap rm(_thread, false);
257 // There can be a race condition between a VM_Operation reaching a safepoint
258 // and the target thread exiting from Java execution.
259 // We must recheck that the last Java frame still exists.
260 if (!_thread->is_exiting() && _thread->has_last_Java_frame()) {
261 javaVFrame* vf = _thread->last_java_vframe(&rm);
262 if (vf != NULL) {
263 Method* method = vf->method();
264 _method_id = method->jmethod_id();
265 _bci = vf->bci();
266 }
267 }
268 }
269 void get_current_location(jmethodID *method_id, int *bci) {
270 *method_id = _method_id;
271 *bci = _bci;
272 }
273 };
274
275 void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool enabled) {
276 assert(event_type == JVMTI_EVENT_SINGLE_STEP || event_type == JVMTI_EVENT_BREAKPOINT,
277 "must be single-step or breakpoint event");
278
279 // Current location is used to detect the following:
280 // 1) a breakpoint event followed by single-stepping to the same bci
281 // 2) single-step to a bytecode that will be transformed to a fast version
282 // We skip to avoid posting the duplicate single-stepping event.
283
284 // If single-stepping is disabled, clear current location so that
285 // single-stepping to the same method and bcp at a later time will be
286 // detected if single-stepping is enabled at that time (see 4388912).
|