Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c3b14d0 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

llkd: stutter pre-panic message to both last kernel and last logcat

Test: compile
Bug: 118712403
Change-Id: I9067b9335b2685169bcf8b1dc0248f7ff4315046
parent 53e782d5
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -510,8 +510,10 @@ bool llkWriteStringToFileConfirm(const std::string& string, const std::string& f
    return android::base::Trim(content) == string;
}

void llkPanicKernel(bool dump, pid_t tid, const char* state) __noreturn;
void llkPanicKernel(bool dump, pid_t tid, const char* state) {
void llkPanicKernel(bool dump, pid_t tid, const char* state,
                    const std::string& message = "") __noreturn;
void llkPanicKernel(bool dump, pid_t tid, const char* state, const std::string& message) {
    if (!message.empty()) LOG(ERROR) << message;
    auto sysrqTriggerFd = llkFileToWriteFd("/proc/sysrq-trigger");
    if (sysrqTriggerFd < 0) {
        // DYB
@@ -537,7 +539,11 @@ void llkPanicKernel(bool dump, pid_t tid, const char* state) {
        }
        ::usleep(200000);  // let everything settle
    }
    llkWriteStringToFile("SysRq : Trigger a crash : 'livelock,"s + state + "'\n", "/dev/kmsg");
    // SysRq message matches kernel format, and propagates through bootstat
    // ultimately to the boot reason into panic,livelock,<state>.
    llkWriteStringToFile(message + (message.empty() ? "" : "\n") +
                                 "SysRq : Trigger a crash : 'livelock,"s + state + "'\n",
                         "/dev/kmsg");
    android::base::WriteStringToFd("c", sysrqTriggerFd);
    // NOTREACHED
    // DYB
@@ -1098,10 +1104,12 @@ milliseconds llkCheck(bool checkRunning) {
                }
            }
            // We are here because we have confirmed kernel live-lock
            LOG(ERROR) << state << ' ' << llkFormat(procp->count) << ' ' << ppid << "->" << pid
                       << "->" << tid << ' ' << procp->getComm() << " [panic]";
            const auto message = state + " "s + llkFormat(procp->count) + " " +
                                 std::to_string(ppid) + "->" + std::to_string(pid) + "->" +
                                 std::to_string(tid) + " " + procp->getComm() + " [panic]";
            llkPanicKernel(true, tid,
                           (state == 'Z') ? "zombie" : (state == 'D') ? "driver" : "sleeping");
                           (state == 'Z') ? "zombie" : (state == 'D') ? "driver" : "sleeping",
                           message);
        }
        LOG(VERBOSE) << "+closedir()";
    }