aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/debug_report.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/debug_report.cc')
-rw-r--r--test/asan/TestCases/debug_report.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/asan/TestCases/debug_report.cc b/test/asan/TestCases/debug_report.cc
index acf52f918dd8..124ae5d76642 100644
--- a/test/asan/TestCases/debug_report.cc
+++ b/test/asan/TestCases/debug_report.cc
@@ -7,6 +7,9 @@
#include <stdlib.h>
int main() {
+ // Disable stderr buffering. Needed on Windows.
+ setvbuf(stderr, NULL, _IONBF, 0);
+
char *heap_ptr = (char *)malloc(10);
free(heap_ptr);
int present = __asan_report_present();
@@ -16,6 +19,18 @@ int main() {
return 0;
}
+// If we use %p with MSVC, it comes out all upper case. Use %08x to get
+// lowercase hex.
+#ifdef _MSC_VER
+# ifdef _WIN64
+# define PTR_FMT "0x%08llx"
+# else
+# define PTR_FMT "0x%08x"
+# endif
+#else
+# define PTR_FMT "%p"
+#endif
+
void __asan_on_error() {
int present = __asan_report_present();
void *pc = __asan_get_report_pc();
@@ -28,13 +43,13 @@ void __asan_on_error() {
fprintf(stderr, "%s\n", (present == 1) ? "report" : "");
// CHECK: report
- fprintf(stderr, "pc: %p\n", pc);
+ fprintf(stderr, "pc: " PTR_FMT "\n", pc);
// CHECK: pc: 0x[[PC:[0-9a-f]+]]
- fprintf(stderr, "bp: %p\n", bp);
+ fprintf(stderr, "bp: " PTR_FMT "\n", bp);
// CHECK: bp: 0x[[BP:[0-9a-f]+]]
- fprintf(stderr, "sp: %p\n", sp);
+ fprintf(stderr, "sp: " PTR_FMT "\n", sp);
// CHECK: sp: 0x[[SP:[0-9a-f]+]]
- fprintf(stderr, "addr: %p\n", addr);
+ fprintf(stderr, "addr: " PTR_FMT "\n", addr);
// CHECK: addr: 0x[[ADDR:[0-9a-f]+]]
fprintf(stderr, "type: %s\n", (is_write ? "write" : "read"));
// CHECK: type: write