Commit 78ed38cf by Alexey Pavlyutkin Committed by Copybara-Service

PR #1783: [riscv][debugging] Fix a few warnings in RISC-V inlines

Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1783

Today we cannot build V8 (which uses the Abseil library) in strict mode for RISC-V due to a few warnings in debbugging inlines. All the warnings are about implicit signed to unsigned conversion and precision losses, nothing serious, but they are still very annoying.

Merge 7b2a865021ca18e3666c544000b6b1258964f6c4 into 8596c6e7

Merging this change closes #1783

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1783 from apavlyutkin:riscv-fix-warnings 7b2a865021ca18e3666c544000b6b1258964f6c4
PiperOrigin-RevId: 693802454
Change-Id: Ibfefc9370606a6b8ec217ac6d87d7c6d70d1a3ce
parent e83ef279
...@@ -36,12 +36,12 @@ ...@@ -36,12 +36,12 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/debugging/stacktrace.h" #include "absl/debugging/stacktrace.h"
static const uintptr_t kUnknownFrameSize = 0; static constexpr ptrdiff_t kUnknownFrameSize = 0;
// Compute the size of a stack frame in [low..high). We assume that low < high. // Compute the size of a stack frame in [low..high). We assume that low < high.
// Return size of kUnknownFrameSize. // Return size of kUnknownFrameSize.
template <typename T> template <typename T>
static inline uintptr_t ComputeStackFrameSize(const T *low, const T *high) { static inline ptrdiff_t ComputeStackFrameSize(const T *low, const T *high) {
const char *low_char_ptr = reinterpret_cast<const char *>(low); const char *low_char_ptr = reinterpret_cast<const char *>(low);
const char *high_char_ptr = reinterpret_cast<const char *>(high); const char *high_char_ptr = reinterpret_cast<const char *>(high);
return low < high ? high_char_ptr - low_char_ptr : kUnknownFrameSize; 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,8 +93,8 @@ static void ** NextStackFrame(void **old_frame_pointer, const void *uc,
// Check frame size. In strict mode, we assume frames to be under 100,000 // Check frame size. In strict mode, we assume frames to be under 100,000
// bytes. In non-strict mode, we relax the limit to 1MB. // bytes. In non-strict mode, we relax the limit to 1MB.
const uintptr_t max_size = STRICT_UNWINDING ? 100000 : 1000000; const ptrdiff_t max_size = STRICT_UNWINDING ? 100000 : 1000000;
const uintptr_t frame_size = const ptrdiff_t frame_size =
ComputeStackFrameSize(old_frame_pointer, new_frame_pointer); ComputeStackFrameSize(old_frame_pointer, new_frame_pointer);
if (frame_size == kUnknownFrameSize) { if (frame_size == kUnknownFrameSize) {
if (STRICT_UNWINDING) if (STRICT_UNWINDING)
...@@ -151,7 +151,9 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count, ...@@ -151,7 +151,9 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
} else { } else {
result[n] = return_address; result[n] = return_address;
if (IS_STACK_FRAMES) { if (IS_STACK_FRAMES) {
sizes[n] = ComputeStackFrameSize(frame_pointer, next_frame_pointer); // NextStackFrame() has already checked that frame size fits to int
sizes[n] = static_cast<int>(ComputeStackFrameSize(frame_pointer,
next_frame_pointer));
} }
n++; n++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment