diff options
author | Reid Kleckner <rnk@google.com> | 2015-08-14 17:39:48 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-08-14 17:39:48 +0000 |
commit | 48d11b32b4633605154b4dd8ce77592f63db7340 (patch) | |
tree | 8e2b0f8940fa36b5bf255def51ef9bf77bf9c1eb /test/asan/TestCases/debug_report.cc | |
parent | d0b2a6effc82c822ae17711b86b96ab343df21bd (diff) |
[windows] Fix or XFAIL remaining portable test failures and enable them
Summary:
This involved various fixes:
- Move a test that uses ulimit to Posix.
- Add a few "REQUIRES: shell" lines to tests using backtick subshell
evaluation.
- The MSVC CRT buffers stdio if the output is a pipe by default. Some
tests need that disabled to avoid interleaving test stdio with asan
output.
- MSVC headers provide _alloca instead of alloca (go figure), so add a
portability macro to the two alloca tests.
- XFAIL tests that rely on accurate symbols, we need to pass more flags
to make that work.
- MSVC's printf implementation of %p uses upper case letters and doesn't
add 0x, so do that manually.
- Accept "SEGV" or "access-violation" reports in crash tests.
Reviewers: samsonov
Subscribers: tberghammer, danalbert, llvm-commits, srhines
Differential Revision: http://reviews.llvm.org/D12019
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/debug_report.cc')
-rw-r--r-- | test/asan/TestCases/debug_report.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/test/asan/TestCases/debug_report.cc b/test/asan/TestCases/debug_report.cc index acf52f918..124ae5d76 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 |