OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/debug/stack_trace.h" | 5 #include "base/debug/stack_trace.h" |
6 | 6 |
7 #include <android/log.h> | 7 #include <android/log.h> |
8 #include <unwind.h> | 8 #include <unwind.h> |
9 | 9 |
10 #include "base/debug/proc_maps_linux.h" | 10 #include "base/debug/proc_maps_linux.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
13 | 13 |
| 14 #ifdef __LP64__ |
| 15 #define FMT_ADDR "0x%016lx" |
| 16 #else |
| 17 #define FMT_ADDR "0x%08x" |
| 18 #endif |
| 19 |
14 namespace { | 20 namespace { |
15 | 21 |
16 struct StackCrawlState { | 22 struct StackCrawlState { |
17 StackCrawlState(uintptr_t* frames, size_t max_depth) | 23 StackCrawlState(uintptr_t* frames, size_t max_depth) |
18 : frames(frames), | 24 : frames(frames), |
19 frame_count(0), | 25 frame_count(0), |
20 max_depth(max_depth), | 26 max_depth(max_depth), |
21 have_skipped_self(false) {} | 27 have_skipped_self(false) {} |
22 | 28 |
23 uintptr_t* frames; | 29 uintptr_t* frames; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 103 |
98 std::vector<MappedMemoryRegion>::iterator iter = regions.begin(); | 104 std::vector<MappedMemoryRegion>::iterator iter = regions.begin(); |
99 while (iter != regions.end()) { | 105 while (iter != regions.end()) { |
100 if (address >= iter->start && address < iter->end && | 106 if (address >= iter->start && address < iter->end && |
101 !iter->path.empty()) { | 107 !iter->path.empty()) { |
102 break; | 108 break; |
103 } | 109 } |
104 ++iter; | 110 ++iter; |
105 } | 111 } |
106 | 112 |
107 *os << base::StringPrintf("#%02d 0x%08x ", i, address); | 113 *os << base::StringPrintf("#%02zd " FMT_ADDR " ", i, address); |
108 | 114 |
109 if (iter != regions.end()) { | 115 if (iter != regions.end()) { |
110 uintptr_t rel_pc = address - iter->start + iter->offset; | 116 uintptr_t rel_pc = address - iter->start + iter->offset; |
111 const char* path = iter->path.c_str(); | 117 const char* path = iter->path.c_str(); |
112 *os << base::StringPrintf("%s+0x%08x", path, rel_pc); | 118 *os << base::StringPrintf("%s+" FMT_ADDR, path, rel_pc); |
113 } else { | 119 } else { |
114 *os << "<unknown>"; | 120 *os << "<unknown>"; |
115 } | 121 } |
116 | 122 |
117 *os << "\n"; | 123 *os << "\n"; |
118 } | 124 } |
119 } | 125 } |
120 | 126 |
121 } // namespace debug | 127 } // namespace debug |
122 } // namespace base | 128 } // namespace base |
OLD | NEW |