Add update_debugger_support for x86 and fix ModBasket.

Made a constructor for struct ModBasket rather than using memset(0).
This was causing problems when setting the std::string className field
on the host.

Change-Id: Ie8fa08d0c9f01b029db88c8a309e54283b00b497
diff --git a/src/jdwp/jdwp_event.cc b/src/jdwp/jdwp_event.cc
index 8b3964a..8be3451 100644
--- a/src/jdwp/jdwp_event.cc
+++ b/src/jdwp/jdwp_event.cc
@@ -107,6 +107,9 @@
  * The rest will be zeroed.
  */
 struct ModBasket {
+  ModBasket() : pLoc(NULL), threadId(0), classId(0), excepClassId(0),
+                caught(false), field(0), thisPtr(0) { }
+
   const JdwpLocation* pLoc;           /* LocationOnly */
   std::string         className;      /* ClassMatch/ClassExclude */
   ObjectId            threadId;       /* ThreadOnly */
@@ -720,7 +723,6 @@
 bool JdwpState::PostLocationEvent(const JdwpLocation* pLoc, ObjectId thisPtr, int eventFlags) {
   ModBasket basket;
 
-  memset(&basket, 0, sizeof(basket));
   basket.pLoc = pLoc;
   basket.classId = pLoc->class_id;
   basket.thisPtr = thisPtr;
@@ -821,7 +823,6 @@
   }
 
   ModBasket basket;
-  memset(&basket, 0, sizeof(basket));
   basket.threadId = threadId;
 
   ExpandBuf* pReq = NULL;
@@ -898,7 +899,6 @@
                               const JdwpLocation* pCatchLoc, ObjectId thisPtr) {
   ModBasket basket;
 
-  memset(&basket, 0, sizeof(basket));
   basket.pLoc = pThrowLoc;
   basket.classId = pThrowLoc->class_id;
   basket.threadId = Dbg::GetThreadSelfId();
@@ -973,7 +973,6 @@
                                  int status) {
   ModBasket basket;
 
-  memset(&basket, 0, sizeof(basket));
   basket.classId = refTypeId;
   basket.threadId = Dbg::GetThreadSelfId();
   basket.className = Dbg::GetClassName(basket.classId);
diff --git a/src/oat/runtime/x86/oat_support_entrypoints_x86.cc b/src/oat/runtime/x86/oat_support_entrypoints_x86.cc
index a3c845e..a555c3d 100644
--- a/src/oat/runtime/x86/oat_support_entrypoints_x86.cc
+++ b/src/oat/runtime/x86/oat_support_entrypoints_x86.cc
@@ -34,6 +34,7 @@
 
 // Debug entrypoints.
 extern void DebugMe(AbstractMethod* method, uint32_t info);
+extern "C" void art_update_debugger(void*, void*, int32_t, void*);
 
 // DexCache entrypoints.
 extern "C" void* art_initialize_static_storage_from_code(uint32_t, void*);
@@ -122,6 +123,11 @@
 extern "C" void art_throw_null_pointer_exception_from_code();
 extern "C" void art_throw_stack_overflow_from_code(void*);
 
+// Instrumentation entrypoints.
+extern "C" void art_instrumentation_entry_from_code(void*);
+extern "C" void art_instrumentation_exit_from_code();
+extern "C" void art_deoptimize();
+
 void InitEntryPoints(EntryPoints* points) {
   // Alloc
   points->pAllocArrayFromCode = art_alloc_array_from_code;
@@ -229,20 +235,21 @@
   points->pThrowStackOverflowFromCode = art_throw_stack_overflow_from_code;
 };
 
-void ChangeDebuggerEntryPoint(EntryPoints*, bool) {
-  UNIMPLEMENTED(FATAL);
+void ChangeDebuggerEntryPoint(EntryPoints* points, bool enabled) {
+  points->pUpdateDebuggerFromCode = (enabled ? art_update_debugger : NULL);
 }
 
 uintptr_t GetInstrumentationExitPc() {
-  return 0;
+  return reinterpret_cast<uintptr_t>(art_instrumentation_exit_from_code);
 }
 
 uintptr_t GetDeoptimizationEntryPoint() {
-  return 0;
+  UNIMPLEMENTED(FATAL);
+  return reinterpret_cast<uintptr_t>(art_deoptimize);
 }
 
 void* GetInstrumentationEntryPoint() {
-  return NULL;
+  return reinterpret_cast<void*>(art_instrumentation_entry_from_code);
 }
 
 }  // namespace art
diff --git a/src/oat/runtime/x86/runtime_support_x86.S b/src/oat/runtime/x86/runtime_support_x86.S
index 558500d..1d24606 100644
--- a/src/oat/runtime/x86/runtime_support_x86.S
+++ b/src/oat/runtime/x86/runtime_support_x86.S
@@ -374,6 +374,17 @@
 TWO_ARG_DOWNCALL art_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO
 TWO_ARG_DOWNCALL art_initialize_type_and_verify_access_from_code, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO
 
+DEFINE_FUNCTION art_update_debugger
+    mov  %eax, %ebx               // stash away eax so that it's saved as if it were an argument
+    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
+    pushl %esp                    // pass arg2 (sp)
+    pushl %fs:THREAD_SELF_OFFSET  // pass Thread::Current()
+    pushl %edx                    // pass arg0 (dex pc)
+    call SYMBOL(artUpdateDebuggerFromCode) // artUpdateDebuggerFromCode(int32_t, Thread*, Method**)
+    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
+    mov  %ebx, %eax               // restore original eax
+    ret
+
 DEFINE_FUNCTION art_get_and_clear_exception
     subl LITERAL(8), %esp         // alignment padding
     pushl %fs:THREAD_SELF_OFFSET  // pass Thread::Current()
@@ -734,6 +745,14 @@
     addl LITERAL(44), %esp        // pop arguments
     RETURN_OR_DELIVER_PENDING_EXCEPTION    // return or deliver exception
 
+DEFINE_FUNCTION art_instrumentation_entry_from_code
+    ret
+DEFINE_FUNCTION art_instrumentation_exit_from_code
+    ret
+
+DEFINE_FUNCTION art_deoptimize
+    ret
+
     /*
      * String's indexOf.
      *
@@ -836,5 +855,4 @@
 END_MACRO
 
     // TODO: implement these!
-UNIMPLEMENTED art_update_debugger
 UNIMPLEMENTED art_memcmp16