|
36 | 36 | #include "absl/base/attributes.h"
|
37 | 37 | #include "absl/debugging/stacktrace.h"
|
38 | 38 |
|
39 |
| -static const uintptr_t kUnknownFrameSize = 0; |
| 39 | +static constexpr ptrdiff_t kUnknownFrameSize = 0; |
40 | 40 |
|
41 | 41 | // Compute the size of a stack frame in [low..high). We assume that low < high.
|
42 | 42 | // Return size of kUnknownFrameSize.
|
43 | 43 | template <typename T>
|
44 |
| -static inline uintptr_t ComputeStackFrameSize(const T *low, const T *high) { |
| 44 | +static inline ptrdiff_t ComputeStackFrameSize(const T *low, const T *high) { |
45 | 45 | const char *low_char_ptr = reinterpret_cast<const char *>(low);
|
46 | 46 | const char *high_char_ptr = reinterpret_cast<const char *>(high);
|
47 | 47 | return low < high ? high_char_ptr - low_char_ptr : kUnknownFrameSize;
|
@@ -93,8 +93,8 @@ static void ** NextStackFrame(void **old_frame_pointer, const void *uc,
|
93 | 93 |
|
94 | 94 | // Check frame size. In strict mode, we assume frames to be under 100,000
|
95 | 95 | // bytes. In non-strict mode, we relax the limit to 1MB.
|
96 |
| - const uintptr_t max_size = STRICT_UNWINDING ? 100000 : 1000000; |
97 |
| - const uintptr_t frame_size = |
| 96 | + const ptrdiff_t max_size = STRICT_UNWINDING ? 100000 : 1000000; |
| 97 | + const ptrdiff_t frame_size = |
98 | 98 | ComputeStackFrameSize(old_frame_pointer, new_frame_pointer);
|
99 | 99 | if (frame_size == kUnknownFrameSize) {
|
100 | 100 | if (STRICT_UNWINDING)
|
@@ -151,7 +151,9 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
|
151 | 151 | } else {
|
152 | 152 | result[n] = return_address;
|
153 | 153 | if (IS_STACK_FRAMES) {
|
154 |
| - sizes[n] = ComputeStackFrameSize(frame_pointer, next_frame_pointer); |
| 154 | + // NextStackFrame() has already checked that frame size fits to int |
| 155 | + sizes[n] = static_cast<int>(ComputeStackFrameSize(frame_pointer, |
| 156 | + next_frame_pointer)); |
155 | 157 | }
|
156 | 158 | n++;
|
157 | 159 | }
|
|
0 commit comments