diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-03-20 16:09:38 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-03-21 10:37:44 -0700 |
commit | b992d0d7d34bed62fd16151a68d60d58cc8003ef (patch) | |
tree | 732d35cc0dd4eff9f99f61261e760595cbb75794 /liblog/logd_write.c | |
parent | 5ad986ab5690291422f86c03c3fe71a1c50faf40 (diff) | |
download | core-b992d0d7d34bed62fd16151a68d60d58cc8003ef.tar.gz core-b992d0d7d34bed62fd16151a68d60d58cc8003ef.tar.bz2 core-b992d0d7d34bed62fd16151a68d60d58cc8003ef.zip |
logd: liblog: Thread IDs missing from logcat -v thread
- stuff caller's thread id into the packet.
Bug: 13568206
Change-Id: I02d0cdf9b1d9e839ff8969f591db42dfe6e4cc95
Diffstat (limited to 'liblog/logd_write.c')
-rw-r--r-- | liblog/logd_write.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c index c3efc33f7..aa0ad39c2 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -111,11 +111,34 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) */ return 0; } - struct iovec newVec[nr + 2]; + /* + * struct { + * // what we provide + * typeof_log_id_t log_id; + * u16 tid; + * log_time realtime; + * // caller provides + * union { + * struct { + * char prio; + * char payload[]; + * } string; + * struct { + * uint32_t tag + * char payload[]; + * } binary; + * }; + * }; + */ + static const unsigned header_length = 3; + struct iovec newVec[nr + header_length]; typeof_log_id_t log_id_buf = log_id; + uint16_t tid = gettid(); newVec[0].iov_base = (unsigned char *) &log_id_buf; newVec[0].iov_len = sizeof_log_id_t; + newVec[1].iov_base = (unsigned char *) &tid; + newVec[1].iov_len = sizeof(tid); struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); @@ -123,17 +146,17 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) realtime_ts.tv_sec = ts.tv_sec; realtime_ts.tv_nsec = ts.tv_nsec; - newVec[1].iov_base = (unsigned char *) &realtime_ts; - newVec[1].iov_len = sizeof(log_time); + newVec[2].iov_base = (unsigned char *) &realtime_ts; + newVec[2].iov_len = sizeof(log_time); size_t i; - for (i = 2; i < nr + 2; i++) { - newVec[i].iov_base = vec[i-2].iov_base; - newVec[i].iov_len = vec[i-2].iov_len; + for (i = header_length; i < nr + header_length; i++) { + newVec[i].iov_base = vec[i-header_length].iov_base; + newVec[i].iov_len = vec[i-header_length].iov_len; } /* The write below could be lost, but will never block. */ - return writev(logd_fd, newVec, nr + 2); + return writev(logd_fd, newVec, nr + header_length); #endif } |