summaryrefslogtreecommitdiff
path: root/libsanitizer
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-16 12:02:29 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-16 12:02:29 +0000
commit1ceb064e3b387d3ccdd761de8ae06ea1f119b199 (patch)
treec820b9a2e4796f64daf0e40ac9e60c9dc6588120 /libsanitizer
parent1b9b22f30ba624603623773a2091ecdf21b399f6 (diff)
downloadgcc-1ceb064e3b387d3ccdd761de8ae06ea1f119b199.tar.gz
Define/use hardware pointer type for stack unwind
PR other/55333 * include/sanitizer/common_interface_defs.h (uhwptr): New type for hardware pointer. * sanitizer_common/sanitizer_stacktrace.cc (StackTrace::FastUnwindStack): Replace uptr with uhwptr for stack unwind. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193557 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libsanitizer')
-rw-r--r--libsanitizer/ChangeLog8
-rw-r--r--libsanitizer/include/sanitizer/common_interface_defs.h7
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace.cc14
3 files changed, 22 insertions, 7 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 156aaebaf33..267aa42d484 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR other/55333
+ * include/sanitizer/common_interface_defs.h (uhwptr): New type
+ for hardware pointer.
+ * sanitizer_common/sanitizer_stacktrace.cc (StackTrace::FastUnwindStack):
+ Replace uptr with uhwptr for stack unwind.
+
2012-11-16 Dodji Seketeli <dodji@redhat.com>
* configure.tgt: Enable build on sparc linux.
diff --git a/libsanitizer/include/sanitizer/common_interface_defs.h b/libsanitizer/include/sanitizer/common_interface_defs.h
index 4ac7609c675..d78d2802a2b 100644
--- a/libsanitizer/include/sanitizer/common_interface_defs.h
+++ b/libsanitizer/include/sanitizer/common_interface_defs.h
@@ -46,6 +46,13 @@ typedef signed long long sptr; // NOLINT
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;
diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
index f6d7a0966c2..915c4b8050a 100644
--- a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
@@ -120,18 +120,18 @@ void StackTrace::FastUnwindStack(uptr pc, uptr bp,
uptr stack_top, uptr stack_bottom) {
CHECK(size == 0 && trace[0] == pc);
size = 1;
- uptr *frame = (uptr*)bp;
- uptr *prev_frame = frame;
+ uhwptr *frame = (uhwptr *)bp;
+ uhwptr *prev_frame = frame;
while (frame >= prev_frame &&
- frame < (uptr*)stack_top - 2 &&
- frame > (uptr*)stack_bottom &&
+ frame < (uhwptr *)stack_top - 2 &&
+ frame > (uhwptr *)stack_bottom &&
size < max_size) {
- 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];
}
}