summaryrefslogtreecommitdiffstats
path: root/llkd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2018-10-31 10:38:15 -0700
committerMark Salyzyn <salyzyn@google.com>2018-11-01 08:14:03 -0700
commit3c3b14d0de9a64590b43aa319b8fe483113b26f9 (patch)
tree2c62e1dbad6c9fa1f99e766e9ad8702f6fbb6d11 /llkd
parent53e782d5315578f9bf8a11df1df9bae588da3f98 (diff)
downloadsystem_core-3c3b14d0de9a64590b43aa319b8fe483113b26f9.tar.gz
system_core-3c3b14d0de9a64590b43aa319b8fe483113b26f9.tar.bz2
system_core-3c3b14d0de9a64590b43aa319b8fe483113b26f9.zip
llkd: stutter pre-panic message to both last kernel and last logcat
Test: compile Bug: 118712403 Change-Id: I9067b9335b2685169bcf8b1dc0248f7ff4315046
Diffstat (limited to 'llkd')
-rw-r--r--llkd/libllkd.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llkd/libllkd.cpp b/llkd/libllkd.cpp
index 7140c3b47..0827470af 100644
--- a/llkd/libllkd.cpp
+++ b/llkd/libllkd.cpp
@@ -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()";
}