blob: 4bdb9c86a6e184bcf12afa5ceab1307b81b96d87 [file] [log] [blame]
Jeff Brown053b8652012-06-06 16:25:03 -07001/*
Mark Salyzynfca0bd12013-12-12 12:21:20 -08002 * Copyright (C) 2012-2014 The Android Open Source Project
Jeff Brown053b8652012-06-06 16:25:03 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brigid Smith62ba4892014-06-10 11:53:08 -070017#define LOG_TAG "DEBUG"
18
Josh Gaoc3706662017-08-29 13:08:32 -070019#include "libdebuggerd/tombstone.h"
20
Jeff Brown053b8652012-06-06 16:25:03 -070021#include <dirent.h>
Kévin PETIT4bb47722013-12-18 16:44:24 +000022#include <errno.h>
23#include <fcntl.h>
24#include <inttypes.h>
25#include <signal.h>
26#include <stddef.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
Jeff Brown053b8652012-06-06 16:25:03 -070030#include <sys/ptrace.h>
31#include <sys/stat.h>
Mark Salyzynff2dcd92016-09-28 15:54:45 -070032#include <time.h>
Jeff Brown053b8652012-06-06 16:25:03 -070033
Christopher Ferris6e964032015-05-15 17:30:21 -070034#include <memory>
35#include <string>
36
Josh Gao57f58f82017-03-15 23:23:22 -070037#include <android-base/file.h>
Josh Gao2b2ae0c2017-08-21 14:31:17 -070038#include <android-base/logging.h>
Tom Cherry31121ca2017-10-10 13:30:57 -070039#include <android-base/properties.h>
Elliott Hughes4f713192015-12-04 22:00:26 -080040#include <android-base/stringprintf.h>
Josh Gao2b2ae0c2017-08-21 14:31:17 -070041#include <android-base/strings.h>
Josh Gao57f58f82017-03-15 23:23:22 -070042#include <android-base/unique_fd.h>
43#include <android/log.h>
Mark Salyzyncfd5b082016-10-17 14:28:00 -070044#include <log/log.h>
Mark Salyzynff2dcd92016-09-28 15:54:45 -070045#include <log/logprint.h>
46#include <private/android_filesystem_config.h>
Christopher Ferris60eb1972019-01-15 15:18:43 -080047#include <unwindstack/JitDebug.h>
48#include <unwindstack/Maps.h>
Josh Gao2b2ae0c2017-08-21 14:31:17 -070049#include <unwindstack/Memory.h>
50#include <unwindstack/Regs.h>
Christopher Ferris60eb1972019-01-15 15:18:43 -080051#include <unwindstack/Unwinder.h>
Jeff Brown053b8652012-06-06 16:25:03 -070052
Josh Gaoc3706662017-08-29 13:08:32 -070053// Needed to get DEBUGGER_SIGNAL.
Josh Gaocbe70cb2016-10-18 18:17:52 -070054#include "debuggerd/handler.h"
rpcraigf1186f32012-07-19 09:38:06 -040055
Josh Gaoc3706662017-08-29 13:08:32 -070056#include "libdebuggerd/backtrace.h"
Josh Gaoc3706662017-08-29 13:08:32 -070057#include "libdebuggerd/open_files_list.h"
Josh Gao2b2ae0c2017-08-21 14:31:17 -070058#include "libdebuggerd/utility.h"
Jeff Brown053b8652012-06-06 16:25:03 -070059
Tom Cherry31121ca2017-10-10 13:30:57 -070060using android::base::GetBoolProperty;
61using android::base::GetProperty;
Elliott Hughes0ba53592017-02-01 16:59:15 -080062using android::base::StringPrintf;
Josh Gao2b2ae0c2017-08-21 14:31:17 -070063using android::base::unique_fd;
64
Elliott Hughese1415a52018-02-15 09:18:21 -080065using namespace std::literals::string_literals;
66
Jeff Brown053b8652012-06-06 16:25:03 -070067#define STACK_WORDS 16
68
Brigid Smith9c8dacc2014-06-02 15:02:20 -070069static void dump_header_info(log_t* log) {
Tom Cherry31121ca2017-10-10 13:30:57 -070070 auto fingerprint = GetProperty("ro.build.fingerprint", "unknown");
71 auto revision = GetProperty("ro.revision", "unknown");
Ben Chengd7760c12012-09-19 16:04:01 -070072
Tom Cherry31121ca2017-10-10 13:30:57 -070073 _LOG(log, logtype::HEADER, "Build fingerprint: '%s'\n", fingerprint.c_str());
74 _LOG(log, logtype::HEADER, "Revision: '%s'\n", revision.c_str());
Brigid Smith62ba4892014-06-10 11:53:08 -070075 _LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING);
Jeff Brown053b8652012-06-06 16:25:03 -070076}
77
Josh Gao6f4644d2018-12-14 13:05:12 -080078static void dump_timestamp(log_t* log, time_t time) {
79 struct tm tm;
80 localtime_r(&time, &tm);
81
82 char buf[strlen("1970-01-01 00:00:00+0830") + 1];
83 strftime(buf, sizeof(buf), "%F %T%z", &tm);
84 _LOG(log, logtype::HEADER, "Timestamp: %s\n", buf);
85}
86
Christopher Ferris60eb1972019-01-15 15:18:43 -080087static void dump_probable_cause(log_t* log, const siginfo_t* si, unwindstack::Maps* maps) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080088 std::string cause;
Josh Gao2b2ae0c2017-08-21 14:31:17 -070089 if (si->si_signo == SIGSEGV && si->si_code == SEGV_MAPERR) {
90 if (si->si_addr < reinterpret_cast<void*>(4096)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080091 cause = StringPrintf("null pointer dereference");
Josh Gao2b2ae0c2017-08-21 14:31:17 -070092 } else if (si->si_addr == reinterpret_cast<void*>(0xffff0ffc)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080093 cause = "call to kuser_helper_version";
Josh Gao2b2ae0c2017-08-21 14:31:17 -070094 } else if (si->si_addr == reinterpret_cast<void*>(0xffff0fe0)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080095 cause = "call to kuser_get_tls";
Josh Gao2b2ae0c2017-08-21 14:31:17 -070096 } else if (si->si_addr == reinterpret_cast<void*>(0xffff0fc0)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080097 cause = "call to kuser_cmpxchg";
Josh Gao2b2ae0c2017-08-21 14:31:17 -070098 } else if (si->si_addr == reinterpret_cast<void*>(0xffff0fa0)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -080099 cause = "call to kuser_memory_barrier";
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700100 } else if (si->si_addr == reinterpret_cast<void*>(0xffff0f60)) {
Elliott Hughes0ba53592017-02-01 16:59:15 -0800101 cause = "call to kuser_cmpxchg64";
102 }
Ivan Lozanodf3cec92018-11-19 10:43:47 -0800103 } else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800104 unwindstack::MapInfo* map_info = maps->Find(reinterpret_cast<uint64_t>(si->si_addr));
105 if (map_info != nullptr && map_info->flags == PROT_EXEC) {
106 cause = "execute-only (no-read) memory access error; likely due to data in .text.";
Ivan Lozanodf3cec92018-11-19 10:43:47 -0800107 }
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700108 } else if (si->si_signo == SIGSYS && si->si_code == SYS_SECCOMP) {
109 cause = StringPrintf("seccomp prevented call to disallowed %s system call %d", ABI_STRING,
110 si->si_syscall);
Elliott Hughes0ba53592017-02-01 16:59:15 -0800111 }
112
113 if (!cause.empty()) _LOG(log, logtype::HEADER, "Cause: %s\n", cause.c_str());
114}
115
Christopher Ferris60eb1972019-01-15 15:18:43 -0800116static void dump_signal_info(log_t* log, const ThreadInfo& thread_info,
117 unwindstack::Memory* process_memory) {
Elliott Hughes2baf4432018-05-30 12:55:04 -0700118 char addr_desc[64]; // ", fault addr 0x1234"
Elliott Hughes70d8f282018-04-25 17:00:14 -0700119 if (signal_has_si_addr(thread_info.siginfo)) {
Elliott Hughes2baf4432018-05-30 12:55:04 -0700120 void* addr = thread_info.siginfo->si_addr;
121 if (thread_info.siginfo->si_signo == SIGILL) {
122 uint32_t instruction = {};
123 process_memory->Read(reinterpret_cast<uint64_t>(addr), &instruction, sizeof(instruction));
124 snprintf(addr_desc, sizeof(addr_desc), "%p (*pc=%#08x)", addr, instruction);
125 } else {
126 snprintf(addr_desc, sizeof(addr_desc), "%p", addr);
127 }
Elliott Hughes855fcc32014-04-25 16:05:34 -0700128 } else {
129 snprintf(addr_desc, sizeof(addr_desc), "--------");
130 }
131
Elliott Hughes70d8f282018-04-25 17:00:14 -0700132 char sender_desc[32] = {}; // " from pid 1234, uid 666"
133 if (signal_has_sender(thread_info.siginfo, thread_info.pid)) {
134 get_signal_sender(sender_desc, sizeof(sender_desc), thread_info.siginfo);
135 }
Elliott Hughes0ba53592017-02-01 16:59:15 -0800136
Elliott Hughes70d8f282018-04-25 17:00:14 -0700137 _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s%s), fault addr %s\n",
138 thread_info.siginfo->si_signo, get_signame(thread_info.siginfo),
139 thread_info.siginfo->si_code, get_sigcode(thread_info.siginfo), sender_desc, addr_desc);
Jeff Brown053b8652012-06-06 16:25:03 -0700140}
141
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700142static void dump_thread_info(log_t* log, const ThreadInfo& thread_info) {
Mark Salyzyn45ae4462014-07-25 12:25:48 -0700143 // Blacklist logd, logd.reader, logd.writer, logd.auditd, logd.control ...
Josh Gao57f58f82017-03-15 23:23:22 -0700144 // TODO: Why is this controlled by thread name?
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700145 if (thread_info.thread_name == "logd" ||
146 android::base::StartsWith(thread_info.thread_name, "logd.")) {
Mark Salyzyn45ae4462014-07-25 12:25:48 -0700147 log->should_retrieve_logcat = false;
148 }
Christopher Ferris20303f82014-01-10 16:33:16 -0800149
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700150 _LOG(log, logtype::HEADER, "pid: %d, tid: %d, name: %s >>> %s <<<\n", thread_info.pid,
151 thread_info.tid, thread_info.thread_name.c_str(), thread_info.process_name.c_str());
Christopher Ferris20303f82014-01-10 16:33:16 -0800152}
Jeff Brown053b8652012-06-06 16:25:03 -0700153
Christopher Ferris60eb1972019-01-15 15:18:43 -0800154static void dump_stack_segment(log_t* log, unwindstack::Maps* maps, unwindstack::Memory* memory,
Christopher Ferris7937a362018-01-18 11:15:49 -0800155 uint64_t* sp, size_t words, int label) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800156 // Read the data all at once.
157 word_t stack_data[words];
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700158
159 // TODO: Do we need to word align this for crashes caused by a misaligned sp?
160 // The process_vm_readv implementation of Memory should handle this appropriately?
Christopher Ferris60eb1972019-01-15 15:18:43 -0800161 size_t bytes_read = memory->Read(*sp, stack_data, sizeof(word_t) * words);
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800162 words = bytes_read / sizeof(word_t);
163 std::string line;
Christopher Ferris20303f82014-01-10 16:33:16 -0800164 for (size_t i = 0; i < words; i++) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800165 line = " ";
166 if (i == 0 && label >= 0) {
167 // Print the label once.
Elliott Hughes0ba53592017-02-01 16:59:15 -0800168 line += StringPrintf("#%02d ", label);
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800169 } else {
170 line += " ";
Christopher Ferris20303f82014-01-10 16:33:16 -0800171 }
Christopher Ferrise36afb02018-01-20 00:59:11 -0800172 line += StringPrintf("%" PRIPTR " %" PRIPTR, *sp, static_cast<uint64_t>(stack_data[i]));
Christopher Ferris20303f82014-01-10 16:33:16 -0800173
Christopher Ferris60eb1972019-01-15 15:18:43 -0800174 unwindstack::MapInfo* map_info = maps->Find(stack_data[i]);
175 if (map_info != nullptr && !map_info->name.empty()) {
176 line += " " + map_info->name;
177 std::string func_name;
178 uint64_t func_offset = 0;
179 if (map_info->GetFunctionName(stack_data[i], &func_name, &func_offset)) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800180 line += " (" + func_name;
Christopher Ferris60eb1972019-01-15 15:18:43 -0800181 if (func_offset) {
182 line += StringPrintf("+%" PRIu64, func_offset);
Jeff Brown053b8652012-06-06 16:25:03 -0700183 }
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800184 line += ')';
Christopher Ferris20303f82014-01-10 16:33:16 -0800185 }
Jeff Brown053b8652012-06-06 16:25:03 -0700186 }
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800187 _LOG(log, logtype::STACK, "%s\n", line.c_str());
Christopher Ferris20303f82014-01-10 16:33:16 -0800188
Pavel Chupinc6c194c2013-11-21 23:17:20 +0400189 *sp += sizeof(word_t);
Christopher Ferris20303f82014-01-10 16:33:16 -0800190 }
Jeff Brown053b8652012-06-06 16:25:03 -0700191}
192
Christopher Ferris60eb1972019-01-15 15:18:43 -0800193static void dump_stack(log_t* log, const std::vector<unwindstack::FrameData>& frames,
194 unwindstack::Maps* maps, unwindstack::Memory* memory) {
Christopher Ferris20303f82014-01-10 16:33:16 -0800195 size_t first = 0, last;
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700196 for (size_t i = 0; i < frames.size(); i++) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800197 if (frames[i].sp) {
Christopher Ferris20303f82014-01-10 16:33:16 -0800198 if (!first) {
199 first = i+1;
200 }
201 last = i;
Jeff Brown053b8652012-06-06 16:25:03 -0700202 }
Christopher Ferris20303f82014-01-10 16:33:16 -0800203 }
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700204
Christopher Ferris20303f82014-01-10 16:33:16 -0800205 if (!first) {
206 return;
207 }
208 first--;
209
Christopher Ferris20303f82014-01-10 16:33:16 -0800210 // Dump a few words before the first frame.
Christopher Ferris7937a362018-01-18 11:15:49 -0800211 uint64_t sp = frames[first].sp - STACK_WORDS * sizeof(word_t);
Christopher Ferris60eb1972019-01-15 15:18:43 -0800212 dump_stack_segment(log, maps, memory, &sp, STACK_WORDS, -1);
213
214#if defined(__LP64__)
215 static constexpr const char delimiter[] = " ................ ................\n";
216#else
217 static constexpr const char delimiter[] = " ........ ........\n";
218#endif
Christopher Ferris20303f82014-01-10 16:33:16 -0800219
220 // Dump a few words from all successive frames.
Christopher Ferris20303f82014-01-10 16:33:16 -0800221 for (size_t i = first; i <= last; i++) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800222 auto* frame = &frames[i];
Christopher Ferris20303f82014-01-10 16:33:16 -0800223 if (sp != frame->sp) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800224 _LOG(log, logtype::STACK, delimiter);
Christopher Ferris20303f82014-01-10 16:33:16 -0800225 sp = frame->sp;
226 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800227 if (i != last) {
228 // Print stack data up to the stack from the next frame.
229 size_t words;
230 uint64_t next_sp = frames[i + 1].sp;
231 if (next_sp < sp) {
232 // The next frame is probably using a completely different stack,
233 // so dump the max from this stack.
Christopher Ferris20303f82014-01-10 16:33:16 -0800234 words = STACK_WORDS;
Christopher Ferris60eb1972019-01-15 15:18:43 -0800235 } else {
236 words = (next_sp - sp) / sizeof(word_t);
237 if (words == 0) {
238 // The sp is the same as the next frame, print at least
239 // one line for this frame.
240 words = 1;
241 } else if (words > STACK_WORDS) {
242 words = STACK_WORDS;
243 }
Christopher Ferris20303f82014-01-10 16:33:16 -0800244 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800245 dump_stack_segment(log, maps, memory, &sp, words, i);
246 } else {
247 // Print some number of words past the last stack frame since we
248 // don't know how large the stack is.
249 dump_stack_segment(log, maps, memory, &sp, STACK_WORDS, i);
Christopher Ferris20303f82014-01-10 16:33:16 -0800250 }
251 }
Jeff Brown053b8652012-06-06 16:25:03 -0700252}
253
Christopher Ferris7937a362018-01-18 11:15:49 -0800254static std::string get_addr_string(uint64_t addr) {
Christopher Ferris862fe022015-06-02 14:52:44 -0700255 std::string addr_str;
256#if defined(__LP64__)
Elliott Hughes0ba53592017-02-01 16:59:15 -0800257 addr_str = StringPrintf("%08x'%08x",
258 static_cast<uint32_t>(addr >> 32),
259 static_cast<uint32_t>(addr & 0xffffffff));
Christopher Ferris862fe022015-06-02 14:52:44 -0700260#else
Christopher Ferris7937a362018-01-18 11:15:49 -0800261 addr_str = StringPrintf("%08x", static_cast<uint32_t>(addr));
Christopher Ferris862fe022015-06-02 14:52:44 -0700262#endif
263 return addr_str;
264}
265
Christopher Ferris60eb1972019-01-15 15:18:43 -0800266static void dump_abort_message(log_t* log, unwindstack::Memory* process_memory, uint64_t address) {
Josh Gao7c89f9e2016-01-13 17:57:14 -0800267 if (address == 0) {
268 return;
269 }
270
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700271 size_t length;
272 if (!process_memory->ReadFully(address, &length, sizeof(length))) {
273 _LOG(log, logtype::HEADER, "Failed to read abort message header: %s\n", strerror(errno));
274 return;
275 }
Josh Gao7c89f9e2016-01-13 17:57:14 -0800276
Josh Gao1cc7bd82018-02-13 13:16:17 -0800277 // The length field includes the length of the length field itself.
278 if (length < sizeof(size_t)) {
279 _LOG(log, logtype::HEADER, "Abort message header malformed: claimed length = %zd\n", length);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700280 return;
Josh Gao7c89f9e2016-01-13 17:57:14 -0800281 }
Josh Gao7c89f9e2016-01-13 17:57:14 -0800282
Josh Gao1cc7bd82018-02-13 13:16:17 -0800283 length -= sizeof(size_t);
284
Josh Gao83b8ac22018-04-20 17:31:53 -0700285 // The abort message should be null terminated already, but reserve a spot for NUL just in case.
286 std::vector<char> msg(length + 1);
Josh Gao1cc7bd82018-02-13 13:16:17 -0800287 if (!process_memory->ReadFully(address + sizeof(length), &msg[0], length)) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700288 _LOG(log, logtype::HEADER, "Failed to read abort message: %s\n", strerror(errno));
289 return;
290 }
291
Josh Gao1cc7bd82018-02-13 13:16:17 -0800292 _LOG(log, logtype::HEADER, "Abort message: '%s'\n", &msg[0]);
Josh Gao7c89f9e2016-01-13 17:57:14 -0800293}
294
Christopher Ferris60eb1972019-01-15 15:18:43 -0800295static void dump_all_maps(log_t* log, unwindstack::Unwinder* unwinder, uint64_t addr) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700296 bool print_fault_address_marker = addr;
Christopher Ferris20303f82014-01-10 16:33:16 -0800297
Christopher Ferris60eb1972019-01-15 15:18:43 -0800298 unwindstack::Maps* maps = unwinder->GetMaps();
Elliott Hughes868d39a2017-09-26 11:54:49 -0700299 _LOG(log, logtype::MAPS,
300 "\n"
Josh Gao1ce8e142017-09-27 13:59:42 -0700301 "memory map (%zu entr%s):",
Christopher Ferris60eb1972019-01-15 15:18:43 -0800302 maps->Total(), maps->Total() == 1 ? "y" : "ies");
Elliott Hughes868d39a2017-09-26 11:54:49 -0700303 if (print_fault_address_marker) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800304 if (maps->Total() != 0 && addr < maps->Get(0)->start) {
Josh Gao1ce8e142017-09-27 13:59:42 -0700305 _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n",
Christopher Ferris862fe022015-06-02 14:52:44 -0700306 get_addr_string(addr).c_str());
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800307 print_fault_address_marker = false;
Elliott Hughes868d39a2017-09-26 11:54:49 -0700308 } else {
Josh Gao1ce8e142017-09-27 13:59:42 -0700309 _LOG(log, logtype::MAPS, " (fault address prefixed with --->)\n");
Brigid Smith8606eaa2014-07-07 12:33:50 -0700310 }
Josh Gao1ce8e142017-09-27 13:59:42 -0700311 } else {
312 _LOG(log, logtype::MAPS, "\n");
Brigid Smith8606eaa2014-07-07 12:33:50 -0700313 }
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800314
Christopher Ferris60eb1972019-01-15 15:18:43 -0800315 std::shared_ptr<unwindstack::Memory>& process_memory = unwinder->GetProcessMemory();
316
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800317 std::string line;
Florian Mayer3d67d342019-02-27 18:00:37 +0000318 for (auto const& map_info : *maps) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800319 line = " ";
320 if (print_fault_address_marker) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800321 if (addr < map_info->start) {
Christopher Ferris862fe022015-06-02 14:52:44 -0700322 _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n",
323 get_addr_string(addr).c_str());
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800324 print_fault_address_marker = false;
Christopher Ferris60eb1972019-01-15 15:18:43 -0800325 } else if (addr >= map_info->start && addr < map_info->end) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800326 line = "--->";
327 print_fault_address_marker = false;
328 }
329 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800330 line += get_addr_string(map_info->start) + '-' + get_addr_string(map_info->end - 1) + ' ';
331 if (map_info->flags & PROT_READ) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800332 line += 'r';
333 } else {
334 line += '-';
335 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800336 if (map_info->flags & PROT_WRITE) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800337 line += 'w';
338 } else {
339 line += '-';
340 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800341 if (map_info->flags & PROT_EXEC) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800342 line += 'x';
343 } else {
344 line += '-';
345 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800346 line += StringPrintf(" %8" PRIx64 " %8" PRIx64, map_info->offset,
347 map_info->end - map_info->start);
Christopher Ferris862fe022015-06-02 14:52:44 -0700348 bool space_needed = true;
Christopher Ferris60eb1972019-01-15 15:18:43 -0800349 if (!map_info->name.empty()) {
Christopher Ferris862fe022015-06-02 14:52:44 -0700350 space_needed = false;
Christopher Ferris60eb1972019-01-15 15:18:43 -0800351 line += " " + map_info->name;
352 std::string build_id = map_info->GetPrintableBuildID();
353 if (!build_id.empty()) {
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800354 line += " (BuildId: " + build_id + ")";
355 }
356 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800357 uint64_t load_bias = map_info->GetLoadBias(process_memory);
358 if (load_bias != 0) {
Christopher Ferris862fe022015-06-02 14:52:44 -0700359 if (space_needed) {
360 line += ' ';
361 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800362 line += StringPrintf(" (load bias 0x%" PRIx64 ")", load_bias);
Christopher Ferris2106f4b2015-05-01 15:02:03 -0700363 }
Christopher Ferrisa21bd932015-02-27 13:39:47 -0800364 _LOG(log, logtype::MAPS, "%s\n", line.c_str());
365 }
366 if (print_fault_address_marker) {
Christopher Ferris862fe022015-06-02 14:52:44 -0700367 _LOG(log, logtype::MAPS, "--->Fault address falls at %s after any mapped regions\n",
368 get_addr_string(addr).c_str());
Christopher Ferris20303f82014-01-10 16:33:16 -0800369 }
Jeff Brown053b8652012-06-06 16:25:03 -0700370}
371
Christopher Ferris60eb1972019-01-15 15:18:43 -0800372void dump_backtrace(log_t* log, unwindstack::Unwinder* unwinder, const char* prefix) {
Christopher Ferris78133452019-03-14 13:44:38 -0700373 unwinder->SetDisplayBuildID(true);
Christopher Ferris60eb1972019-01-15 15:18:43 -0800374 for (size_t i = 0; i < unwinder->NumFrames(); i++) {
375 _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, unwinder->FormatFrame(i).c_str());
Christopher Ferrisab9e7dc2015-02-09 17:06:27 -0800376 }
Jeff Brown053b8652012-06-06 16:25:03 -0700377}
378
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700379static void print_register_row(log_t* log,
380 const std::vector<std::pair<std::string, uint64_t>>& registers) {
381 std::string output;
382 for (auto& [name, value] : registers) {
Christopher Ferris7937a362018-01-18 11:15:49 -0800383 output += android::base::StringPrintf(" %-3s %0*" PRIx64, name.c_str(),
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700384 static_cast<int>(2 * sizeof(void*)),
Christopher Ferris7937a362018-01-18 11:15:49 -0800385 static_cast<uint64_t>(value));
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700386 }
387
388 _LOG(log, logtype::REGISTERS, " %s\n", output.c_str());
Josh Gao77b00ed2017-05-05 18:11:23 -0700389}
390
Christopher Ferris60eb1972019-01-15 15:18:43 -0800391void dump_registers(log_t* log, unwindstack::Regs* regs) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700392 // Split lr/sp/pc into their own special row.
393 static constexpr size_t column_count = 4;
394 std::vector<std::pair<std::string, uint64_t>> current_row;
395 std::vector<std::pair<std::string, uint64_t>> special_row;
396
397#if defined(__arm__) || defined(__aarch64__)
398 static constexpr const char* special_registers[] = {"ip", "lr", "sp", "pc"};
399#elif defined(__i386__)
400 static constexpr const char* special_registers[] = {"ebp", "esp", "eip"};
401#elif defined(__x86_64__)
402 static constexpr const char* special_registers[] = {"rbp", "rsp", "rip"};
403#else
404 static constexpr const char* special_registers[] = {};
405#endif
406
407 regs->IterateRegisters([log, &current_row, &special_row](const char* name, uint64_t value) {
408 auto row = &current_row;
409 for (const char* special_name : special_registers) {
410 if (strcmp(special_name, name) == 0) {
411 row = &special_row;
412 break;
413 }
414 }
415
416 row->emplace_back(name, value);
417 if (current_row.size() == column_count) {
418 print_register_row(log, current_row);
419 current_row.clear();
420 }
421 });
422
423 if (!current_row.empty()) {
424 print_register_row(log, current_row);
425 }
426
427 print_register_row(log, special_row);
428}
429
Christopher Ferris60eb1972019-01-15 15:18:43 -0800430void dump_memory_and_code(log_t* log, unwindstack::Maps* maps, unwindstack::Memory* memory,
431 unwindstack::Regs* regs) {
432 regs->IterateRegisters([log, maps, memory](const char* reg_name, uint64_t reg_value) {
Elliott Hughese1415a52018-02-15 09:18:21 -0800433 std::string label{"memory near "s + reg_name};
Christopher Ferris60eb1972019-01-15 15:18:43 -0800434 if (maps) {
435 unwindstack::MapInfo* map_info = maps->Find(reg_value);
436 if (map_info != nullptr && !map_info->name.empty()) {
437 label += " (" + map_info->name + ")";
438 }
Elliott Hughese1415a52018-02-15 09:18:21 -0800439 }
440 dump_memory(log, memory, reg_value, label);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700441 });
442}
443
Christopher Ferris60eb1972019-01-15 15:18:43 -0800444static bool dump_thread(log_t* log, unwindstack::Unwinder* unwinder, const ThreadInfo& thread_info,
445 uint64_t abort_msg_address, bool primary_thread) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700446 log->current_tid = thread_info.tid;
Josh Gao7c89f9e2016-01-13 17:57:14 -0800447 if (!primary_thread) {
Brigid Smith62ba4892014-06-10 11:53:08 -0700448 _LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
Josh Gao7c89f9e2016-01-13 17:57:14 -0800449 }
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700450 dump_thread_info(log, thread_info);
Christopher Ferris20303f82014-01-10 16:33:16 -0800451
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700452 if (thread_info.siginfo) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800453 dump_signal_info(log, thread_info, unwinder->GetProcessMemory().get());
454 dump_probable_cause(log, thread_info.siginfo, unwinder->GetMaps());
Josh Gao7c89f9e2016-01-13 17:57:14 -0800455 }
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700456
Josh Gao34c25562017-12-22 14:18:39 -0800457 if (primary_thread) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800458 dump_abort_message(log, unwinder->GetProcessMemory().get(), abort_msg_address);
Josh Gao34c25562017-12-22 14:18:39 -0800459 }
460
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700461 dump_registers(log, thread_info.registers.get());
462
Josh Gao5d1c14f2018-04-20 12:04:41 -0700463 // Unwind will mutate the registers, so make a copy first.
Christopher Ferris60eb1972019-01-15 15:18:43 -0800464 std::unique_ptr<unwindstack::Regs> regs_copy(thread_info.registers->Clone());
465 unwinder->SetRegs(regs_copy.get());
466 unwinder->Unwind();
467 if (unwinder->NumFrames() == 0) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700468 _LOG(log, logtype::THREAD, "Failed to unwind");
Christopher Ferris60eb1972019-01-15 15:18:43 -0800469 } else {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700470 _LOG(log, logtype::BACKTRACE, "\nbacktrace:\n");
Christopher Ferris60eb1972019-01-15 15:18:43 -0800471 dump_backtrace(log, unwinder, " ");
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700472
473 _LOG(log, logtype::STACK, "\nstack:\n");
Christopher Ferris60eb1972019-01-15 15:18:43 -0800474 dump_stack(log, unwinder->frames(), unwinder->GetMaps(), unwinder->GetProcessMemory().get());
Josh Gao7c89f9e2016-01-13 17:57:14 -0800475 }
Brigid Smith62ba4892014-06-10 11:53:08 -0700476
Josh Gao7c89f9e2016-01-13 17:57:14 -0800477 if (primary_thread) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800478 unwindstack::Maps* maps = unwinder->GetMaps();
479 dump_memory_and_code(log, maps, unwinder->GetProcessMemory().get(),
480 thread_info.registers.get());
481 if (maps != nullptr) {
Christopher Ferris7937a362018-01-18 11:15:49 -0800482 uint64_t addr = 0;
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700483 siginfo_t* si = thread_info.siginfo;
Elliott Hughes70d8f282018-04-25 17:00:14 -0700484 if (signal_has_si_addr(si)) {
Christopher Ferris7937a362018-01-18 11:15:49 -0800485 addr = reinterpret_cast<uint64_t>(si->si_addr);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700486 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800487 dump_all_maps(log, unwinder, addr);
Christopher Ferris20303f82014-01-10 16:33:16 -0800488 }
489 }
490
Josh Gao7c89f9e2016-01-13 17:57:14 -0800491 log->current_tid = log->crashed_tid;
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700492 return true;
Jeff Brown053b8652012-06-06 16:25:03 -0700493}
494
Christopher Ferris20303f82014-01-10 16:33:16 -0800495// Reads the contents of the specified log device, filters out the entries
496// that don't match the specified pid, and writes them to the tombstone file.
497//
Mark Salyzyn17e85c02014-06-27 15:55:19 -0700498// If "tail" is non-zero, log the last "tail" number of lines.
Mark Salyzyn989980c2014-05-14 12:37:22 -0700499static EventTagMap* g_eventTagMap = NULL;
500
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700501static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned int tail) {
Christopher Ferris20303f82014-01-10 16:33:16 -0800502 bool first = true;
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700503 logger_list* logger_list;
Jeff Brown053b8652012-06-06 16:25:03 -0700504
Mark Salyzyn45ae4462014-07-25 12:25:48 -0700505 if (!log->should_retrieve_logcat) {
506 return;
507 }
508
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800509 logger_list = android_logger_list_open(
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800510 android_name_to_log_id(filename), ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, tail, pid);
Jeff Brown053b8652012-06-06 16:25:03 -0700511
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800512 if (!logger_list) {
Brigid Smith50eb5462014-06-18 14:17:57 -0700513 ALOGE("Unable to open %s: %s\n", filename, strerror(errno));
Christopher Ferris20303f82014-01-10 16:33:16 -0800514 return;
515 }
516
Christopher Ferris20303f82014-01-10 16:33:16 -0800517 while (true) {
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700518 log_msg log_entry;
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800519 ssize_t actual = android_logger_list_read(logger_list, &log_entry);
520
Christopher Ferris20303f82014-01-10 16:33:16 -0800521 if (actual < 0) {
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800522 if (actual == -EINTR) {
Christopher Ferris20303f82014-01-10 16:33:16 -0800523 // interrupted by signal, retry
524 continue;
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800525 } else if (actual == -EAGAIN) {
Christopher Ferris20303f82014-01-10 16:33:16 -0800526 // non-blocking EOF; we're done
527 break;
528 } else {
Christopher Ferrisb36b5922015-06-17 18:35:59 -0700529 ALOGE("Error while reading log: %s\n", strerror(-actual));
Christopher Ferris20303f82014-01-10 16:33:16 -0800530 break;
531 }
532 } else if (actual == 0) {
Christopher Ferrisb36b5922015-06-17 18:35:59 -0700533 ALOGE("Got zero bytes while reading log: %s\n", strerror(errno));
Christopher Ferris20303f82014-01-10 16:33:16 -0800534 break;
Jeff Brown053b8652012-06-06 16:25:03 -0700535 }
536
Brigid Smith50eb5462014-06-18 14:17:57 -0700537 // NOTE: if you ALOGV something here, this will spin forever,
Christopher Ferris20303f82014-01-10 16:33:16 -0800538 // because you will be writing as fast as you're reading. Any
539 // high-frequency debug diagnostics should just be written to
540 // the tombstone file.
Jeff Brown053b8652012-06-06 16:25:03 -0700541
Christopher Ferris20303f82014-01-10 16:33:16 -0800542 if (first) {
Mark Salyzyne43290d2014-06-27 10:32:22 -0700543 _LOG(log, logtype::LOGS, "--------- %slog %s\n",
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800544 tail ? "tail end of " : "", filename);
Christopher Ferris20303f82014-01-10 16:33:16 -0800545 first = false;
546 }
547
548 // Msg format is: <priority:1><tag:N>\0<message:N>\0
549 //
550 // We want to display it in the same format as "logcat -v threadtime"
551 // (although in this case the pid is redundant).
Mark Salyzyn989980c2014-05-14 12:37:22 -0700552 char timeBuf[32];
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700553 time_t sec = static_cast<time_t>(log_entry.entry.sec);
Mark Salyzyn989980c2014-05-14 12:37:22 -0700554 struct tm tmBuf;
555 struct tm* ptm;
556 ptm = localtime_r(&sec, &tmBuf);
557 strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm);
558
559 if (log_entry.id() == LOG_ID_EVENTS) {
560 if (!g_eventTagMap) {
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700561 g_eventTagMap = android_openEventTagMap(nullptr);
Mark Salyzyn989980c2014-05-14 12:37:22 -0700562 }
563 AndroidLogEntry e;
564 char buf[512];
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700565 if (android_log_processBinaryLogBuffer(&log_entry.entry_v1, &e, g_eventTagMap, buf,
566 sizeof(buf)) == 0) {
567 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n", timeBuf,
568 log_entry.entry.nsec / 1000000, log_entry.entry.pid, log_entry.entry.tid, 'I',
569 (int)e.tagLen, e.tag, e.message);
570 }
Mark Salyzyn989980c2014-05-14 12:37:22 -0700571 continue;
572 }
573
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700574 char* msg = log_entry.msg();
575 if (msg == nullptr) {
576 continue;
577 }
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800578 unsigned char prio = msg[0];
579 char* tag = msg + 1;
580 msg = tag + strlen(tag) + 1;
Christopher Ferris20303f82014-01-10 16:33:16 -0800581
582 // consume any trailing newlines
Mark Salyzynfca0bd12013-12-12 12:21:20 -0800583 char* nl = msg + strlen(msg) - 1;
584 while (nl >= msg && *nl == '\n') {
Mark Salyzyn17e85c02014-06-27 15:55:19 -0700585 *nl-- = '\0';
Christopher Ferris20303f82014-01-10 16:33:16 -0800586 }
587
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700588 static const char* kPrioChars = "!.VDIWEFS";
Christopher Ferris20303f82014-01-10 16:33:16 -0800589 char prioChar = (prio < strlen(kPrioChars) ? kPrioChars[prio] : '?');
590
Mark Salyzynfca0bd12013-12-12 12:21:20 -0800591 // Look for line breaks ('\n') and display each text line
592 // on a separate line, prefixed with the header, like logcat does.
593 do {
594 nl = strchr(msg, '\n');
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700595 if (nl != nullptr) {
Mark Salyzynfca0bd12013-12-12 12:21:20 -0800596 *nl = '\0';
597 ++nl;
598 }
599
Christopher Ferrisc637ada2018-07-13 16:55:38 -0700600 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n", timeBuf,
601 log_entry.entry.nsec / 1000000, log_entry.entry.pid, log_entry.entry.tid, prioChar, tag,
602 msg);
Mark Salyzynfca0bd12013-12-12 12:21:20 -0800603 } while ((msg = nl));
Christopher Ferris20303f82014-01-10 16:33:16 -0800604 }
Jeff Brown053b8652012-06-06 16:25:03 -0700605
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800606 android_logger_list_free(logger_list);
Jeff Brown053b8652012-06-06 16:25:03 -0700607}
608
Christopher Ferris20303f82014-01-10 16:33:16 -0800609// Dumps the logs generated by the specified pid to the tombstone, from both
610// "system" and "main" log devices. Ideally we'd interleave the output.
Mark Salyzyn17e85c02014-06-27 15:55:19 -0700611static void dump_logs(log_t* log, pid_t pid, unsigned int tail) {
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700612 if (pid == getpid()) {
613 // Cowardly refuse to dump logs while we're running in-process.
614 return;
615 }
616
Mark Salyzyn22b5cef2013-11-22 10:53:34 -0800617 dump_log_file(log, pid, "system", tail);
618 dump_log_file(log, pid, "main", tail);
Jeff Brown053b8652012-06-06 16:25:03 -0700619}
620
Christopher Ferris7937a362018-01-18 11:15:49 -0800621void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo,
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800622 ucontext_t* ucontext) {
623 pid_t pid = getpid();
624 pid_t tid = gettid();
625
Josh Gaoe73c9322017-02-08 16:06:26 -0800626 log_t log;
627 log.current_tid = tid;
628 log.crashed_tid = tid;
629 log.tfd = tombstone_fd;
630 log.amfd_data = nullptr;
631
Josh Gao57f58f82017-03-15 23:23:22 -0700632 char thread_name[16];
633 char process_name[128];
634
635 read_with_default("/proc/self/comm", thread_name, sizeof(thread_name), "<unknown>");
636 read_with_default("/proc/self/cmdline", process_name, sizeof(process_name), "<unknown>");
637
Christopher Ferris60eb1972019-01-15 15:18:43 -0800638 std::unique_ptr<unwindstack::Regs> regs(
639 unwindstack::Regs::CreateFromUcontext(unwindstack::Regs::CurrentArch(), ucontext));
Josh Gaoe73c9322017-02-08 16:06:26 -0800640
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700641 std::map<pid_t, ThreadInfo> threads;
642 threads[gettid()] = ThreadInfo{
643 .registers = std::move(regs),
644 .tid = tid,
645 .thread_name = thread_name,
646 .pid = pid,
647 .process_name = process_name,
648 .siginfo = siginfo,
649 };
Josh Gao77b00ed2017-05-05 18:11:23 -0700650
Christopher Ferris60eb1972019-01-15 15:18:43 -0800651 unwindstack::UnwinderFromPid unwinder(kMaxFrames, pid);
David Srbecky85b5fec2018-02-23 18:06:13 +0000652 if (!unwinder.Init()) {
Christopher Ferris60eb1972019-01-15 15:18:43 -0800653 LOG(FATAL) << "Failed to init unwinder object.";
Josh Gaoe73c9322017-02-08 16:06:26 -0800654 }
Josh Gaofdc95c92017-09-13 15:33:39 -0700655
Christopher Ferris60eb1972019-01-15 15:18:43 -0800656 engrave_tombstone(unique_fd(dup(tombstone_fd)), &unwinder, threads, tid, abort_msg_address,
657 nullptr, nullptr);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700658}
659
Christopher Ferris60eb1972019-01-15 15:18:43 -0800660void engrave_tombstone(unique_fd output_fd, unwindstack::Unwinder* unwinder,
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700661 const std::map<pid_t, ThreadInfo>& threads, pid_t target_thread,
Christopher Ferris7937a362018-01-18 11:15:49 -0800662 uint64_t abort_msg_address, OpenFilesList* open_files,
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700663 std::string* amfd_data) {
664 // don't copy log messages to tombstone unless this is a dev device
665 bool want_logs = android::base::GetBoolProperty("ro.debuggable", false);
666
667 log_t log;
668 log.current_tid = target_thread;
669 log.crashed_tid = target_thread;
670 log.tfd = output_fd.get();
671 log.amfd_data = amfd_data;
672
673 _LOG(&log, logtype::HEADER, "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
674 dump_header_info(&log);
Josh Gao6f4644d2018-12-14 13:05:12 -0800675 dump_timestamp(&log, time(nullptr));
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700676
677 auto it = threads.find(target_thread);
678 if (it == threads.end()) {
679 LOG(FATAL) << "failed to find target thread";
680 }
Christopher Ferris60eb1972019-01-15 15:18:43 -0800681 dump_thread(&log, unwinder, it->second, abort_msg_address, true);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700682
683 if (want_logs) {
chirag honnavardef08882017-04-20 18:22:06 +0900684 dump_logs(&log, it->second.pid, 50);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700685 }
686
687 for (auto& [tid, thread_info] : threads) {
688 if (tid == target_thread) {
689 continue;
Josh Gaofdc95c92017-09-13 15:33:39 -0700690 }
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700691
Christopher Ferris60eb1972019-01-15 15:18:43 -0800692 dump_thread(&log, unwinder, thread_info, 0, false);
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700693 }
694
695 if (open_files) {
696 _LOG(&log, logtype::OPEN_FILES, "\nopen files:\n");
697 dump_open_files_list(&log, *open_files, " ");
698 }
699
700 if (want_logs) {
701 dump_logs(&log, it->second.pid, 0);
Josh Gaofdc95c92017-09-13 15:33:39 -0700702 }
Josh Gaoe73c9322017-02-08 16:06:26 -0800703}