[compiler-rt] r209277 - Use 64-bit pointer to unwind stack for x86-64
Kostya Serebryany
kcc at google.com
Wed May 21 00:34:10 PDT 2014
Author: kcc
Date: Wed May 21 02:34:03 2014
New Revision: 209277
URL: http://llvm.org/viewvc/llvm-project?rev=209277&view=rev
Log:
Use 64-bit pointer to unwind stack for x86-64
X32 uses ILP32 data model in 64-bit hardware mode. This patch always
uses 64-bit pointer to unwind stack for x86-64.
Patch by H.J. Lu
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=209277&r1=209276&r2=209277&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Wed May 21 02:34:03 2014
@@ -57,6 +57,13 @@ typedef signed long long sptr; // NOL
typedef unsigned long uptr; // NOLINT
typedef signed long sptr; // NOLINT
#endif // defined(_WIN64)
+#if defined(__x86_64__)
+// Since x32 uses ILP32 data model in 64-bit hardware mode, we must use
+// 64-bit pointer to unwind stack frame.
+typedef unsigned long long uhwptr; // NOLINT
+#else
+typedef uptr uhwptr; // NOLINT
+#endif
typedef unsigned char u8;
typedef unsigned short u16; // NOLINT
typedef unsigned int u32;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=209277&r1=209276&r2=209277&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Wed May 21 02:34:03 2014
@@ -39,21 +39,21 @@ void StackTrace::FastUnwindStack(uptr pc
CHECK_GE(max_depth, 2);
trace[0] = pc;
size = 1;
- uptr *frame = (uptr *)bp;
- uptr *prev_frame = frame - 1;
+ uhwptr *frame = (uhwptr *)bp;
+ uhwptr *prev_frame = frame - 1;
if (stack_top < 4096) return; // Sanity check for stack top.
// Avoid infinite loop when frame == frame[0] by using frame > prev_frame.
while (frame > prev_frame &&
- frame < (uptr *)stack_top - 2 &&
- frame > (uptr *)stack_bottom &&
+ frame < (uhwptr *)stack_top - 2 &&
+ frame > (uhwptr *)stack_bottom &&
IsAligned((uptr)frame, sizeof(*frame)) &&
size < max_depth) {
- uptr pc1 = frame[1];
+ uhwptr pc1 = frame[1];
if (pc1 != pc) {
- trace[size++] = pc1;
+ trace[size++] = (uptr) pc1;
}
prev_frame = frame;
- frame = (uptr*)frame[0];
+ frame = (uhwptr *)frame[0];
}
}
More information about the llvm-commits
mailing list