diff --git a/vm/interpreter/src/interpreter.cpp b/vm/interpreter/src/interpreter.cpp old mode 100644 new mode 100755 index 53dbf1a..7da148b --- a/vm/interpreter/src/interpreter.cpp +++ b/vm/interpreter/src/interpreter.cpp @@ -2547,6 +2547,8 @@ interpreter(StackFrame &frame) { vm_monitor_enter_wrapper(ml->monitor); } + bool breakpoint_processed = false; + while (true) { uint8 ip0 = *frame.ip; @@ -2563,8 +2565,10 @@ restart: } return; } - if (interpreter_ti_notification_mode + if (!breakpoint_processed && + interpreter_ti_notification_mode & INTERPRETER_TI_SINGLE_STEP_EVENT) { + breakpoint_processed = false; single_step_callback(frame); } //assert(!exn_raised()); @@ -2905,6 +2909,7 @@ #endif case OPCODE_D2L: Opcode_D2L(frame); break; case OPCODE_BREAKPOINT: ip0 = Opcode_BREAKPOINT(frame); + breakpoint_processed = true; goto restart; case OPCODE_WIDE: @@ -3234,7 +3239,7 @@ interpreterInvokeStatic(StackFrame& prev if (frame.jvmti_pop_frame == POP_FRAME_NOW) { setLastStackFrame(frame.prev); clear_current_thread_exception(); - frame.ip -= 3; + frame.prev->ip -= 3; DEBUG_TRACE(" invoke_static }}}\n"); return; } @@ -3520,7 +3525,7 @@ interpreterInvokeSpecial(StackFrame& pre if (frame.jvmti_pop_frame == POP_FRAME_NOW) { setLastStackFrame(frame.prev); clear_current_thread_exception(); - frame.ip -= 3; + frame.prev->ip -= 3; DEBUG_TRACE(" invoke_special }}}\n"); return; } diff --git a/vm/interpreter/src/interpreter_ti.cpp b/vm/interpreter/src/interpreter_ti.cpp index e31de44..ceae3dc 100644 --- a/vm/interpreter/src/interpreter_ti.cpp +++ b/vm/interpreter/src/interpreter_ti.cpp @@ -489,7 +489,6 @@ interpreter_ti_notify_frame_pop(jvmtiEnv void single_step_callback(StackFrame &frame) { uint8 ip0 = *frame.ip; - if (ip0 == OPCODE_BREAKPOINT) return; hythread_suspend_enable(); Method *method = frame.method; diff --git a/vm/vmcore/src/jvmti/jvmti_method.cpp b/vm/vmcore/src/jvmti/jvmti_method.cpp index c753d28..2a03ed8 100644 --- a/vm/vmcore/src/jvmti/jvmti_method.cpp +++ b/vm/vmcore/src/jvmti/jvmti_method.cpp @@ -34,6 +34,8 @@ #include "jvmti_interface.h" #include "suspend_checker.h" #include "jvmti_internal.h" #include "environment.h" +#include "exceptions.h" +#include "interpreter_exports.h" /* * Get Method Name (and Signature) @@ -524,19 +526,22 @@ jvmtiGetBytecodes(jvmtiEnv* env, if( err != JVMTI_ERROR_NONE ) return err; memcpy( *bytecodes_ptr, mtd->get_byte_code_addr(), *bytecode_count_ptr ); - TIEnv *p_env = (TIEnv *)env; - DebugUtilsTI *ti = p_env->vm->vm_env->TI; + if (interpreter_enabled()) + { + TIEnv *p_env = (TIEnv *)env; + DebugUtilsTI *ti = p_env->vm->vm_env->TI; - LMAutoUnlock lock(&ti->brkpntlst_lock); + LMAutoUnlock lock(&ti->brkpntlst_lock); - if (!ti->have_breakpoint(method)) - return JVMTI_ERROR_NONE; + if (!ti->have_breakpoint(method)) + return JVMTI_ERROR_NONE; - for (BreakPoint* bpt = ti->find_first_bpt(method); bpt; - bpt = ti->find_next_bpt(bpt, method)) - { - (*bytecodes_ptr)[bpt->location] = - (unsigned char)(POINTER_SIZE_INT) bpt->id; + for (BreakPoint* bpt = ti->find_first_bpt(method); bpt; + bpt = ti->find_next_bpt(bpt, method)) + { + (*bytecodes_ptr)[bpt->location] = + (unsigned char)(POINTER_SIZE_INT) bpt->id; + } } return JVMTI_ERROR_NONE; @@ -672,11 +677,17 @@ jvmtiIsMethodObsolete(jvmtiEnv* env, void jvmti_method_enter_callback(Method_Handle method) { + BEGIN_RAISE_AREA; + jvmti_process_method_entry_event(reinterpret_cast(method)); + + END_RAISE_AREA; } void jvmti_method_exit_callback(Method_Handle method, jvalue* return_value) { + BEGIN_RAISE_AREA; + Method *m = reinterpret_cast(method); jmethodID mid = reinterpret_cast(method); @@ -687,4 +698,6 @@ void jvmti_method_exit_callback(Method_H jvalue jv = { 0 }; jvmti_process_method_exit_event(mid, JNI_FALSE, jv); } + + END_RAISE_AREA; } diff --git a/vm/vmcore/src/jvmti/jvmti_stack.cpp b/vm/vmcore/src/jvmti/jvmti_stack.cpp index d7dce26..968237d 100644 --- a/vm/vmcore/src/jvmti/jvmti_stack.cpp +++ b/vm/vmcore/src/jvmti/jvmti_stack.cpp @@ -52,28 +52,27 @@ jint get_thread_stack_depth(VM_thread *t jint depth = 0; Method_Handle method = NULL; + jint skip = 0; + while (!si_is_past_end(si)) { method = si_get_method(si); if (method) + { depth += 1 + si_get_inline_depth(si); - si_goto_previous(si); - } - - jint skip = 0; - - if (method) - { - Class *clss = method_get_class(method); - assert(clss); + Class *clss = method_get_class(method); + assert(clss); - if (strcmp(method_get_name(method), "run") == 0 && - strcmp(class_get_name(clss), "java/lang/VMStart$MainThread") == 0) - { - skip = 3; + if (strcmp(method_get_name(method), "runImpl") == 0 && + strcmp(class_get_name(clss), "java/lang/VMStart$MainThread") == 0) + { + skip = 3; + } } + + si_goto_previous(si); } depth -= skip; diff --git a/vm/vmcore/src/jvmti/jvmti_watch.cpp b/vm/vmcore/src/jvmti/jvmti_watch.cpp index b7230d5..b5cce58 100644 --- a/vm/vmcore/src/jvmti/jvmti_watch.cpp +++ b/vm/vmcore/src/jvmti/jvmti_watch.cpp @@ -43,6 +43,7 @@ #include "jvmti_interface.h" #include "suspend_checker.h" #include "jvmti_internal.h" #include "environment.h" +#include "exceptions.h" enum Watch_Type @@ -311,12 +312,14 @@ void jvmti_field_access_callback(Field_H jlocation location, jobject* object) { + BEGIN_RAISE_AREA; tmn_suspend_enable(); jvmti_process_field_access_event(field, (jmethodID) method, location, object); tmn_suspend_disable(); + END_RAISE_AREA; } void jvmti_field_modification_callback(Field_Handle field, @@ -325,10 +328,12 @@ void jvmti_field_modification_callback(F jobject* object, jvalue* new_value) { + BEGIN_RAISE_AREA; tmn_suspend_enable(); jvmti_process_field_modification_event(field, (jmethodID) method, location, object, *new_value); tmn_suspend_disable(); + END_RAISE_AREA; } diff --git a/vm/vmcore/src/util/linux/signals_ia32.cpp b/vm/vmcore/src/util/linux/signals_ia32.cpp index 1886767..8510b81 100644 --- a/vm/vmcore/src/util/linux/signals_ia32.cpp +++ b/vm/vmcore/src/util/linux/signals_ia32.cpp @@ -497,9 +497,12 @@ void jvmti_jit_breakpoint_handler(int si bool handled = jvmti_send_jit_breakpoint_event(®s); if (handled) + { linux_regs_to_ucontext(uc, ®s); + return; + } - fprintf(stderr, "SIGINT in VM code.\n"); + fprintf(stderr, "SIGTRAP in VM code.\n"); linux_ucontext_to_regs(®s, uc); st_print_stack(®s); signal(signum, 0);