summaryrefslogtreecommitdiffstats
path: root/runtime/debugger.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-02-25 15:10:04 +0100
committerSebastien Hertz <shertz@google.com>2014-02-25 18:06:04 +0100
commitaaea7343831b64f4351c9abc7493ec062adfaf53 (patch)
tree9ace06bf09aecdce840d590d9673880461287bdf /runtime/debugger.cc
parentbdbc11899d04b284c0ec4b055e1a009c7034aaa5 (diff)
downloadart-aaea7343831b64f4351c9abc7493ec062adfaf53.tar.gz
art-aaea7343831b64f4351c9abc7493ec062adfaf53.tar.bz2
art-aaea7343831b64f4351c9abc7493ec062adfaf53.zip
Fix debugger disconnection crash.
Fixes a check failure where we uninstall instrumentation while we did not install it before. This happens when the JDWP thread stops with no debugger connected. Bug: 13168905 Change-Id: I83766ced79721747e5a7aaf27ce01a853ad55f03
Diffstat (limited to 'runtime/debugger.cc')
-rw-r--r--runtime/debugger.cc32
1 files changed, 18 insertions, 14 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index d3f684dc0c..9f09709a78 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -599,20 +599,24 @@ void Dbg::Disconnected() {
runtime->GetThreadList()->SuspendAll();
Thread* self = Thread::Current();
ThreadState old_state = self->SetStateUnsafe(kRunnable);
- {
- // Since we're going to disable deoptimization, we clear the deoptimization requests queue.
- // This prevent us from having any pending deoptimization request when the debugger attaches to
- // us again while no event has been requested yet.
- MutexLock mu(Thread::Current(), *Locks::deoptimization_lock_);
- gDeoptimizationRequests.clear();
- }
- runtime->GetInstrumentation()->RemoveListener(&gDebugInstrumentationListener,
- instrumentation::Instrumentation::kMethodEntered |
- instrumentation::Instrumentation::kMethodExited |
- instrumentation::Instrumentation::kDexPcMoved |
- instrumentation::Instrumentation::kExceptionCaught);
- runtime->GetInstrumentation()->DisableDeoptimization();
- gDebuggerActive = false;
+
+ // Debugger may not be active at this point.
+ if (gDebuggerActive) {
+ {
+ // Since we're going to disable deoptimization, we clear the deoptimization requests queue.
+ // This prevents us from having any pending deoptimization request when the debugger attaches
+ // to us again while no event has been requested yet.
+ MutexLock mu(Thread::Current(), *Locks::deoptimization_lock_);
+ gDeoptimizationRequests.clear();
+ }
+ runtime->GetInstrumentation()->RemoveListener(&gDebugInstrumentationListener,
+ instrumentation::Instrumentation::kMethodEntered |
+ instrumentation::Instrumentation::kMethodExited |
+ instrumentation::Instrumentation::kDexPcMoved |
+ instrumentation::Instrumentation::kExceptionCaught);
+ runtime->GetInstrumentation()->DisableDeoptimization();
+ gDebuggerActive = false;
+ }
gRegistry->Clear();
gDebuggerConnected = false;
CHECK_EQ(self->SetStateUnsafe(old_state), kRunnable);