Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 96535 invoked from network); 21 Sep 2006 19:03:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Sep 2006 19:03:27 -0000 Received: (qmail 42786 invoked by uid 500); 21 Sep 2006 19:03:27 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 42763 invoked by uid 500); 21 Sep 2006 19:03:27 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 42752 invoked by uid 99); 21 Sep 2006 19:03:27 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Sep 2006 12:03:27 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=geirm@apache.org; spf=permerror X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received-SPF: error (idunn.apache.osuosl.org: domain apache.org from 140.211.166.113 cause and error) Received: from [140.211.166.113] ([140.211.166.113:59272] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 8B/F1-03726-EF1E2154 for ; Thu, 21 Sep 2006 12:03:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 347921A981A; Thu, 21 Sep 2006 12:03:24 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r448633 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore: include/jvmti_internal.h src/exception/exceptions_jit.cpp src/jit/ini.cpp src/jvmti/jvmti_break.cpp src/jvmti/jvmti_event.cpp src/jvmti/jvmti_step.cpp Date: Thu, 21 Sep 2006 19:03:23 -0000 To: harmony-commits@incubator.apache.org From: geirm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060921190324.347921A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: geirm Date: Thu Sep 21 12:03:23 2006 New Revision: 448633 URL: http://svn.apache.org/viewvc?view=rev&rev=448633 Log: HARMONY-1490 Fixes for SingleStep implementation. Corrected phase, state structure, addded m2n transition Tested on Ubuntu 6. Note that tests don't actually work to show new functionality, but as HARMONY-1507 does fix this, I'll commit and we'll move forward. Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h Thu Sep 21 12:03:23 2006 @@ -97,7 +97,6 @@ struct JVMTISingleStepState { - bool enabled; BreakPoint **predicted_breakpoints; unsigned predicted_bp_count; }; Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Thu Sep 21 12:03:23 2006 @@ -219,7 +219,7 @@ if (ti->isEnabled() && ti->is_single_step_enabled()) { VM_thread *vm_thread = p_TLS_vmthread; - if (vm_thread->ss_state->enabled) + if (NULL != vm_thread->ss_state) { LMAutoUnlock lock(&ti->brkpntlst_lock); jvmti_remove_single_step_breakpoints(ti, vm_thread); @@ -262,10 +262,11 @@ si_set_ip(si, handler->get_handler_ip(), false); // Start single step in exception handler - if (ti->isEnabled() && ti->is_single_step_enabled()) + if (ti->isEnabled() && ti->is_single_step_enabled() && + ti->getPhase() == JVMTI_PHASE_LIVE) { VM_thread *vm_thread = p_TLS_vmthread; - if (vm_thread->ss_state->enabled) + if (NULL != vm_thread->ss_state) { LMAutoUnlock lock(&ti->brkpntlst_lock); Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp Thu Sep 21 12:03:23 2006 @@ -38,10 +38,11 @@ assert(NULL != VM_Global_State::loader_env->em_interface->ExecuteMethod); DebugUtilsTI *ti = VM_Global_State::loader_env->TI; - if (ti->isEnabled() && ti->is_single_step_enabled()) + if (ti->isEnabled() && ti->is_single_step_enabled() && + ti->getPhase() == JVMTI_PHASE_LIVE) { VM_thread *vm_thread = p_TLS_vmthread; - if (vm_thread->ss_state->enabled) + if (NULL != vm_thread->ss_state) { // Start single stepping a new Java method LMAutoUnlock lock(&ti->brkpntlst_lock); Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp Thu Sep 21 12:03:23 2006 @@ -33,6 +33,8 @@ #include "suspend_checker.h" #include "jit_intf_cpp.h" #include "encoder.h" +#include "m2n.h" + #define INSTRUMENTATION_BYTE_HLT 0xf4 // HLT instruction #define INSTRUMENTATION_BYTE_CLI 0xfa // CLI instruction @@ -143,7 +145,7 @@ TRACE2("jvmti.break", "BREAKPOINT occured, location = " << native_location); DebugUtilsTI *ti = VM_Global_State::loader_env->TI; - if (!ti->isEnabled()) + if (!ti->isEnabled() || ti->getPhase() != JVMTI_PHASE_LIVE) return false; ti->brkpntlst_lock._lock(); @@ -157,8 +159,12 @@ assert(ti->isEnabled()); assert(!interpreter_enabled()); + M2nFrame *m2nf = m2n_push_suspended_frame(regs); + + hythread_t h_thread = hythread_self(); + jthread j_thread = jthread_get_java_thread(h_thread); ObjectHandle hThread = oh_allocate_local_handle(); - hThread->object = (Java_java_lang_Thread *)jthread_get_java_thread(hythread_self())->object; + hThread->object = (Java_java_lang_Thread *)j_thread->object; tmn_suspend_enable(); void *id = bp->id; @@ -173,15 +179,16 @@ if (ti->is_single_step_enabled()) { VM_thread *vm_thread = p_TLS_vmthread; - if (vm_thread->ss_state->enabled) + if (NULL != vm_thread->ss_state) { - JVMTISingleStepState *ss_state = vm_thread->ss_state; - for(unsigned iii = 0; iii < ss_state->predicted_bp_count; iii++) + for(unsigned iii = 0; NULL != vm_thread->ss_state && + iii < vm_thread->ss_state->predicted_bp_count; iii++) { - if (ss_state->predicted_breakpoints[iii]->native_location == + if (vm_thread->ss_state->predicted_breakpoints[iii]->native_location == native_location) { - ss_breakpoint = ss_state->predicted_breakpoints[iii]; + ss_breakpoint = + vm_thread->ss_state->predicted_breakpoints[iii]; TIEnv *ti_env = ti->getEnvironments(); TIEnv *next_env; @@ -232,12 +239,17 @@ } } } + // Reinitialize breakpoint after SingleStep because this + // breakpoint could have been deleted inside of callback + // if agent terminated single step + bp = ti->find_first_bpt(native_location); } } + // Send events for all normally set breakpoints for this location // if there are any - do + while (bp) { TIEnv *env = bp->env; jlocation location = bp->location; @@ -245,9 +257,12 @@ BreakPoint *next_bp = ti->find_next_bpt(bp, native_location); if (bp == ss_breakpoint) + { // Don't send breakpoint event for breakpoint which was // actually SingleStep breakpoint + bp = next_bp; continue; + } if (env->global_events[JVMTI_EVENT_BREAKPOINT - JVMTI_MIN_EVENT_TYPE_VAL]) { @@ -295,7 +310,7 @@ } bp = next_bp; - } while(bp); + } // Now we need to return back to normal code execution, it is // necessary to execute the original instruction The idea is to @@ -386,16 +401,16 @@ if (ti->is_single_step_enabled()) { VM_thread *vm_thread = p_TLS_vmthread; - if (vm_thread->ss_state->enabled) + if (NULL != vm_thread->ss_state) { - jvmti_remove_single_step_breakpoints(ti, vm_thread); - jvmti_StepLocation *locations; unsigned locations_count; jvmti_SingleStepLocation(vm_thread, (Method *)ss_breakpoint->method, (unsigned)ss_breakpoint->location, &locations, &locations_count); + jvmti_remove_single_step_breakpoints(ti, vm_thread); + jvmtiError UNREF errorCode = jvmti_set_single_step_breakpoints( ti, vm_thread, locations, locations_count); assert(JVMTI_ERROR_NONE == errorCode); @@ -406,6 +421,9 @@ tmn_suspend_disable(); oh_discard_local_handle(hThread); + + m2n_set_last_frame(m2n_get_previous_frame(m2nf)); + STD_FREE(m2nf); return true; } Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Thu Sep 21 12:03:23 2006 @@ -1551,7 +1551,7 @@ { process_jvmti_event(JVMTI_EVENT_THREAD_START, 0, 0); - if (ti->is_single_step_enabled()) + if (ti->is_single_step_enabled() && ti->getPhase() == JVMTI_PHASE_LIVE) { // Init single step state for the thread VM_thread *vm_thread = p_TLS_vmthread; @@ -1562,7 +1562,6 @@ vm_thread->ss_state->predicted_breakpoints = NULL; vm_thread->ss_state->predicted_bp_count = 0; - vm_thread->ss_state->enabled = true; } } else @@ -1576,8 +1575,8 @@ LMAutoUnlock lock(&ti->brkpntlst_lock); jvmti_remove_single_step_breakpoints(ti, vm_thread); - vm_thread->ss_state->enabled = false; _deallocate((unsigned char *)vm_thread->ss_state); + vm_thread->ss_state = NULL; } } } Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp?view=diff&rev=448633&r1=448632&r2=448633 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp Thu Sep 21 12:03:23 2006 @@ -414,16 +414,23 @@ { ASSERT_NO_INTERPRETER; + *count = 0; // create stack iterator, current stack frame should be native StackIterator *si = si_create_from_native(thread); si_transfer_all_preserved_registers(si); assert(si_is_native(si)); // get previous stack frame, it should be java frame si_goto_previous(si); + + if (si_is_past_end(si)) + { + si_free(si); + return JVMTI_ERROR_NONE; + } + assert(!si_is_native(si)); // get previous stack frame si_goto_previous(si); - *count = 0; if (!si_is_native(si)) { // stack frame is java frame, get frame method and location uint16 bc = 0; @@ -483,9 +490,6 @@ vm_thread->ss_state->predicted_breakpoints = NULL; vm_thread->ss_state->predicted_bp_count = 0; - vm_thread->ss_state->enabled = true; - - vm_thread->ss_state->enabled = true; jvmti_StepLocation *locations; unsigned locations_number; @@ -537,8 +541,8 @@ { VM_thread *vm_thread = get_vm_thread(ht); jvmti_remove_single_step_breakpoints(this, vm_thread); - vm_thread->ss_state->enabled = false; _deallocate((unsigned char *)vm_thread->ss_state); + vm_thread->ss_state = NULL; } single_step_enabled = false;