diff options
| author | 2015-05-26 13:00:34 +0000 | |
|---|---|---|
| committer | 2015-05-26 13:00:34 +0000 | |
| commit | 092a5656937a319449346e8c356f3f4c2870d81c (patch) | |
| tree | 4937b3818d393b05e7461a0dc98c0b483402f475 | |
| parent | 8a8d8252f52bec14a8fe2b6f88e1f184c63cf351 (diff) | |
| parent | de48aa6708a3d5dacf7db3d64965e23261fb15d3 (diff) | |
Merge "JDWP: fix breakpoint on catch statement"
| -rw-r--r-- | runtime/debugger.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 0eb7f2b855..ef1aa6a98c 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -2806,7 +2806,27 @@ void Dbg::PostLocationEvent(mirror::ArtMethod* m, int dex_pc, mirror::Object* th JDWP::EventLocation location; SetEventLocation(&location, m, dex_pc); + // We need to be sure no exception is pending when calling JdwpState::PostLocationEvent. + // This is required to be able to call JNI functions to create JDWP ids. To achieve this, + // we temporarily clear the current thread's exception (if any) and will restore it after + // the call. + // Note: the only way to get a pending exception here is to suspend on a move-exception + // instruction. + Thread* const self = Thread::Current(); + StackHandleScope<1> hs(self); + Handle<mirror::Throwable> pending_exception(hs.NewHandle(self->GetException())); + self->ClearException(); + if (kIsDebugBuild && pending_exception.Get() != nullptr) { + const DexFile::CodeItem* code_item = location.method->GetCodeItem(); + const Instruction* instr = Instruction::At(&code_item->insns_[location.dex_pc]); + CHECK_EQ(Instruction::MOVE_EXCEPTION, instr->Opcode()); + } + gJdwpState->PostLocationEvent(&location, this_object, event_flags, return_value); + + if (pending_exception.Get() != nullptr) { + self->SetException(pending_exception.Get()); + } } void Dbg::PostFieldAccessEvent(mirror::ArtMethod* m, int dex_pc, |