harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r449237 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore: include/ src/jvmti/
Date Sat, 23 Sep 2006 13:39:32 GMT
Author: geirm
Date: Sat Sep 23 06:39:31 2006
New Revision: 449237

URL: http://svn.apache.org/viewvc?view=rev&rev=449237
Log:
HARMONY-1548

I like the new infrastructure, contained in Harmony-1545, however I found
several bugs in the implementation.

- Improved insterting breakpoint interface.
- Improved trace for inserting breakpoints.
- Fixed declaration of VMBreakPoints class.
- Improved interface for breakpoints

I also added a lot of useful tracing to debug this code.

This patch also contains several fixes in parts of code unrelated to the new
infrastructure but necessary for correct SingleStep and breakpoints
functionality.

- Added check of existence of pending breakpoints after lock.
- Fixed setting single step breakpoint for Linux
- Fixed erroneous breakpoint events reporting 

Ubuntu 6 - smoke, c-unit and kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_dasm.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.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_method.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_dasm.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_dasm.h?view=diff&rev=449237&r1=449236&r2=449237
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_dasm.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_dasm.h Sat Sep 23 06:39:31
2006
@@ -32,7 +32,7 @@
 public:
 
     enum Type {
-        OPCODEERROR,
+        OPCODEERROR = 0,
         UNKNOWN,
         OTHER=UNKNOWN,
         RELATIVE_JUMP,
@@ -72,7 +72,8 @@
     };
 
     
-    InstructionDisassembler(NativeCodePtr address)
+    InstructionDisassembler(NativeCodePtr address) :
+        type(OPCODEERROR), target(0), len(0), cond_jump_type(JUMP_OVERFLOW)
     {
         disasm(address, this);
     }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?view=diff&rev=449237&r1=449236&r2=449237
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Sat Sep 23 06:39:31
2006
@@ -32,7 +32,7 @@
 
 struct Agent;
 extern Agent *current_loading_agent;
-class VmBrkptIntf;
+class VMBreakInterface;
 
 /*
  * Type that describes TI environment created by GetEnv function
@@ -46,7 +46,7 @@
     jvmtiEventCallbacks event_table;
     jvmtiExtensionEvent *extension_event_table;
     jvmtiCapabilities posessed_capabilities;
-    VmBrkptIntf *brpt_intf;
+    VMBreakInterface *brpt_intf;
     TIEnv* next;
 
     bool global_events[JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL];

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=449237&r1=449236&r2=449237
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h Sat Sep 23 06:39:31
2006
@@ -91,7 +91,7 @@
 
 struct JVMTISingleStepState
 {
-    VmBrkptIntf* predicted_breakpoints;
+    VMBreakInterface* predicted_breakpoints;
 };
 
 /*
@@ -145,8 +145,8 @@
 };
 
 typedef struct Class Class;
-class VmBreakpoints;
-struct VmBrkptRef;
+class VMBreakPoints;
+struct VMBreakPointRef;
 
 /*
  * JVMTI state of the VM
@@ -156,7 +156,7 @@
         jint agent_counter;
         Lock_Manager TIenvs_lock;
         Lock_Manager dcList_lock;
-        VmBreakpoints* vm_brpt;
+        VMBreakPoints* vm_brpt;
 
         DebugUtilsTI();
 
@@ -346,8 +346,8 @@
 jint load_agentpath(Agent *agent, const char *str, JavaVM_Internal *vm);
 
 // Breakpoints internal functions
-jvmtiError jvmti_get_next_bytecodes_stack_from_native(VM_thread *thread,
-    jvmti_StepLocation **next_step, unsigned *count, bool step_up);
+jvmtiError jvmti_get_next_bytecodes_from_native(VM_thread *thread,
+    jvmti_StepLocation **next_step, unsigned *count, bool stack_step_up);
 void jvmti_set_single_step_breakpoints(DebugUtilsTI *ti,
     VM_thread *vm_thread, jvmti_StepLocation *locations,
     unsigned locations_number);
@@ -366,6 +366,6 @@
     unsigned location, jvmti_StepLocation **next_step, unsigned *count);
 
 // Callback function for JVMTI breakpoint processing
-bool jvmti_process_breakpoint_event(VmBrkptIntf* intf, VmBrkptRef* bp_ref);
+bool jvmti_process_breakpoint_event(VMBreakInterface* intf, VMBreakPointRef* bp_ref);
 
 #endif /* _JVMTI_INTERNAL_H_ */

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp?view=diff&rev=449237&r1=449236&r2=449237
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp Sat Sep 23 06:39:31
2006
@@ -266,8 +266,9 @@
 
     // Acquire interface for breakpoint handling
     newenv->brpt_intf =
-        vm->vm_env->TI->vm_brpt->query_intf(jvmti_process_breakpoint_event,
-                                                    interpreter_enabled());
+        vm->vm_env->TI->vm_brpt->new_intf(jvmti_process_breakpoint_event,
+                                          PRIORITY_SIMPLE_BREAKPOINT,
+                                          interpreter_enabled());
 
     LMAutoUnlock lock(&vm->vm_env->TI->TIenvs_lock);
     vm->vm_env->TI->addEnvironment(newenv);
@@ -312,7 +313,7 @@
     res = _allocate( MAX_NOTIFY_LIST * sizeof(Class**),
         (unsigned char**)&notifyPrepareList );
     assert(res == JVMTI_ERROR_NONE);
-    vm_brpt = new VmBreakpoints();
+    vm_brpt = new VMBreakPoints();
     assert(vm_brpt);
     return;
 }

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=449237&r1=449236&r2=449237
==============================================================================
--- 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 Sat Sep 23
06:39:31 2006
@@ -37,12 +37,16 @@
 
 
 // Callback function for JVMTI breakpoint processing
-bool jvmti_process_breakpoint_event(VmBrkptIntf* intf, VmBrkptRef* bp_ref)
+bool jvmti_process_breakpoint_event(VMBreakInterface* intf, VMBreakPointRef* bp_ref)
 {
-    VmBrkpt* bp = bp_ref->brpt;
+    VMBreakPoint* bp = bp_ref->brpt;
     assert(bp);
 
-    TRACE2("jvmti.break", "BREAKPOINT occured: location=" << bp->location);
+    TRACE2("jvmti.break", "Process breakpoint: "
+            << class_get_name(method_get_class((Method*)bp->method)) << "."
+            << method_get_name((Method*)bp->method)
+            << method_get_descriptor((Method*)bp->method)
+            << " :" << bp->location << " :" << bp->addr);
 
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() || ti->getPhase() != JVMTI_PHASE_LIVE)
@@ -135,7 +139,11 @@
                    jmethodID method,
                    jlocation location)
 {
-    TRACE2("jvmti.break", "SetBreakpoint called, method = " << method << " ,
location = " << location);
+    TRACE2("jvmti.break", "SetBreakpoint is called for method: "
+        << class_get_name(method_get_class((Method*)method)) << "."
+        << method_get_name((Method*)method)
+        << method_get_descriptor((Method*)method)
+        << " :" << location);
     SuspendEnabledChecker sec;
 
     jvmtiError errorCode;
@@ -181,10 +189,10 @@
         return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
 
     TIEnv *p_env = (TIEnv *)env;
-    VmBrkptIntf* brpt_intf = p_env->brpt_intf;
+    VMBreakInterface* brpt_intf = p_env->brpt_intf;
     LMAutoUnlock lock(brpt_intf->get_lock());
 
-    VmBrkptRef* bp = brpt_intf->find(method, location);
+    VMBreakPointRef* bp = brpt_intf->find(method, location);
 
     if (NULL != bp)
         return JVMTI_ERROR_DUPLICATE;
@@ -202,7 +210,7 @@
         return JVMTI_ERROR_INTERNAL;
     }
 
-    TRACE2("jvmti.break", "SetBreakpoint successfull");
+    TRACE2("jvmti.break", "SetBreakpoint is successfull");
     return JVMTI_ERROR_NONE;
 }
 
@@ -219,7 +227,11 @@
                      jmethodID method,
                      jlocation location)
 {
-    TRACE2("jvmti.break", "ClearBreakpoint called, method = " << method << "
, location = " << location);
+    TRACE2("jvmti.break", "ClearBreakpoint is called for method: "
+        << class_get_name(method_get_class((Method*)method)) << "."
+        << method_get_name((Method*)method)
+        << method_get_descriptor((Method*)method)
+        << " :" << location);
     SuspendEnabledChecker sec;
     jvmtiError errorCode;
 
@@ -265,10 +277,10 @@
         return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
 
     TIEnv *p_env = (TIEnv *)env;
-    VmBrkptIntf* brpt_intf = p_env->brpt_intf;
+    VMBreakInterface* brpt_intf = p_env->brpt_intf;
     LMAutoUnlock lock(brpt_intf->get_lock());
 
-    VmBrkptRef* bp = brpt_intf->find(method, location);
+    VMBreakPointRef* bp = brpt_intf->find(method, location);
 
     if (NULL == bp)
         return JVMTI_ERROR_NOT_FOUND;
@@ -276,6 +288,6 @@
     if (!brpt_intf->remove(bp))
         return JVMTI_ERROR_INTERNAL;
 
-    TRACE2("jvmti.break", "ClearBreakpoint successfull");
+    TRACE2("jvmti.break", "ClearBreakpoint is successfull");
     return JVMTI_ERROR_NONE;
 }

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=449237&r1=449236&r2=449237
==============================================================================
--- 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 Sat Sep 23
06:39:31 2006
@@ -325,7 +325,6 @@
                 else if (JVMTI_DISABLE == mode && ti->is_single_step_enabled())
                 {
                     // Check that no environment has SingleStep enabled
-                    TRACE2("jvmti.break.ss", "SingleStep event is disabled");
                     LMAutoUnlock lock(&ti->TIenvs_lock);
                     bool disable = true;
 
@@ -344,6 +343,7 @@
 
                     if (disable)
                     {
+                        TRACE2("jvmti.break.ss", "SingleStep event is disabled");
                         jvmtiError errorCode = ti->jvmti_single_step_stop();
 
                         if (JVMTI_ERROR_NONE != errorCode)

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_method.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_method.cpp?view=diff&rev=449237&r1=449236&r2=449237
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_method.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_method.cpp Sat Sep 23
06:39:31 2006
@@ -530,14 +530,14 @@
     if (interpreter_enabled())
     {
         TIEnv *p_env = (TIEnv *)env;
-        VmBreakpoints* vm_brpt = p_env->vm->vm_env->TI->vm_brpt;
+        VMBreakPoints* vm_brpt = p_env->vm->vm_env->TI->vm_brpt;
 
         LMAutoUnlock lock(vm_brpt->get_lock());
 
         if (!vm_brpt->has_breakpoint(method))
             return JVMTI_ERROR_NONE;
 
-        for (VmBrkpt* bpt = vm_brpt->find_first(method); bpt;
+        for (VMBreakPoint* bpt = vm_brpt->find_first(method); bpt;
              bpt = vm_brpt->find_next(bpt, method))
         {
             (*bytecodes_ptr)[bpt->location] =

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=449237&r1=449236&r2=449237
==============================================================================
--- 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 Sat Sep 23 06:39:31
2006
@@ -31,8 +31,6 @@
 #include "open/jthread.h"
 #include "jvmti_break_intf.h"
 
-static JNIEnv * jvmti_test_jenv = jni_native_intf;
-
 static inline short
 jvmti_GetHalfWordValue( const unsigned char *bytecode,
                         unsigned location)
@@ -258,7 +256,7 @@
         case OPCODE_RETURN:         /* 0xb1 */
             assert( !is_wide );
             {
-                error = jvmti_get_next_bytecodes_stack_from_native( 
+                error = jvmti_get_next_bytecodes_from_native( 
                     thread, next_step, count, true );
                 assert( error == JVMTI_ERROR_NONE );
             }
@@ -382,7 +380,7 @@
 } // jvmti_SingleStepLocation
 
 static void
-jvmti_setup_jit_single_step(DebugUtilsTI *ti, VmBrkptIntf* intf,
+jvmti_setup_jit_single_step(DebugUtilsTI *ti, VMBreakInterface* intf,
                             Method* m, jlocation location)
 {
     VM_thread* vm_thread = p_TLS_vmthread;
@@ -398,12 +396,16 @@
 }
 
 // Callback function for JVMTI single step processing
-static bool jvmti_process_jit_single_step_event(VmBrkptIntf* intf, VmBrkptRef* bp_ref)
+static bool jvmti_process_jit_single_step_event(VMBreakInterface* intf, VMBreakPointRef*
bp_ref)
 {
-    VmBrkpt* bp = bp_ref->brpt;
+    VMBreakPoint* bp = bp_ref->brpt;
     assert(bp);
 
-    TRACE2("jvmti.break.ss", "Single Step occured: location=" << bp->location);
+    TRACE2("jvmti.break.ss", "SingleStep occured: "
+        << class_get_name(method_get_class((Method*)bp->method)) << "."
+        << method_get_name((Method*)bp->method)
+        << method_get_descriptor((Method*)bp->method)
+        << " :" << bp->location << " :" << bp->addr);
 
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() || ti->getPhase() != JVMTI_PHASE_LIVE)
@@ -516,23 +518,17 @@
     JVMTISingleStepState *ss_state = vm_thread->ss_state;
 
     if (NULL == ss_state->predicted_breakpoints)
-    { // Create SS breakpoints list
+    {
+        // Create SS breakpoints list
+        // Single Step must be processed earlier then Breakpoints
         ss_state->predicted_breakpoints =
-            ti->vm_brpt->query_intf(jvmti_process_jit_single_step_event, false);
+            ti->vm_brpt->new_intf(jvmti_process_jit_single_step_event,
+                PRIORITY_SINGLE_STEP_BREAKPOINT, false);
         assert(ss_state->predicted_breakpoints);
-        // Single Step must be processed earlier then Breakpoints
-        assert(BREAK_MIN_PRIORITY > BREAK_MAX_PRIORITY);
-        ss_state->predicted_breakpoints->set_priority(BREAK_MIN_PRIORITY - 1);
     }
 
     for (unsigned iii = 0; iii < locations_number; iii++)
     {
-        VmBrkptRef* ref =
-            ss_state->predicted_breakpoints->add((jmethodID)locations[iii].method,
-                                                  locations[iii].location,
-                                                  locations[iii].native_location,
-                                                  NULL);
-
         TRACE2("jvmti.break.ss", "Set single step breakpoint: "
             << class_get_name(method_get_class(locations[iii].method)) << "."
             << method_get_name(locations[iii].method)
@@ -540,6 +536,11 @@
             << " :" << locations[iii].location
             << " :" << locations[iii].native_location);
 
+        VMBreakPointRef* ref =
+            ss_state->predicted_breakpoints->add((jmethodID)locations[iii].method,
+                                                  locations[iii].location,
+                                                  locations[iii].native_location,
+                                                  NULL);
         assert(ref);
     }
 }
@@ -549,14 +550,16 @@
     // Function is always executed under global TI breakpoints lock
     JVMTISingleStepState *ss_state = vm_thread->ss_state;
 
+    TRACE2("jvmti.break.ss", "Remove single step breakpoints");
+
     if (ss_state && ss_state->predicted_breakpoints)
         ss_state->predicted_breakpoints->remove_all();
 }
 
-jvmtiError jvmti_get_next_bytecodes_stack_from_native(VM_thread *thread,
+jvmtiError jvmti_get_next_bytecodes_from_native(VM_thread *thread,
     jvmti_StepLocation **next_step,
     unsigned *count,
-    bool step_up)
+    bool stack_step_up)
 {
     ASSERT_NO_INTERPRETER;
 
@@ -575,7 +578,7 @@
     }
 
     assert(!si_is_native(si));
-    if( step_up ) {
+    if( stack_step_up ) {
         // get previous stack frame
         si_goto_previous(si);
     }
@@ -607,13 +610,13 @@
     }
     si_free(si);
     return JVMTI_ERROR_NONE;
-} // jvmti_get_next_bytecodes_stack_from_native
+} // jvmti_get_next_bytecodes_from_native
 
 jvmtiError DebugUtilsTI::jvmti_single_step_start(void)
 {
     assert(hythread_is_suspend_enabled());
 
-    VmBreakpoints* vm_brpt = VM_Global_State::loader_env->TI->vm_brpt;
+    VMBreakPoints* vm_brpt = VM_Global_State::loader_env->TI->vm_brpt;
     LMAutoUnlock lock(vm_brpt->get_lock());
 
     hythread_iterator_t threads_iterator;
@@ -651,7 +654,7 @@
         jvmti_StepLocation *locations;
         unsigned locations_number;
 
-        errorCode = jvmti_get_next_bytecodes_stack_from_native(
+        errorCode = jvmti_get_next_bytecodes_from_native(
             vm_thread, &locations, &locations_number, false);
 
         if (JVMTI_ERROR_NONE != errorCode)
@@ -676,7 +679,7 @@
 {
     assert(hythread_is_suspend_enabled());
 
-    VmBreakpoints* vm_brpt = VM_Global_State::loader_env->TI->vm_brpt;
+    VMBreakPoints* vm_brpt = VM_Global_State::loader_env->TI->vm_brpt;
     LMAutoUnlock lock(vm_brpt->get_lock());
 
     hythread_iterator_t threads_iterator;



Mime
View raw message