Loading debuggerd/handler/debuggerd_handler.cpp +28 −2 Original line number Original line Diff line number Diff line Loading @@ -116,6 +116,26 @@ static void __noreturn __printflike(1, 2) fatal_errno(const char* fmt, ...) { fatal("%s: %s", buf, strerror(err)); fatal("%s: %s", buf, strerror(err)); } } static bool get_main_thread_name(char* buf, size_t len) { int fd = open("/proc/self/comm", O_RDONLY | O_CLOEXEC); if (fd == -1) { return false; } ssize_t rc = read(fd, buf, len); close(fd); if (rc == -1) { return false; } else if (rc == 0) { // Should never happen? return false; } // There's a trailing newline, replace it with a NUL. buf[rc - 1] = '\0'; return true; } /* /* * Writes a summary of the signal to the log file. We do this so that, if * Writes a summary of the signal to the log file. We do this so that, if * for some reason we're not able to contact debuggerd, there is still some * for some reason we're not able to contact debuggerd, there is still some Loading Loading @@ -188,8 +208,14 @@ static void log_signal_summary(int signum, const siginfo_t* info) { } } } } async_safe_format_log(ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s)", char main_thread_name[MAX_TASK_NAME_LEN + 1]; signum, signal_name, code_desc, addr_desc, __gettid(), thread_name); if (!get_main_thread_name(main_thread_name, sizeof(main_thread_name))) { strncpy(main_thread_name, "<unknown>", sizeof(main_thread_name)); } async_safe_format_log( ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s), pid %d (%s)", signum, signal_name, code_desc, addr_desc, __gettid(), thread_name, __getpid(), main_thread_name); } } /* /* Loading Loading
debuggerd/handler/debuggerd_handler.cpp +28 −2 Original line number Original line Diff line number Diff line Loading @@ -116,6 +116,26 @@ static void __noreturn __printflike(1, 2) fatal_errno(const char* fmt, ...) { fatal("%s: %s", buf, strerror(err)); fatal("%s: %s", buf, strerror(err)); } } static bool get_main_thread_name(char* buf, size_t len) { int fd = open("/proc/self/comm", O_RDONLY | O_CLOEXEC); if (fd == -1) { return false; } ssize_t rc = read(fd, buf, len); close(fd); if (rc == -1) { return false; } else if (rc == 0) { // Should never happen? return false; } // There's a trailing newline, replace it with a NUL. buf[rc - 1] = '\0'; return true; } /* /* * Writes a summary of the signal to the log file. We do this so that, if * Writes a summary of the signal to the log file. We do this so that, if * for some reason we're not able to contact debuggerd, there is still some * for some reason we're not able to contact debuggerd, there is still some Loading Loading @@ -188,8 +208,14 @@ static void log_signal_summary(int signum, const siginfo_t* info) { } } } } async_safe_format_log(ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s)", char main_thread_name[MAX_TASK_NAME_LEN + 1]; signum, signal_name, code_desc, addr_desc, __gettid(), thread_name); if (!get_main_thread_name(main_thread_name, sizeof(main_thread_name))) { strncpy(main_thread_name, "<unknown>", sizeof(main_thread_name)); } async_safe_format_log( ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s), pid %d (%s)", signum, signal_name, code_desc, addr_desc, __gettid(), thread_name, __getpid(), main_thread_name); } } /* /* Loading