Switch to non debuggable only if entry/exit stubs are not required

We used to switch to non-debuggable at the end of method tracing or when
jvmti event is being detached without any further checks. When there are
multiple instrumentation agents active at the same time (for ex: tracing
+ debugger) this might mean we switch the state while entry / exit stubs
are still needed by other agent. Fix method tracing and jvmti detach to
first remove the instrumentation keys added by the agent and then check
to see if entry / exit stubs are needed for some other reason before
switching the runtime state.

Bug: 206029744
Test: art/test.py

Change-Id: I71b55ec109d84d8559f85eede6ccf1f45d5b72dd
4 files changed