Implement JDWP StackFrame.ThisObject.

I found a way to test this too.

Change-Id: Ia9451c97d5b4269f63c6b8d75f145583db7dfff5
diff --git a/src/debugger.cc b/src/debugger.cc
index 98d501c..3a6c154 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -152,6 +152,7 @@
 }
 
 static JDWP::JdwpTag TagFromClass(Class* c) {
+  CHECK(c != NULL);
   if (c->IsArrayClass()) {
     return JDWP::JT_ARRAY;
   }
@@ -574,11 +575,6 @@
   return true;
 }
 
-const char* Dbg::GetObjectTypeName(JDWP::ObjectId objectId) {
-  UNIMPLEMENTED(FATAL);
-  return NULL;
-}
-
 uint8_t Dbg::GetObjectTag(JDWP::ObjectId objectId) {
   Object* o = gRegistry->Get<Object*>(objectId);
   return TagFromObject(o);
@@ -1290,8 +1286,18 @@
 }
 
 bool Dbg::GetThisObject(JDWP::ObjectId threadId, JDWP::FrameId frameId, JDWP::ObjectId* pThisId) {
-  UNIMPLEMENTED(FATAL);
-  return false;
+  Method** sp = reinterpret_cast<Method**>(frameId);
+  Frame f;
+  f.SetSP(sp);
+  uint16_t reg = DemangleSlot(0, f);
+  Method* m = f.GetMethod();
+
+  Object* o = NULL;
+  if (!m->IsNative() && !m->IsStatic()) {
+    o = reinterpret_cast<Object*>(f.GetVReg(m, reg));
+  }
+  *pThisId = gRegistry->Add(o);
+  return true;
 }
 
 void Dbg::GetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, JDWP::JdwpTag tag, uint8_t* buf, size_t width) {