Fix detaching a debugger while threads are suspended.
The interesting part of this change is in "thread_list.cc".
I've done a TODO in TagFromClass, but haven't seen it make any practical
difference in a debugger. I also tightened up the types in GetThreadStatus
while investigating the fact that we report some threads as "RUNNING, SUSPENDED",
which makes no sense until you realize that TS_RUNNING corresponds to both
our kRunnable thread state and our kNative thread state, the latter of which
may actually be a suspended thread.
I've also made us fail faster in the "address in use" jdwp failure case,
and tidied up a bunch of the capitalization in logging.
Change-Id: I0fe705791d07db31c4615addce44da4fdfbfd0d1
diff --git a/src/dalvik_system_Zygote.cc b/src/dalvik_system_Zygote.cc
index cd3f656..e3a2cdd 100644
--- a/src/dalvik_system_Zygote.cc
+++ b/src/dalvik_system_Zygote.cc
@@ -174,10 +174,7 @@
return 0;
}
-// Set Linux capability flags.
-//
-// Returns 0 on success, errno on failure.
-int SetCapabilities(int64_t permitted, int64_t effective) {
+void SetCapabilities(int64_t permitted, int64_t effective) {
#ifdef HAVE_ANDROID_OS
struct __user_cap_header_struct capheader;
struct __user_cap_data_struct capdata;
@@ -192,11 +189,9 @@
capdata.permitted = permitted;
if (capset(&capheader, &capdata) != 0) {
- return errno;
+ PLOG(FATAL) << "capset(" << permitted << ", " << effective << ") failed";
}
#endif /*HAVE_ANDROID_OS*/
-
- return 0;
}
void EnableDebugFeatures(uint32_t debug_flags) {
@@ -300,29 +295,25 @@
int err = SetGids(env, javaGids);
if (err < 0) {
- PLOG(FATAL) << "cannot setgroups()";
+ PLOG(FATAL) << "setgroups failed";
}
err = SetRLimits(env, javaRlimits);
if (err < 0) {
- PLOG(FATAL) << "cannot setrlimit()";
+ PLOG(FATAL) << "setrlimit failed";
}
err = setgid(gid);
if (err < 0) {
- PLOG(FATAL) << "cannot setgid(" << gid << ")";
+ PLOG(FATAL) << "setgid(" << gid << ") failed";
}
err = setuid(uid);
if (err < 0) {
- PLOG(FATAL) << "cannot setuid(" << uid << ")";
+ PLOG(FATAL) << "setuid(" << uid << ") failed";
}
- err = SetCapabilities(permittedCapabilities, effectiveCapabilities);
- if (err != 0) {
- PLOG(FATAL) << "cannot set capabilities ("
- << permittedCapabilities << "," << effectiveCapabilities << ")";
- }
+ SetCapabilities(permittedCapabilities, effectiveCapabilities);
// Our system thread ID, etc, has changed so reset Thread state.
self->InitAfterFork();