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
diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h b/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h
index 198c48b..be90d0f 100644
--- a/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h
+++ b/debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h
@@ -40,16 +40,16 @@
 /* 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<pid_t, std::string>& threads, uintptr_t abort_msg_address,
+                       const std::map<pid_t, std::string>& 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<pid_t, ThreadInfo>& 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 c5abfe2..0f049fd 100644
--- a/debuggerd/libdebuggerd/include/libdebuggerd/utility.h
+++ b/debuggerd/libdebuggerd/include/libdebuggerd/utility.h
@@ -68,7 +68,7 @@
 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 1e3a10f..421ce43 100644
--- a/debuggerd/libdebuggerd/test/tombstone_test.cpp
+++ b/debuggerd/libdebuggerd/test/tombstone_test.cpp
@@ -437,9 +437,9 @@
   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 89a125b..320e5db 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -127,7 +127,7 @@
 }
 
 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 @@
     } 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 @@
   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 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<uint32_t>(addr >> 32),
                           static_cast<uint32_t>(addr & 0xffffffff));
 #else
-  addr_str = StringPrintf("%08x", addr);
+  addr_str = StringPrintf("%08x", static_cast<uint32_t>(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 @@
   _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 @@
     } 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 @@
       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 @@
                                const std::vector<std::pair<std::string, uint64_t>>& 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<int>(2 * sizeof(void*)),
-                                          static_cast<uintptr_t>(value));
+                                          static_cast<uint64_t>(value));
   }
 
   _LOG(log, logtype::REGISTERS, "  %s\n", output.c_str());
@@ -389,7 +389,7 @@
 }
 
 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 @@
   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<uintptr_t>(si->si_addr);
+        addr = reinterpret_cast<uint64_t>(si->si_addr);
       }
       dump_all_maps(log, map, process_memory, addr);
     }
@@ -572,7 +572,7 @@
   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(unique_fd output_fd, BacktraceMap* map, Memory* process_memory,
                        const std::map<pid_t, ThreadInfo>& 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 247d806..3ac98f5 100644
--- a/debuggerd/libdebuggerd/utility.cpp
+++ b/debuggerd/libdebuggerd/utility.cpp
@@ -124,7 +124,7 @@
 #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 @@
     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 @@
     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<uint64_t>(*data_ptr));
 
         // Fill out the ascii string from the data.
         uint8_t* ptr = reinterpret_cast<uint8_t*>(data_ptr);