logd: klogd: deal with htc modified printk
Skip leading 'c0 32767 ' and place pid (32767 in example) into pid field of log record. Bug: 29831823 Change-Id: I9fcd3cb0235dfcad78627736712a20d2dc1250cc
This commit is contained in:
parent
df5d12850a
commit
0b4a63d212
|
@ -401,7 +401,32 @@ void LogKlog::sniffTime(log_time &now,
|
|||
}
|
||||
}
|
||||
|
||||
pid_t LogKlog::sniffPid(const char *cp, size_t len) {
|
||||
pid_t LogKlog::sniffPid(const char **buf, size_t len) {
|
||||
const char *cp = *buf;
|
||||
// HTC kernels with modified printk "c0 1648 "
|
||||
if ((len > 9) &&
|
||||
(cp[0] == 'c') &&
|
||||
isdigit(cp[1]) &&
|
||||
(isdigit(cp[2]) || (cp[2] == ' ')) &&
|
||||
(cp[3] == ' ')) {
|
||||
bool gotDigit = false;
|
||||
int i;
|
||||
for (i = 4; i < 9; ++i) {
|
||||
if (isdigit(cp[i])) {
|
||||
gotDigit = true;
|
||||
} else if (gotDigit || (cp[i] != ' ')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((i == 9) && (cp[i] == ' ')) {
|
||||
int pid = 0;
|
||||
char dummy;
|
||||
if (sscanf(cp + 4, "%d%c", &pid, &dummy) == 2) {
|
||||
*buf = cp + 10; // skip-it-all
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (len) {
|
||||
// Mediatek kernels with modified printk
|
||||
if (*cp == '[') {
|
||||
|
@ -587,7 +612,7 @@ int LogKlog::log(const char *buf, size_t len) {
|
|||
}
|
||||
|
||||
// Parse pid, tid and uid
|
||||
const pid_t pid = sniffPid(p, len - (p - buf));
|
||||
const pid_t pid = sniffPid(&p, len - (p - buf));
|
||||
const pid_t tid = pid;
|
||||
const uid_t uid = pid ? logbuf->pidToUid(pid) : 0;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
protected:
|
||||
void sniffTime(log_time &now, const char **buf, size_t len, bool reverse);
|
||||
pid_t sniffPid(const char *buf, size_t len);
|
||||
pid_t sniffPid(const char **buf, size_t len);
|
||||
void calculateCorrection(const log_time &monotonic,
|
||||
const char *real_string, size_t len);
|
||||
virtual bool onDataAvailable(SocketClient *cli);
|
||||
|
|
Loading…
Reference in New Issue