Make StartDebugger the last thing in InitNonZygoteOrPostFork again
StartDebugger should be the last thing in InitNonZygoteOrPostFork
since it is allowed to either suspend until there is a debugger
connection or allow concurrent debugger actions to start taking place.
Doing any initialization after it's called is therefor dangerous.
Test: adb forward tcp:12345 jdwp:`adb shell pidof com.antonioleiva.bandhookkotlin`
jdb -attach localhost:12345
Change-Id: I4d435a3d48fcbb01054d7b551d713de851077489
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index fc589e1..dbea325 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1046,12 +1046,7 @@
StartSignalCatcher();
- // Start the JDWP thread. If the command-line debugger flags specified "suspend=y",
- // this will pause the runtime (in the internal debugger implementation), so we probably want
- // this to come last.
ScopedObjectAccess soa(Thread::Current());
- GetRuntimeCallbacks()->StartDebugger();
-
if (Dbg::IsJdwpAllowed() || IsProfileableFromShell() || IsJavaDebuggable()) {
std::string err;
ScopedThreadSuspension sts(Thread::Current(), ThreadState::kNative);
@@ -1066,6 +1061,10 @@
SetJniIdType(JniIdType::kPointer);
}
}
+ // Start the JDWP thread. If the command-line debugger flags specified "suspend=y",
+ // this will pause the runtime (in the internal debugger implementation), so we probably want
+ // this to come last.
+ GetRuntimeCallbacks()->StartDebugger();
}
void Runtime::StartSignalCatcher() {