diff options
author | Misha Wagner <mishaw@google.com> | 2019-04-18 16:07:33 +0100 |
---|---|---|
committer | Misha Wagner <mishaw@google.com> | 2019-04-29 11:19:34 +0100 |
commit | 1d0d6623238f9a0de8edbf8a59e64f90847e6e1f (patch) | |
tree | a27c3ac34cb64f9f4bc49c5113bc16d009fa8aac | |
parent | 6b8caf8eb709cc8eec1691d44ce09db4559e165d (diff) | |
download | system_core-1d0d6623238f9a0de8edbf8a59e64f90847e6e1f.tar.gz system_core-1d0d6623238f9a0de8edbf8a59e64f90847e6e1f.tar.bz2 system_core-1d0d6623238f9a0de8edbf8a59e64f90847e6e1f.zip |
Add UID printing to tombstone headers
This is for Android Telemetry to be able to categorise the processes
that produce tombstones.
Bug: 129933535
Test: atest debugerd_test:TombstoneTest
Change-Id: Ie635347c9839eb58bfd27739050bd68cbdbf98da
Merged-In: Ie635347c9839eb58bfd27739050bd68cbdbf98da
(cherry picked from commit e5b7913d2c5da92c37233fef15ab3109e37d9c90)
-rw-r--r-- | debuggerd/libdebuggerd/include/libdebuggerd/types.h | 3 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/test/tombstone_test.cpp | 10 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/tombstone.cpp | 3 |
3 files changed, 16 insertions, 0 deletions
diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/types.h b/debuggerd/libdebuggerd/include/libdebuggerd/types.h index 70583af30..eb4b1b844 100644 --- a/debuggerd/libdebuggerd/include/libdebuggerd/types.h +++ b/debuggerd/libdebuggerd/include/libdebuggerd/types.h @@ -23,6 +23,9 @@ struct ThreadInfo { std::unique_ptr<unwindstack::Regs> registers; + + pid_t uid; + pid_t tid; std::string thread_name; diff --git a/debuggerd/libdebuggerd/test/tombstone_test.cpp b/debuggerd/libdebuggerd/test/tombstone_test.cpp index 3196ce84b..88c206f8d 100644 --- a/debuggerd/libdebuggerd/test/tombstone_test.cpp +++ b/debuggerd/libdebuggerd/test/tombstone_test.cpp @@ -343,6 +343,16 @@ TEST_F(TombstoneTest, dump_header_info) { ASSERT_STREQ(expected.c_str(), amfd_data_.c_str()); } +TEST_F(TombstoneTest, dump_thread_info_uid) { + dump_thread_info(&log_, ThreadInfo{.uid = 1, + .pid = 2, + .tid = 3, + .thread_name = "some_thread", + .process_name = "some_process"}); + std::string expected = "pid: 2, tid: 3, name: some_thread >>> some_process <<<\nuid: 1\n"; + ASSERT_STREQ(expected.c_str(), amfd_data_.c_str()); +} + TEST_F(TombstoneTest, dump_timestamp) { setenv("TZ", "UTC", 1); tzset(); diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index cc337ed30..89a5a455f 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -151,6 +151,7 @@ static void dump_thread_info(log_t* log, const ThreadInfo& thread_info) { _LOG(log, logtype::HEADER, "pid: %d, tid: %d, name: %s >>> %s <<<\n", thread_info.pid, thread_info.tid, thread_info.thread_name.c_str(), thread_info.process_name.c_str()); + _LOG(log, logtype::HEADER, "uid: %d\n", thread_info.uid); } static void dump_stack_segment(log_t* log, unwindstack::Maps* maps, unwindstack::Memory* memory, @@ -622,6 +623,7 @@ static void dump_logs(log_t* log, pid_t pid, unsigned int tail) { void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo, ucontext_t* ucontext) { + pid_t uid = getuid(); pid_t pid = getpid(); pid_t tid = gettid(); @@ -643,6 +645,7 @@ void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, si std::map<pid_t, ThreadInfo> threads; threads[gettid()] = ThreadInfo{ .registers = std::move(regs), + .uid = uid, .tid = tid, .thread_name = thread_name, .pid = pid, |