summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris2018-01-18 13:15:49 -0600
committerChristopher Ferris2018-01-18 19:26:20 -0600
commit7937a36c8e24ef2dc5105a2a6b67f395934b2e2f (patch)
treec41fda20166f7166c5f17dc881da3ec5d8c3b25d /debuggerd
parent2c4f487dfbf1e1cce6e887bfef5e864f8222d07f (diff)
downloadplatform-system-core-7937a36c8e24ef2dc5105a2a6b67f395934b2e2f.tar.gz
platform-system-core-7937a36c8e24ef2dc5105a2a6b67f395934b2e2f.tar.xz
platform-system-core-7937a36c8e24ef2dc5105a2a6b67f395934b2e2f.zip
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
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/libdebuggerd/include/libdebuggerd/tombstone.h6
-rw-r--r--debuggerd/libdebuggerd/include/libdebuggerd/utility.h2
-rw-r--r--debuggerd/libdebuggerd/test/tombstone_test.cpp4
-rw-r--r--debuggerd/libdebuggerd/tombstone.cpp36
-rw-r--r--debuggerd/libdebuggerd/utility.cpp6
5 files changed, 27 insertions, 27 deletions
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);
40/* Creates a tombstone file and writes the crash dump to it. */ 40/* Creates a tombstone file and writes the crash dump to it. */
41void engrave_tombstone(int tombstone_fd, BacktraceMap* map, const OpenFilesList* open_files, 41void engrave_tombstone(int tombstone_fd, BacktraceMap* map, const OpenFilesList* open_files,
42 pid_t pid, pid_t tid, const std::string& process_name, 42 pid_t pid, pid_t tid, const std::string& process_name,
43 const std::map<pid_t, std::string>& threads, uintptr_t abort_msg_address, 43 const std::map<pid_t, std::string>& threads, uint64_t abort_msg_address,
44 std::string* amfd_data); 44 std::string* amfd_data);
45 45
46void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo, 46void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo,
47 ucontext_t* ucontext); 47 ucontext_t* ucontext);
48 48
49void engrave_tombstone(android::base::unique_fd output_fd, BacktraceMap* map, 49void engrave_tombstone(android::base::unique_fd output_fd, BacktraceMap* map,
50 unwindstack::Memory* process_memory, 50 unwindstack::Memory* process_memory,
51 const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread, 51 const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread,
52 uintptr_t abort_msg_address, OpenFilesList* open_files, 52 uint64_t abort_msg_address, OpenFilesList* open_files,
53 std::string* amfd_data); 53 std::string* amfd_data);
54 54
55#endif // _DEBUGGERD_TOMBSTONE_H 55#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 {
68class Memory; 68class Memory;
69} 69}
70 70
71void dump_memory(log_t* log, unwindstack::Memory* backtrace, uintptr_t addr, const char* fmt, ...); 71void dump_memory(log_t* log, unwindstack::Memory* backtrace, uint64_t addr, const char* fmt, ...);
72 72
73void read_with_default(const char* path, char* buf, size_t len, const char* default_value); 73void read_with_default(const char* path, char* buf, size_t len, const char* default_value);
74 74
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) {
437 map_mock_->AddMap(map); 437 map_mock_->AddMap(map);
438 438
439#if defined(__LP64__) 439#if defined(__LP64__)
440 uintptr_t addr = 0x12345a534040UL; 440 uint64_t addr = 0x12345a534040UL;
441#else 441#else
442 uintptr_t addr = 0xf534040UL; 442 uint64_t addr = 0xf534040UL;
443#endif 443#endif
444 dump_all_maps(&log_, map_mock_.get(), nullptr, addr); 444 dump_all_maps(&log_, map_mock_.get(), nullptr, addr);
445 445
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) {
127} 127}
128 128
129static void dump_stack_segment(log_t* log, BacktraceMap* backtrace_map, Memory* process_memory, 129static void dump_stack_segment(log_t* log, BacktraceMap* backtrace_map, Memory* process_memory,
130 uintptr_t* sp, size_t words, int label) { 130 uint64_t* sp, size_t words, int label) {
131 // Read the data all at once. 131 // Read the data all at once.
132 word_t stack_data[words]; 132 word_t stack_data[words];
133 133
@@ -144,18 +144,18 @@ static void dump_stack_segment(log_t* log, BacktraceMap* backtrace_map, Memory*
144 } else { 144 } else {
145 line += " "; 145 line += " ";
146 } 146 }
147 line += StringPrintf("%" PRIPTR " %" PRIPTR, *sp, stack_data[i]); 147 line += StringPrintf("%" PRIPTR " %" PRIxPTR, *sp, stack_data[i]);
148 148
149 backtrace_map_t map; 149 backtrace_map_t map;
150 backtrace_map->FillIn(stack_data[i], &map); 150 backtrace_map->FillIn(stack_data[i], &map);
151 if (BacktraceMap::IsValid(map) && !map.name.empty()) { 151 if (BacktraceMap::IsValid(map) && !map.name.empty()) {
152 line += " " + map.name; 152 line += " " + map.name;
153 uintptr_t offset = 0; 153 uint64_t offset = 0;
154 std::string func_name = backtrace_map->GetFunctionName(stack_data[i], &offset); 154 std::string func_name = backtrace_map->GetFunctionName(stack_data[i], &offset);
155 if (!func_name.empty()) { 155 if (!func_name.empty()) {
156 line += " (" + func_name; 156 line += " (" + func_name;
157 if (offset) { 157 if (offset) {
158 line += StringPrintf("+%" PRIuPTR, offset); 158 line += StringPrintf("+%" PRIu64, offset);
159 } 159 }
160 line += ')'; 160 line += ')';
161 } 161 }
@@ -185,7 +185,7 @@ static void dump_stack(log_t* log, BacktraceMap* backtrace_map, Memory* process_
185 first--; 185 first--;
186 186
187 // Dump a few words before the first frame. 187 // Dump a few words before the first frame.
188 word_t sp = frames[first].sp - STACK_WORDS * sizeof(word_t); 188 uint64_t sp = frames[first].sp - STACK_WORDS * sizeof(word_t);
189 dump_stack_segment(log, backtrace_map, process_memory, &sp, STACK_WORDS, -1); 189 dump_stack_segment(log, backtrace_map, process_memory, &sp, STACK_WORDS, -1);
190 190
191 // Dump a few words from all successive frames. 191 // Dump a few words from all successive frames.
@@ -213,19 +213,19 @@ static void dump_stack(log_t* log, BacktraceMap* backtrace_map, Memory* process_
213 } 213 }
214} 214}
215 215
216static std::string get_addr_string(uintptr_t addr) { 216static std::string get_addr_string(uint64_t addr) {
217 std::string addr_str; 217 std::string addr_str;
218#if defined(__LP64__) 218#if defined(__LP64__)
219 addr_str = StringPrintf("%08x'%08x", 219 addr_str = StringPrintf("%08x'%08x",
220 static_cast<uint32_t>(addr >> 32), 220 static_cast<uint32_t>(addr >> 32),
221 static_cast<uint32_t>(addr & 0xffffffff)); 221 static_cast<uint32_t>(addr & 0xffffffff));
222#else 222#else
223 addr_str = StringPrintf("%08x", addr); 223 addr_str = StringPrintf("%08x", static_cast<uint32_t>(addr));
224#endif 224#endif
225 return addr_str; 225 return addr_str;
226} 226}
227 227
228static void dump_abort_message(log_t* log, Memory* process_memory, uintptr_t address) { 228static void dump_abort_message(log_t* log, Memory* process_memory, uint64_t address) {
229 if (address == 0) { 229 if (address == 0) {
230 return; 230 return;
231 } 231 }
@@ -251,7 +251,7 @@ static void dump_abort_message(log_t* log, Memory* process_memory, uintptr_t add
251 _LOG(log, logtype::HEADER, "Abort message: '%s'\n", msg); 251 _LOG(log, logtype::HEADER, "Abort message: '%s'\n", msg);
252} 252}
253 253
254static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, uintptr_t addr) { 254static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory, uint64_t addr) {
255 bool print_fault_address_marker = addr; 255 bool print_fault_address_marker = addr;
256 256
257 ScopedBacktraceMapIteratorLock lock(map); 257 ScopedBacktraceMapIteratorLock lock(map);
@@ -301,7 +301,7 @@ static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory,
301 } else { 301 } else {
302 line += '-'; 302 line += '-';
303 } 303 }
304 line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, entry->offset, entry->end - entry->start); 304 line += StringPrintf(" %8" PRIx64 " %8" PRIx64, entry->offset, entry->end - entry->start);
305 bool space_needed = true; 305 bool space_needed = true;
306 if (entry->name.length() > 0) { 306 if (entry->name.length() > 0) {
307 space_needed = false; 307 space_needed = false;
@@ -315,7 +315,7 @@ static void dump_all_maps(log_t* log, BacktraceMap* map, Memory* process_memory,
315 if (space_needed) { 315 if (space_needed) {
316 line += ' '; 316 line += ' ';
317 } 317 }
318 line += StringPrintf(" (load bias 0x%" PRIxPTR ")", entry->load_bias); 318 line += StringPrintf(" (load bias 0x%" PRIx64 ")", entry->load_bias);
319 } 319 }
320 _LOG(log, logtype::MAPS, "%s\n", line.c_str()); 320 _LOG(log, logtype::MAPS, "%s\n", line.c_str());
321 } 321 }
@@ -335,9 +335,9 @@ static void print_register_row(log_t* log,
335 const std::vector<std::pair<std::string, uint64_t>>& registers) { 335 const std::vector<std::pair<std::string, uint64_t>>& registers) {
336 std::string output; 336 std::string output;
337 for (auto& [name, value] : registers) { 337 for (auto& [name, value] : registers) {
338 output += android::base::StringPrintf(" %-3s %0*" PRIxPTR, name.c_str(), 338 output += android::base::StringPrintf(" %-3s %0*" PRIx64, name.c_str(),
339 static_cast<int>(2 * sizeof(void*)), 339 static_cast<int>(2 * sizeof(void*)),
340 static_cast<uintptr_t>(value)); 340 static_cast<uint64_t>(value));
341 } 341 }
342 342
343 _LOG(log, logtype::REGISTERS, " %s\n", output.c_str()); 343 _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) {
389} 389}
390 390
391static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory, 391static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory,
392 const ThreadInfo& thread_info, uintptr_t abort_msg_address, 392 const ThreadInfo& thread_info, uint64_t abort_msg_address,
393 bool primary_thread) { 393 bool primary_thread) {
394 UNUSED(process_memory); 394 UNUSED(process_memory);
395 log->current_tid = thread_info.tid; 395 log->current_tid = thread_info.tid;
@@ -425,10 +425,10 @@ static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory,
425 if (primary_thread) { 425 if (primary_thread) {
426 dump_memory_and_code(log, process_memory, thread_info.registers.get()); 426 dump_memory_and_code(log, process_memory, thread_info.registers.get());
427 if (map) { 427 if (map) {
428 uintptr_t addr = 0; 428 uint64_t addr = 0;
429 siginfo_t* si = thread_info.siginfo; 429 siginfo_t* si = thread_info.siginfo;
430 if (signal_has_si_addr(si->si_signo, si->si_code)) { 430 if (signal_has_si_addr(si->si_signo, si->si_code)) {
431 addr = reinterpret_cast<uintptr_t>(si->si_addr); 431 addr = reinterpret_cast<uint64_t>(si->si_addr);
432 } 432 }
433 dump_all_maps(log, map, process_memory, addr); 433 dump_all_maps(log, map, process_memory, addr);
434 } 434 }
@@ -572,7 +572,7 @@ static void dump_logs(log_t* log, pid_t pid, unsigned int tail) {
572 dump_log_file(log, pid, "main", tail); 572 dump_log_file(log, pid, "main", tail);
573} 573}
574 574
575void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo, 575void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo,
576 ucontext_t* ucontext) { 576 ucontext_t* ucontext) {
577 pid_t pid = getpid(); 577 pid_t pid = getpid();
578 pid_t tid = gettid(); 578 pid_t tid = gettid();
@@ -614,7 +614,7 @@ void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, s
614 614
615void engrave_tombstone(unique_fd output_fd, BacktraceMap* map, Memory* process_memory, 615void engrave_tombstone(unique_fd output_fd, BacktraceMap* map, Memory* process_memory,
616 const std::map<pid_t, ThreadInfo>& threads, pid_t target_thread, 616 const std::map<pid_t, ThreadInfo>& threads, pid_t target_thread,
617 uintptr_t abort_msg_address, OpenFilesList* open_files, 617 uint64_t abort_msg_address, OpenFilesList* open_files,
618 std::string* amfd_data) { 618 std::string* amfd_data) {
619 // don't copy log messages to tombstone unless this is a dev device 619 // don't copy log messages to tombstone unless this is a dev device
620 bool want_logs = android::base::GetBoolProperty("ro.debuggable", false); 620 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, ...) {
124#define MEMORY_BYTES_TO_DUMP 256 124#define MEMORY_BYTES_TO_DUMP 256
125#define MEMORY_BYTES_PER_LINE 16 125#define MEMORY_BYTES_PER_LINE 16
126 126
127void dump_memory(log_t* log, unwindstack::Memory* memory, uintptr_t addr, const char* fmt, ...) { 127void dump_memory(log_t* log, unwindstack::Memory* memory, uint64_t addr, const char* fmt, ...) {
128 std::string log_msg; 128 std::string log_msg;
129 va_list ap; 129 va_list ap;
130 va_start(ap, fmt); 130 va_start(ap, fmt);
@@ -159,7 +159,7 @@ void dump_memory(log_t* log, unwindstack::Memory* memory, uintptr_t addr, const
159 bytes &= ~(sizeof(uintptr_t) - 1); 159 bytes &= ~(sizeof(uintptr_t) - 1);
160 } 160 }
161 161
162 uintptr_t start = 0; 162 uint64_t start = 0;
163 bool skip_2nd_read = false; 163 bool skip_2nd_read = false;
164 if (bytes == 0) { 164 if (bytes == 0) {
165 // In this case, we might want to try another read at the beginning of 165 // 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
206 std::string ascii; 206 std::string ascii;
207 for (size_t i = 0; i < MEMORY_BYTES_PER_LINE / sizeof(uintptr_t); i++) { 207 for (size_t i = 0; i < MEMORY_BYTES_PER_LINE / sizeof(uintptr_t); i++) {
208 if (current >= start && current + sizeof(uintptr_t) <= total_bytes) { 208 if (current >= start && current + sizeof(uintptr_t) <= total_bytes) {
209 android::base::StringAppendF(&logline, " %" PRIPTR, *data_ptr); 209 android::base::StringAppendF(&logline, " %" PRIPTR, static_cast<uint64_t>(*data_ptr));
210 210
211 // Fill out the ascii string from the data. 211 // Fill out the ascii string from the data.
212 uint8_t* ptr = reinterpret_cast<uint8_t*>(data_ptr); 212 uint8_t* ptr = reinterpret_cast<uint8_t*>(data_ptr);