From 7937a36c8e24ef2dc5105a2a6b67f395934b2e2f Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Thu, 18 Jan 2018 11:15:49 -0800 Subject: Change all uintptr_t to uint64_t in API. In order to support the offline unwinding properly, get rid of the usage of non-fixed type uintptr_t from all API calls. In addition, completely remove the old local and remote unwinding code that used libunwind. The next step will be to move the offline unwinding to the new unwinder. Bug: 65682279 Test: Ran unit tests for libbacktrace/debuggerd. Test: Ran debuggerd -b on a few arm and arm64 processes. Test: Ran crasher and crasher64 and verified tombstones look correct. Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33 --- .../libdebuggerd/include/libdebuggerd/tombstone.h | 6 ++-- .../libdebuggerd/include/libdebuggerd/utility.h | 2 +- debuggerd/libdebuggerd/test/tombstone_test.cpp | 4 +-- debuggerd/libdebuggerd/tombstone.cpp | 36 +++++++++++----------- debuggerd/libdebuggerd/utility.cpp | 6 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'debuggerd') diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h b/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h index 198c48b26..be90d0f0b 100644 --- a/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h +++ b/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h @@ -40,16 +40,16 @@ int open_tombstone(std::string* path); /* Creates a tombstone file and writes the crash dump to it. */ void engrave_tombstone(int tombstone_fd, BacktraceMap* map, const OpenFilesList* open_files, pid_t pid, pid_t tid, const std::string& process_name, - const std::map& threads, uintptr_t abort_msg_address, + const std::map& threads, uint64_t abort_msg_address, std::string* amfd_data); -void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo, +void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo, ucontext_t* ucontext); void engrave_tombstone(android::base::unique_fd output_fd, BacktraceMap* map, unwindstack::Memory* process_memory, const std::map& thread_info, pid_t target_thread, - uintptr_t abort_msg_address, OpenFilesList* open_files, + uint64_t abort_msg_address, OpenFilesList* open_files, std::string* amfd_data); #endif // _DEBUGGERD_TOMBSTONE_H diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/utility.h b/debuggerd/libdebuggerd/include/libdebuggerd/utility.h index c5abfe24f..0f049fd25 100644 --- a/debuggerd/libdebuggerd/include/libdebuggerd/utility.h +++ b/debuggerd/libdebuggerd/include/libdebuggerd/utility.h @@ -68,7 +68,7 @@ namespace unwindstack { class Memory; } -void dump_memory(log_t* log, unwindstack::Memory* backtrace, uintptr_t addr, const char* fmt, ...); +void dump_memory(log_t* log, unwindstack::Memory* backtrace, uint64_t addr, const char* fmt, ...); void read_with_default(const char* path, char* buf, size_t len, const char* default_value); diff --git a/debuggerd/libdebuggerd/test/tombstone_test.cpp b/debuggerd/libdebuggerd/test/tombstone_test.cpp index 1e3a10f08..421ce43c0 100644 --- a/debuggerd/libdebuggerd/test/tombstone_test.cpp +++ b/debuggerd/libdebuggerd/test/tombstone_test.cpp @@ -437,9 +437,9 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_after) { map_mock_->AddMap(map); #if defined(__LP64__) - uintptr_t addr = 0x12345a534040UL; + uint64_t addr = 0x12345a534040UL; #else - uintptr_t addr = 0xf534040UL; + uint64_t addr = 0xf534040UL; #endif dump_all_maps(&log_, map_mock_.get(), nullptr, addr); diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index 89a125b80..320e5dbb9 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -127,7 +127,7 @@ static void dump_thread_info(log_t* log, const ThreadInfo& thread_info) { } static void dump_stack_segment(log_t* log, BacktraceMap* backtrace_map, Memory* process_memory, - uintptr_t* sp, size_t words, int label) { + uint64_t* sp, size_t words, int label) { // Read the data all at once. word_t stack_data[words]; @@ -144,18 +144,18 @@ static void dump_stack_segment(log_t* log, BacktraceMap* backtrace_map, Memory* } else { line += " "; } - line += StringPrintf("%" PRIPTR " %" PRIPTR, *sp, stack_data[i]); + line += StringPrintf("%" PRIPTR " %" PRIxPTR, *sp, stack_data[i]); backtrace_map_t map; backtrace_map->FillIn(stack_data[i], &map); if (BacktraceMap::IsValid(map) && !map.name.empty()) { line += " " + map.name; - uintptr_t offset = 0; + uint64_t offset = 0; std::string func_name = backtrace_map->GetFunctionName(stack_data[i], &offset); if (!func_name.empty()) { line += " (" + func_name; if (offset) { - line += StringPrintf("+%" PRIuPTR, offset); + line += StringPrintf("+%" PRIu64, offset); } line += ')'; } @@ -185,7 +185,7 @@ static void dump_stack(log_t* log, BacktraceMap* backtrace_map, Memory* process_ first--; // Dump a few words before the first frame. - word_t sp = frames[first].sp - STACK_WORDS * sizeof(word_t); + uint64_t sp = frames[first].sp - STACK_WORDS * sizeof(word_t); dump_stack_segment(log, backtrace_map, process_memory, &sp, STACK_WORDS, -1); // Dump a few words from all successive frames. @@ -213,19 +213,19 @@ static void dump_stack(log_t* log, BacktraceMap* backtrace_map, Memory* process_ } } -static std::string get_addr_string(uintptr_t addr) { +static std::string get_addr_string(uint64_t addr) { std::string addr_str; #if defined(__LP64__) addr_str = StringPrintf("%08x'%08x", static_cast(addr >> 32), static_cast(addr & 0xffffffff)); #else - addr_str = StringPrintf("%08x", addr); + addr_str = StringPrintf("%08x", static_cast(addr)); #endif return addr_str; } -static void dump_abort_message(log_t* log, Memory* process_memory, uintptr_t address) { +static void dump_abort_message(log_t* log, Memory* process_memory, uint64_t address) { if (address == 0) { return; } @@ -251,7 +251,7 @@ static void dump_abort_message(log_t* log, Memory* process_memory, uintptr_t add _LOG(log, logtype::HEADER, "Abort message: '%s'\n", msg); } -static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, uintptr_t addr) { +static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, uint64_t addr) { bool print_fault_address_marker = addr; ScopedBacktraceMapIteratorLock lock(map); @@ -301,7 +301,7 @@ static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, } else { line += '-'; } - line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, entry->offset, entry->end - entry->start); + line += StringPrintf(" %8" PRIx64 " %8" PRIx64, entry->offset, entry->end - entry->start); bool space_needed = true; if (entry->name.length() > 0) { space_needed = false; @@ -315,7 +315,7 @@ static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, if (space_needed) { line += ' '; } - line += StringPrintf(" (load bias 0x%" PRIxPTR ")", entry->load_bias); + line += StringPrintf(" (load bias 0x%" PRIx64 ")", entry->load_bias); } _LOG(log, logtype::MAPS, "%s\n", line.c_str()); } @@ -335,9 +335,9 @@ static void print_register_row(log_t* log, const std::vector>& registers) { std::string output; for (auto& [name, value] : registers) { - output += android::base::StringPrintf(" %-3s %0*" PRIxPTR, name.c_str(), + output += android::base::StringPrintf(" %-3s %0*" PRIx64, name.c_str(), static_cast(2 * sizeof(void*)), - static_cast(value)); + static_cast(value)); } _LOG(log, logtype::REGISTERS, " %s\n", output.c_str()); @@ -389,7 +389,7 @@ void dump_memory_and_code(log_t* log, Memory* memory, Regs* regs) { } static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory, - const ThreadInfo& thread_info, uintptr_t abort_msg_address, + const ThreadInfo& thread_info, uint64_t abort_msg_address, bool primary_thread) { UNUSED(process_memory); log->current_tid = thread_info.tid; @@ -425,10 +425,10 @@ static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory, if (primary_thread) { dump_memory_and_code(log, process_memory, thread_info.registers.get()); if (map) { - uintptr_t addr = 0; + uint64_t addr = 0; siginfo_t* si = thread_info.siginfo; if (signal_has_si_addr(si->si_signo, si->si_code)) { - addr = reinterpret_cast(si->si_addr); + addr = reinterpret_cast(si->si_addr); } dump_all_maps(log, map, process_memory, addr); } @@ -572,7 +572,7 @@ static void dump_logs(log_t* log, pid_t pid, unsigned int tail) { dump_log_file(log, pid, "main", tail); } -void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo, +void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo, ucontext_t* ucontext) { pid_t pid = getpid(); pid_t tid = gettid(); @@ -614,7 +614,7 @@ void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, s void engrave_tombstone(unique_fd output_fd, BacktraceMap* map, Memory* process_memory, const std::map& threads, pid_t target_thread, - uintptr_t abort_msg_address, OpenFilesList* open_files, + uint64_t abort_msg_address, OpenFilesList* open_files, std::string* amfd_data) { // don't copy log messages to tombstone unless this is a dev device bool want_logs = android::base::GetBoolProperty("ro.debuggable", false); diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp index 247d806ba..3ac98f58f 100644 --- a/debuggerd/libdebuggerd/utility.cpp +++ b/debuggerd/libdebuggerd/utility.cpp @@ -124,7 +124,7 @@ void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) { #define MEMORY_BYTES_TO_DUMP 256 #define MEMORY_BYTES_PER_LINE 16 -void dump_memory(log_t* log, unwindstack::Memory* memory, uintptr_t addr, const char* fmt, ...) { +void dump_memory(log_t* log, unwindstack::Memory* memory, uint64_t addr, const char* fmt, ...) { std::string log_msg; va_list ap; va_start(ap, fmt); @@ -159,7 +159,7 @@ void dump_memory(log_t* log, unwindstack::Memory* memory, uintptr_t addr, const bytes &= ~(sizeof(uintptr_t) - 1); } - uintptr_t start = 0; + uint64_t start = 0; bool skip_2nd_read = false; if (bytes == 0) { // In this case, we might want to try another read at the beginning of @@ -206,7 +206,7 @@ void dump_memory(log_t* log, unwindstack::Memory* memory, uintptr_t addr, const std::string ascii; for (size_t i = 0; i < MEMORY_BYTES_PER_LINE / sizeof(uintptr_t); i++) { if (current >= start && current + sizeof(uintptr_t) <= total_bytes) { - android::base::StringAppendF(&logline, " %" PRIPTR, *data_ptr); + android::base::StringAppendF(&logline, " %" PRIPTR, static_cast(*data_ptr)); // Fill out the ascii string from the data. uint8_t* ptr = reinterpret_cast(data_ptr); -- cgit v1.2.3-54-g00ecf