ART: Clean up API after change 102631

This adds an abort_on_error parameter to GetCurrentMethod, which is
by default true. This restores all previous behavior, except for
monitor installation, where it follows 101639.

Bug: 16556938

(cherry picked from commit 6ec8ebd178ed39aa09e4c7fad194900114c4121a)

Change-Id: I2dee19d30674f2ffda33b3dc963e12470f39edb9
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index e86b537..e7e5fe4 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -166,7 +166,9 @@
   bool success = GetObject()->CasLockWordWeakSequentiallyConsistent(lw, fat);
   // Lock profiling.
   if (success && owner_ != nullptr && lock_profiling_threshold_ != 0) {
-    locking_method_ = owner_->GetCurrentMethod(&locking_dex_pc_);
+    // Do not abort on dex pc errors. This can easily happen when we want to dump a stack trace on
+    // abort.
+    locking_method_ = owner_->GetCurrentMethod(&locking_dex_pc_, false);
   }
   return success;
 }
diff --git a/runtime/thread.cc b/runtime/thread.cc
index e5f7aa4..3c69c01 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1972,10 +1972,10 @@
 // Note: this visitor may return with a method set, but dex_pc_ being DexFile:kDexNoIndex. This is
 //       so we don't abort in a special situation (thinlocked monitor) when dumping the Java stack.
 struct CurrentMethodVisitor FINAL : public StackVisitor {
-  CurrentMethodVisitor(Thread* thread, Context* context, bool fail_on_error)
+  CurrentMethodVisitor(Thread* thread, Context* context, bool abort_on_error)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
       : StackVisitor(thread, context), this_object_(nullptr), method_(nullptr), dex_pc_(0),
-        fail_on_error_(fail_on_error) {}
+        abort_on_error_(abort_on_error) {}
   bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     mirror::ArtMethod* m = GetMethod();
     if (m->IsRuntimeMethod()) {
@@ -1986,17 +1986,17 @@
       this_object_ = GetThisObject();
     }
     method_ = m;
-    dex_pc_ = GetDexPc(fail_on_error_);
+    dex_pc_ = GetDexPc(abort_on_error_);
     return false;
   }
   mirror::Object* this_object_;
   mirror::ArtMethod* method_;
   uint32_t dex_pc_;
-  const bool fail_on_error_;
+  const bool abort_on_error_;
 };
 
-mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const {
-  CurrentMethodVisitor visitor(const_cast<Thread*>(this), nullptr, false);
+mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc, bool abort_on_error) const {
+  CurrentMethodVisitor visitor(const_cast<Thread*>(this), nullptr, abort_on_error);
   visitor.WalkStack(false);
   if (dex_pc != nullptr) {
     *dex_pc = visitor.dex_pc_;
diff --git a/runtime/thread.h b/runtime/thread.h
index 22292ff..f132282 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -321,7 +321,9 @@
     tlsPtr_.long_jump_context = context;
   }
 
-  mirror::ArtMethod* GetCurrentMethod(uint32_t* dex_pc) const
+  // Get the current method and dex pc. If there are errors in retrieving the dex pc, this will
+  // abort the runtime iff abort_on_error is true.
+  mirror::ArtMethod* GetCurrentMethod(uint32_t* dex_pc, bool abort_on_error = true) const
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   ThrowLocation GetCurrentLocationForThrow() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);