diff options
Diffstat (limited to 'debuggerd')
-rw-r--r-- | debuggerd/Android.bp | 26 | ||||
-rw-r--r-- | debuggerd/handler/debuggerd_handler.cpp | 2 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/gwp_asan.cpp | 63 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/tombstone.cpp | 21 |
4 files changed, 20 insertions, 92 deletions
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp index f28c778fe..d67b52277 100644 --- a/debuggerd/Android.bp +++ b/debuggerd/Android.bp @@ -103,9 +103,14 @@ cc_library_static { export_include_dirs: ["include"], } -// Fallback implementation. +// Fallback implementation, for use in the Bionic linker only. cc_library_static { name: "libdebuggerd_handler_fallback", + visibility: ["//bionic/linker"], + apex_available: [ + "com.android.runtime", + "//apex_available:platform", + ], defaults: ["debuggerd_defaults"], recovery_available: true, srcs: [ @@ -118,8 +123,7 @@ cc_library_static { "libasync_safe", "libbase", "libdebuggerd", - "libunwindstack", - "libdexfile_support_static", // libunwindstack dependency + "libunwindstack_no_dex", "liblzma", "libcutils", ], @@ -127,14 +131,6 @@ cc_library_static { header_libs: ["bionic_libc_platform_headers"], export_header_lib_headers: ["bionic_libc_platform_headers"], - target: { - recovery: { - exclude_static_libs: [ - "libdexfile_support_static", - ], - }, - }, - export_include_dirs: ["include"], } @@ -188,7 +184,7 @@ cc_library_static { ], static_libs: [ - "libdexfile_support_static", // libunwindstack dependency + "libdexfile_support", // libunwindstack dependency "libunwindstack", "liblzma", "libbase", @@ -201,7 +197,7 @@ cc_library_static { target: { recovery: { exclude_static_libs: [ - "libdexfile_support_static", + "libdexfile_support", ], }, }, @@ -321,6 +317,10 @@ cc_binary { "libprocinfo", "libunwindstack", ], + + apex_available: [ + "com.android.runtime", + ], } cc_binary { diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp index 003c3d9a6..ac28fe907 100644 --- a/debuggerd/handler/debuggerd_handler.cpp +++ b/debuggerd/handler/debuggerd_handler.cpp @@ -83,7 +83,7 @@ using unique_fd = android::base::unique_fd_impl<FdsanBypassCloser>; #define CRASH_DUMP_NAME "crash_dump32" #endif -#define CRASH_DUMP_PATH "/system/bin/" CRASH_DUMP_NAME +#define CRASH_DUMP_PATH "/apex/com.android.runtime/bin/" CRASH_DUMP_NAME // Wrappers that directly invoke the respective syscalls, in case the cached values are invalid. #pragma GCC poison getpid gettid diff --git a/debuggerd/libdebuggerd/gwp_asan.cpp b/debuggerd/libdebuggerd/gwp_asan.cpp index fe3a1730d..f27136558 100644 --- a/debuggerd/libdebuggerd/gwp_asan.cpp +++ b/debuggerd/libdebuggerd/gwp_asan.cpp @@ -157,63 +157,6 @@ void GwpAsanCrashData::DumpCause(log_t* log) const { error_string_, diff, byte_suffix, location_str, alloc_size, alloc_address); } -// Build a frame for symbolization using the maps from the provided unwinder. -// The constructed frame contains just enough information to be used to -// symbolize a GWP-ASan stack trace. -static unwindstack::FrameData BuildFrame(unwindstack::Unwinder* unwinder, uintptr_t pc, - size_t frame_num) { - unwindstack::FrameData frame; - frame.num = frame_num; - - unwindstack::Maps* maps = unwinder->GetMaps(); - unwindstack::MapInfo* map_info = maps->Find(pc); - if (!map_info) { - frame.rel_pc = pc; - return frame; - } - - unwindstack::Elf* elf = - map_info->GetElf(unwinder->GetProcessMemory(), unwindstack::Regs::CurrentArch()); - - uint64_t relative_pc = elf->GetRelPc(pc, map_info); - - // Create registers just to get PC adjustment. Doesn't matter what they point - // to. - unwindstack::Regs* regs = unwindstack::Regs::CreateFromLocal(); - uint64_t pc_adjustment = regs->GetPcAdjustment(relative_pc, elf); - relative_pc -= pc_adjustment; - // The debug PC may be different if the PC comes from the JIT. - uint64_t debug_pc = relative_pc; - - // If we don't have a valid ELF file, check the JIT. - if (!elf->valid()) { - unwindstack::JitDebug jit_debug(unwinder->GetProcessMemory()); - uint64_t jit_pc = pc - pc_adjustment; - unwindstack::Elf* jit_elf = jit_debug.GetElf(maps, jit_pc); - if (jit_elf != nullptr) { - debug_pc = jit_pc; - elf = jit_elf; - } - } - - // Copy all the things we need into the frame for symbolization. - frame.rel_pc = relative_pc; - frame.pc = pc - pc_adjustment; - frame.map_name = map_info->name; - frame.map_elf_start_offset = map_info->elf_start_offset; - frame.map_exact_offset = map_info->offset; - frame.map_start = map_info->start; - frame.map_end = map_info->end; - frame.map_flags = map_info->flags; - frame.map_load_bias = elf->GetLoadBias(); - - if (!elf->GetFunctionName(relative_pc, &frame.function_name, &frame.function_offset)) { - frame.function_name = ""; - frame.function_offset = 0; - } - return frame; -} - constexpr size_t kMaxTraceLength = gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect; bool GwpAsanCrashData::HasDeallocationTrace() const { @@ -240,7 +183,8 @@ void GwpAsanCrashData::DumpDeallocationTrace(log_t* log, unwindstack::Unwinder* unwinder->SetDisplayBuildID(true); for (size_t i = 0; i < num_frames; ++i) { - unwindstack::FrameData frame_data = BuildFrame(unwinder, frames.get()[i], i); + unwindstack::FrameData frame_data = unwinder->BuildFrameFromPcOnly(frames.get()[i]); + frame_data.num = i; _LOG(log, logtype::BACKTRACE, " %s\n", unwinder->FormatFrame(frame_data).c_str()); } } @@ -266,7 +210,8 @@ void GwpAsanCrashData::DumpAllocationTrace(log_t* log, unwindstack::Unwinder* un unwinder->SetDisplayBuildID(true); for (size_t i = 0; i < num_frames; ++i) { - unwindstack::FrameData frame_data = BuildFrame(unwinder, frames.get()[i], i); + unwindstack::FrameData frame_data = unwinder->BuildFrameFromPcOnly(frames.get()[i]); + frame_data.num = i; _LOG(log, logtype::BACKTRACE, " %s\n", unwinder->FormatFrame(frame_data).c_str()); } } diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index 70b8817be..e0168d539 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -447,8 +447,6 @@ static bool dump_thread(log_t* log, unwindstack::Unwinder* unwinder, const Threa // that don't match the specified pid, and writes them to the tombstone file. // // If "tail" is non-zero, log the last "tail" number of lines. -static EventTagMap* g_eventTagMap = NULL; - static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned int tail) { bool first = true; logger_list* logger_list; @@ -457,8 +455,8 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned return; } - logger_list = android_logger_list_open( - android_name_to_log_id(filename), ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, tail, pid); + logger_list = + android_logger_list_open(android_name_to_log_id(filename), ANDROID_LOG_NONBLOCK, tail, pid); if (!logger_list) { ALOGE("Unable to open %s: %s\n", filename, strerror(errno)); @@ -507,21 +505,6 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned ptm = localtime_r(&sec, &tmBuf); strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm); - if (log_entry.id() == LOG_ID_EVENTS) { - if (!g_eventTagMap) { - g_eventTagMap = android_openEventTagMap(nullptr); - } - AndroidLogEntry e; - char buf[512]; - if (android_log_processBinaryLogBuffer(&log_entry.entry, &e, g_eventTagMap, buf, - sizeof(buf)) == 0) { - _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n", timeBuf, - log_entry.entry.nsec / 1000000, log_entry.entry.pid, log_entry.entry.tid, 'I', - (int)e.tagLen, e.tag, e.message); - } - continue; - } - char* msg = log_entry.msg(); if (msg == nullptr) { continue; |