diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-03-21 20:09:29 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-03-21 20:09:29 +0000 |
commit | ee212d0053c6c8801dbd382d24c776040c4f8f0e (patch) | |
tree | 732d35cc0dd4eff9f99f61261e760595cbb75794 /logd | |
parent | 5ad986ab5690291422f86c03c3fe71a1c50faf40 (diff) | |
parent | b992d0d7d34bed62fd16151a68d60d58cc8003ef (diff) | |
download | system_core-ee212d0053c6c8801dbd382d24c776040c4f8f0e.zip system_core-ee212d0053c6c8801dbd382d24c776040c4f8f0e.tar.gz system_core-ee212d0053c6c8801dbd382d24c776040c4f8f0e.tar.bz2 |
Merge "logd: liblog: Thread IDs missing from logcat -v thread"
Diffstat (limited to 'logd')
-rw-r--r-- | logd/LogBuffer.cpp | 6 | ||||
-rw-r--r-- | logd/LogBuffer.h | 3 | ||||
-rw-r--r-- | logd/LogBufferElement.cpp | 6 | ||||
-rw-r--r-- | logd/LogBufferElement.h | 5 | ||||
-rw-r--r-- | logd/LogListener.cpp | 11 |
5 files changed, 21 insertions, 10 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 197b7e8..1c5cef0 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -45,13 +45,13 @@ LogBuffer::LogBuffer(LastLogTimes *times) } void LogBuffer::log(log_id_t log_id, log_time realtime, - uid_t uid, pid_t pid, const char *msg, - unsigned short len) { + uid_t uid, pid_t pid, pid_t tid, + const char *msg, unsigned short len) { if ((log_id >= LOG_ID_MAX) || (log_id < 0)) { return; } LogBufferElement *elem = new LogBufferElement(log_id, realtime, - uid, pid, msg, len); + uid, pid, tid, msg, len); pthread_mutex_lock(&mLogElementsLock); diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h index 0745e56..cbbb2ce 100644 --- a/logd/LogBuffer.h +++ b/logd/LogBuffer.h @@ -48,7 +48,8 @@ public: LogBuffer(LastLogTimes *times); void log(log_id_t log_id, log_time realtime, - uid_t uid, pid_t pid, const char *msg, unsigned short len); + uid_t uid, pid_t pid, pid_t tid, + const char *msg, unsigned short len); log_time flushTo(SocketClient *writer, const log_time start, bool privileged, bool (*filter)(const LogBufferElement *element, void *arg) = NULL, diff --git a/logd/LogBufferElement.cpp b/logd/LogBufferElement.cpp index 8d45f34..d959ceb 100644 --- a/logd/LogBufferElement.cpp +++ b/logd/LogBufferElement.cpp @@ -27,11 +27,12 @@ const log_time LogBufferElement::FLUSH_ERROR((uint32_t)0, (uint32_t)0); LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime, - uid_t uid, pid_t pid, const char *msg, - unsigned short len) + uid_t uid, pid_t pid, pid_t tid, + const char *msg, unsigned short len) : mLogId(log_id) , mUid(uid) , mPid(pid) + , mTid(tid) , mMsgLen(len) , mMonotonicTime(CLOCK_MONOTONIC) , mRealTime(realtime) { @@ -50,6 +51,7 @@ log_time LogBufferElement::flushTo(SocketClient *reader) { entry.len = mMsgLen; entry.lid = mLogId; entry.pid = mPid; + entry.tid = mTid; entry.sec = mRealTime.tv_sec; entry.nsec = mRealTime.tv_nsec; diff --git a/logd/LogBufferElement.h b/logd/LogBufferElement.h index 1da09ae..fdca973 100644 --- a/logd/LogBufferElement.h +++ b/logd/LogBufferElement.h @@ -26,6 +26,7 @@ class LogBufferElement { const log_id_t mLogId; const uid_t mUid; const pid_t mPid; + const pid_t mTid; char *mMsg; const unsigned short mMsgLen; const log_time mMonotonicTime; @@ -33,12 +34,14 @@ class LogBufferElement { public: LogBufferElement(log_id_t log_id, log_time realtime, - uid_t uid, pid_t pid, const char *msg, unsigned short len); + uid_t uid, pid_t pid, pid_t tid, + const char *msg, unsigned short len); virtual ~LogBufferElement(); log_id_t getLogId() const { return mLogId; } uid_t getUid(void) const { return mUid; } pid_t getPid(void) const { return mPid; } + pid_t getTid(void) const { return mTid; } unsigned short getMsgLen() const { return mMsgLen; } log_time getMonotonicTime(void) const { return mMonotonicTime; } log_time getRealTime(void) const { return mRealTime; } diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp index 2aa2ebb..bef2097 100644 --- a/logd/LogListener.cpp +++ b/logd/LogListener.cpp @@ -50,7 +50,7 @@ bool LogListener::onDataAvailable(SocketClient *cli) { int socket = cli->getSocket(); ssize_t n = recvmsg(socket, &hdr, 0); - if (n <= (ssize_t) sizeof_log_id_t) { + if (n <= (sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time))) { return false; } @@ -82,17 +82,22 @@ bool LogListener::onDataAvailable(SocketClient *cli) { if (log_id < 0 || log_id >= LOG_ID_MAX) { return false; } - char *msg = ((char *)buffer) + sizeof_log_id_t; n -= sizeof_log_id_t; + // second element is the thread id of the caller + pid_t tid = (pid_t) *((uint16_t *) msg); + msg += sizeof(uint16_t); + n -= sizeof(uint16_t); + + // third element is the realtime at point of caller log_time realtime(msg); msg += sizeof(log_time); n -= sizeof(log_time); unsigned short len = n; if (len == n) { - logbuf->log(log_id, realtime, cred->uid, cred->pid, msg, len); + logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, len); reader->notifyNewLog(); } |