Merge "debuggerd: prepare to abandon ship^Wgdb."
This commit is contained in:
commit
15ab143bea
3 changed files with 23 additions and 16 deletions
|
@ -391,7 +391,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
// There appears to be a bug in the kernel where our death causes SIGHUP to
|
||||
// be sent to our process group if we exit while it has stopped jobs (e.g.
|
||||
// because of wait_for_gdb). Use setsid to create a new process group to
|
||||
// because of wait_for_debugger). Use setsid to create a new process group to
|
||||
// avoid hitting this.
|
||||
setsid();
|
||||
|
||||
|
@ -548,15 +548,17 @@ int main(int argc, char** argv) {
|
|||
fork_exit_write.reset();
|
||||
|
||||
// Defer the message until later, for readability.
|
||||
bool wait_for_gdb = android::base::GetBoolProperty("debug.debuggerd.wait_for_gdb", false);
|
||||
bool wait_for_debugger = android::base::GetBoolProperty(
|
||||
"debug.debuggerd.wait_for_debugger",
|
||||
android::base::GetBoolProperty("debug.debuggerd.wait_for_gdb", false));
|
||||
if (siginfo.si_signo == BIONIC_SIGNAL_DEBUGGER) {
|
||||
wait_for_gdb = false;
|
||||
wait_for_debugger = false;
|
||||
}
|
||||
|
||||
// Detach from all of our attached threads before resuming.
|
||||
for (const auto& [tid, thread] : thread_info) {
|
||||
int resume_signal = thread.signo == BIONIC_SIGNAL_DEBUGGER ? 0 : thread.signo;
|
||||
if (wait_for_gdb) {
|
||||
if (wait_for_debugger) {
|
||||
resume_signal = 0;
|
||||
if (tgkill(target_process, tid, SIGSTOP) != 0) {
|
||||
PLOG(WARNING) << "failed to send SIGSTOP to " << tid;
|
||||
|
@ -641,12 +643,12 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (wait_for_gdb) {
|
||||
if (wait_for_debugger) {
|
||||
// Use ALOGI to line up with output from engrave_tombstone.
|
||||
ALOGI(
|
||||
"***********************************************************\n"
|
||||
"* Process %d has been suspended while crashing.\n"
|
||||
"* To attach gdbserver and start gdb, run this on the host:\n"
|
||||
"* To attach the debugger, run this on the host:\n"
|
||||
"*\n"
|
||||
"* gdbclient.py -p %d\n"
|
||||
"*\n"
|
||||
|
|
|
@ -69,7 +69,7 @@ using android::base::unique_fd;
|
|||
#define ARCH_SUFFIX ""
|
||||
#endif
|
||||
|
||||
constexpr char kWaitForGdbKey[] = "debug.debuggerd.wait_for_gdb";
|
||||
constexpr char kWaitForDebuggerKey[] = "debug.debuggerd.wait_for_debugger";
|
||||
|
||||
#define TIMEOUT(seconds, expr) \
|
||||
[&]() { \
|
||||
|
@ -157,7 +157,7 @@ static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, uniq
|
|||
class CrasherTest : public ::testing::Test {
|
||||
public:
|
||||
pid_t crasher_pid = -1;
|
||||
bool previous_wait_for_gdb;
|
||||
bool previous_wait_for_debugger;
|
||||
unique_fd crasher_pipe;
|
||||
unique_fd intercept_fd;
|
||||
|
||||
|
@ -178,8 +178,13 @@ class CrasherTest : public ::testing::Test {
|
|||
};
|
||||
|
||||
CrasherTest::CrasherTest() {
|
||||
previous_wait_for_gdb = android::base::GetBoolProperty(kWaitForGdbKey, false);
|
||||
android::base::SetProperty(kWaitForGdbKey, "0");
|
||||
previous_wait_for_debugger = android::base::GetBoolProperty(kWaitForDebuggerKey, false);
|
||||
android::base::SetProperty(kWaitForDebuggerKey, "0");
|
||||
|
||||
// Clear the old property too, just in case someone's been using it
|
||||
// on this device. (We only document the new name, but we still support
|
||||
// the old name so we don't break anyone's existing setups.)
|
||||
android::base::SetProperty("debug.debuggerd.wait_for_gdb", "0");
|
||||
}
|
||||
|
||||
CrasherTest::~CrasherTest() {
|
||||
|
@ -189,7 +194,7 @@ CrasherTest::~CrasherTest() {
|
|||
TEMP_FAILURE_RETRY(waitpid(crasher_pid, &status, WUNTRACED));
|
||||
}
|
||||
|
||||
android::base::SetProperty(kWaitForGdbKey, previous_wait_for_gdb ? "1" : "0");
|
||||
android::base::SetProperty(kWaitForDebuggerKey, previous_wait_for_debugger ? "1" : "0");
|
||||
}
|
||||
|
||||
void CrasherTest::StartIntercept(unique_fd* output_fd, DebuggerdDumpType intercept_type) {
|
||||
|
@ -734,9 +739,9 @@ TEST_F(CrasherTest, intercept_timeout) {
|
|||
AssertDeath(SIGABRT);
|
||||
}
|
||||
|
||||
TEST_F(CrasherTest, wait_for_gdb) {
|
||||
if (!android::base::SetProperty(kWaitForGdbKey, "1")) {
|
||||
FAIL() << "failed to enable wait_for_gdb";
|
||||
TEST_F(CrasherTest, wait_for_debugger) {
|
||||
if (!android::base::SetProperty(kWaitForDebuggerKey, "1")) {
|
||||
FAIL() << "failed to enable wait_for_debugger";
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ static void create_vm_process() {
|
|||
|
||||
// There appears to be a bug in the kernel where our death causes SIGHUP to
|
||||
// be sent to our process group if we exit while it has stopped jobs (e.g.
|
||||
// because of wait_for_gdb). Use setsid to create a new process group to
|
||||
// because of wait_for_debugger). Use setsid to create a new process group to
|
||||
// avoid hitting this.
|
||||
setsid();
|
||||
|
||||
|
@ -600,7 +600,7 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
|
|||
// starting to dump right before our death.
|
||||
pthread_mutex_unlock(&crash_mutex);
|
||||
} else {
|
||||
// Resend the signal, so that either gdb or the parent's waitpid sees it.
|
||||
// Resend the signal, so that either the debugger or the parent's waitpid sees it.
|
||||
resend_signal(info);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue