Added CheckSuspend and UpdateDebugger to interpreter loop.

Moved CheckSuspend so that the code doesn't need to be repeated in LLVM
as well.

Change-Id: I1073f82352593bf0d5f99b28d382e4687f3a0d90
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler_llvm/runtime_support_llvm.cc
index 43d1a4c..28f9335 100644
--- a/src/compiler_llvm/runtime_support_llvm.cc
+++ b/src/compiler_llvm/runtime_support_llvm.cc
@@ -86,16 +86,7 @@
 
 void art_test_suspend_from_code(Thread* thread)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-  for (;;) {
-    if (thread->ReadFlag(kCheckpointRequest)) {
-      thread->RunCheckpointFunction();
-      thread->AtomicClearFlag(kCheckpointRequest);
-    } else if (thread->ReadFlag(kSuspendRequest)) {
-      thread->FullSuspendCheck();
-    } else {
-      break;
-    }
-  }
+  CheckSuspend(thread);
 }
 
 ShadowFrame* art_push_shadow_frame_from_code(Thread* thread, ShadowFrame* new_shadow_frame,
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 18ad010..0a32f8f 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -19,6 +19,7 @@
 #include <math.h>
 
 #include "common_throws.h"
+#include "debugger.h"
 #include "dex_instruction.h"
 #include "invoke_arg_array_builder.h"
 #include "logging.h"
@@ -508,7 +509,10 @@
   const Instruction* inst = Instruction::At(insns + shadow_frame.GetDexPC());
   JValue result_register;
   while (true) {
-    shadow_frame.SetDexPC(inst->GetDexPc(insns));
+    CheckSuspend(self);
+    uint32_t dex_pc = inst->GetDexPc(insns);
+    shadow_frame.SetDexPC(dex_pc);
+    Dbg::UpdateDebugger(dex_pc, self);
     DecodedInstruction dec_insn(inst);
     const bool kTracing = false;
     if (kTracing) {
diff --git a/src/oat/runtime/support_thread.cc b/src/oat/runtime/support_thread.cc
index c33b42e..04038ab 100644
--- a/src/oat/runtime/support_thread.cc
+++ b/src/oat/runtime/support_thread.cc
@@ -15,25 +15,12 @@
  */
 
 #include "callee_save_frame.h"
+#include "runtime_support.h"
 #include "thread.h"
 #include "thread_list.h"
 
 namespace art {
 
-static void CheckSuspend(Thread* thread)
-    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-  for (;;) {
-    if (thread->ReadFlag(kCheckpointRequest)) {
-      thread->RunCheckpointFunction();
-      thread->AtomicClearFlag(kCheckpointRequest);
-    } else if (thread->ReadFlag(kSuspendRequest)) {
-      thread->FullSuspendCheck();
-    } else {
-      break;
-    }
-  }
-}
-
 void CheckSuspendFromCode(Thread* thread)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   // Called when thread->suspend_count_ != 0 on JNI return. JNI method acts as callee-save frame.
diff --git a/src/runtime_support.h b/src/runtime_support.h
index 5a5cdcd..e54e05b 100644
--- a/src/runtime_support.h
+++ b/src/runtime_support.h
@@ -280,6 +280,20 @@
   }
 }
 
+static inline void CheckSuspend(Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  for (;;) {
+    if (thread->ReadFlag(kCheckpointRequest)) {
+      thread->RunCheckpointFunction();
+      thread->AtomicClearFlag(kCheckpointRequest);
+    } else if (thread->ReadFlag(kSuspendRequest)) {
+      thread->FullSuspendCheck();
+    } else {
+      break;
+    }
+  }
+}
+
 }  // namespace art
 
 #endif  // ART_SRC_RUNTIME_SUPPORT_H_