harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
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 GMT
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;



Mime
View raw message