Merge "Add UID printing to tombstone headers" into qt-dev

This commit is contained in:
Misha Wagner 2019-05-01 07:46:51 +00:00 committed by Android (Google) Code Review
commit 59d8d4bb8a
3 changed files with 16 additions and 0 deletions

View file

@ -23,6 +23,9 @@
struct ThreadInfo {
std::unique_ptr<unwindstack::Regs> registers;
pid_t uid;
pid_t tid;
std::string thread_name;

View file

@ -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();

View file

@ -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,
@ -615,6 +616,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();
@ -636,6 +638,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,