[llvm-commits] [compiler-rt] r165391 - in /compiler-rt/trunk/lib/asan: lit_tests/CMakeLists.txt lit_tests/global-overflow.cc lit_tests/heap-overflow.cc lit_tests/large_func_test.cc lit_tests/lit.cfg lit_tests/null_deref.cc lit_tests/shared-lib-test.cc lit_tests/stack-overflow.cc lit_tests/strncpy-overflow.cc lit_tests/use-after-free.cc scripts/asan_symbolize.py

Alexey Samsonov samsonov at google.com
Mon Oct 8 06:11:19 PDT 2012


Author: samsonov
Date: Mon Oct  8 08:11:18 2012
New Revision: 165391

URL: http://llvm.org/viewvc/llvm-project?rev=165391&view=rev
Log:
[ASan] use llvm-symbolizer for ASan lit-style tests on Mac

Modified:
    compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt
    compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc
    compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc
    compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc
    compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
    compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc
    compiler-rt/trunk/lib/asan/lit_tests/shared-lib-test.cc
    compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc
    compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc
    compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc
    compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py

Modified: compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt Mon Oct  8 08:11:18 2012
@@ -15,12 +15,9 @@
   # Run ASan output tests only if we're not cross-compiling,
   # and can be sure that clang would produce working binaries.
   set(ASAN_TEST_DEPS
-    clang clang-headers FileCheck count not llvm-nm
+    clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
     ${ASAN_RUNTIME_LIBRARIES}
     )
-  if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-    list(APPEND ASAN_TEST_DEPS llvm-symbolizer)
-  endif()
   set(ASAN_TEST_PARAMS
     asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
     )

Modified: compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc Mon Oct  8 08:11:18 2012
@@ -17,7 +17,7 @@
   memset(ZZZ, 0, 10);
   int res = YYY[argc * 10];  // BOOOM
   // CHECK: {{READ of size 1 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in main .*global-overflow.cc:18}}
+  // CHECK: {{    #0 0x.* in _?main .*global-overflow.cc:18}}
   // CHECK: {{0x.* is located 0 bytes to the right of global variable}}
   // CHECK:   {{.*YYY.* of size 10}}
   res += XXX[argc] + ZZZ[argc];

Modified: compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc Mon Oct  8 08:11:18 2012
@@ -22,7 +22,7 @@
   memset(x, 0, 10);
   int res = x[argc * 10];  // BOOOM
   // CHECK: {{READ of size 1 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in main .*heap-overflow.cc:23}}
+  // CHECK: {{    #0 0x.* in _?main .*heap-overflow.cc:23}}
   // CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}
   // CHECK: {{allocated by thread T0 here:}}
 
@@ -32,7 +32,7 @@
   // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}
   // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}
   // CHECK-Darwin: {{    #2 0x.* in malloc.*}}
-  // CHECK-Darwin: {{    #3 0x.* in main heap-overflow.cc:21}}
+  // CHECK-Darwin: {{    #3 0x.* in _?main .*heap-overflow.cc:21}}
   free(x);
   return res;
 }

Modified: compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc Mon Oct  8 08:11:18 2012
@@ -58,8 +58,8 @@
 // CHECK-Linux:  {{    #0 0x.* in LargeFunction.*large_func_test.cc:32}}
 // CHECK-Darwin: {{    #0 0x.* in .*LargeFunction.*large_func_test.cc:32}}
 
-// CHECK: {{    #1 0x.* in main .*large_func_test.cc:48}}
+// CHECK: {{    #1 0x.* in _?main .*large_func_test.cc:48}}
 // CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
 // CHECK: {{allocated by thread T0 here:}}
 // CHECK: {{    #0 0x.* in operator new.*}}
-// CHECK: {{    #1 0x.* in main .*large_func_test.cc:47}}
+// CHECK: {{    #1 0x.* in _?main .*large_func_test.cc:47}}

Modified: compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/lit.cfg?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/lit.cfg Mon Oct  8 08:11:18 2012
@@ -69,13 +69,11 @@
                                                 clang_asan_cxxflags + " ")) )
 
 # Setup path to external LLVM symbolizer to run AddressSanitizer output tests.
-# Currently llvm-symbolizer is supported on Linux only.
-if config.host_os == 'Linux':
-  llvm_obj_root = getattr(config, 'llvm_obj_root', None)
-  if llvm_obj_root:
-    config.environment['LLVM_SYMBOLIZER_PATH'] = os.path.join(
-        config.llvm_obj_root, "projects", "compiler-rt", "utils",
-        "llvm-symbolizer", "llvm-symbolizer")
+llvm_obj_root = getattr(config, 'llvm_obj_root', None)
+if llvm_obj_root:
+  config.environment['LLVM_SYMBOLIZER_PATH'] = os.path.join(
+      config.llvm_obj_root, "projects", "compiler-rt", "utils",
+      "llvm-symbolizer", "llvm-symbolizer")
 
 # Setup path to symbolizer script.
 # FIXME: Instead we should copy this script to the build tree and point

Modified: compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc Mon Oct  8 08:11:18 2012
@@ -31,4 +31,4 @@
 // CHECK-Linux: {{    #0 0x.* in NullDeref.*null_deref.cc:20}}
 // CHECK-Darwin: {{    #0 0x.* in .*NullDeref.*null_deref.cc:20}}
 
-// CHECK: {{    #1 0x.* in main.*null_deref.cc:23}}
+// CHECK: {{    #1 0x.* in _?main.*null_deref.cc:23}}

Modified: compiler-rt/trunk/lib/asan/lit_tests/shared-lib-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/shared-lib-test.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/shared-lib-test.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/shared-lib-test.cc Mon Oct  8 08:11:18 2012
@@ -49,6 +49,6 @@
   // CHECK: {{.*ERROR: AddressSanitizer global-buffer-overflow}}
   // CHECK: {{READ of size 4 at 0x.* thread T0}}
   // CHECK: {{    #0 0x.*}}
-  // CHECK: {{    #1 0x.* in main .*shared-lib-test.cc:48}}
+  // CHECK: {{    #1 0x.* in _?main .*shared-lib-test.cc:48}}
   return 0;
 }

Modified: compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc Mon Oct  8 08:11:18 2012
@@ -13,7 +13,7 @@
   memset(x, 0, 10);
   int res = x[argc * 10];  // BOOOM
   // CHECK: {{READ of size 1 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in main .*stack-overflow.cc:14}}
+  // CHECK: {{    #0 0x.* in _?main .*stack-overflow.cc:14}}
   // CHECK: {{Address 0x.* is .* frame <main>}}
   return res;
 }

Modified: compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc Mon Oct  8 08:11:18 2012
@@ -25,7 +25,7 @@
   // CHECK: {{WRITE of size 1 at 0x.* thread T0}}
   // CHECK-Linux: {{    #0 0x.* in .*strncpy}}
   // CHECK-Darwin: {{    #0 0x.* in wrap_strncpy}}
-  // CHECK: {{    #1 0x.* in main .*strncpy-overflow.cc:24}}
+  // CHECK: {{    #1 0x.* in _?main .*strncpy-overflow.cc:24}}
   // CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
   // CHECK: {{allocated by thread T0 here:}}
 
@@ -35,6 +35,6 @@
   // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}
   // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}
   // CHECK-Darwin: {{    #2 0x.* in malloc.*}}
-  // CHECK-Darwin: {{    #3 0x.* in main .*strncpy-overflow.cc:23}}
+  // CHECK-Darwin: {{    #3 0x.* in _?main .*strncpy-overflow.cc:23}}
   return short_buffer[8];
 }

Modified: compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc Mon Oct  8 08:11:18 2012
@@ -23,7 +23,7 @@
   // CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address}}
   // CHECK:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
   // CHECK: {{READ of size 1 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in main .*use-after-free.cc:22}}
+  // CHECK: {{    #0 0x.* in _?main .*use-after-free.cc:22}}
   // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
   // CHECK: {{freed by thread T0 here:}}
 
@@ -33,7 +33,7 @@
   // CHECK-Darwin: {{    #0 0x.* in .*mz_free.*}}
   // We override free() on Darwin, thus no malloc_zone_free
   // CHECK-Darwin: {{    #1 0x.* in wrap_free}}
-  // CHECK-Darwin: {{    #2 0x.* in main .*use-after-free.cc:21}}
+  // CHECK-Darwin: {{    #2 0x.* in _?main .*use-after-free.cc:21}}
 
   // CHECK: {{previously allocated by thread T0 here:}}
 
@@ -43,5 +43,5 @@
   // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}
   // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}
   // CHECK-Darwin: {{    #2 0x.* in malloc.*}}
-  // CHECK-Darwin: {{    #3 0x.* in main .*use-after-free.cc:20}}
+  // CHECK-Darwin: {{    #3 0x.* in _?main .*use-after-free.cc:20}}
 }

Modified: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=165391&r1=165390&r2=165391&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py (original)
+++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py Mon Oct  8 08:11:18 2012
@@ -97,13 +97,11 @@
 
 
 def LLVMSymbolizerFactory(system):
-  if system == 'Linux':
-    symbolizer_path = os.getenv('LLVM_SYMBOLIZER_PATH')
-    if not symbolizer_path:
-      # Assume llvm-symbolizer is in PATH.
-      symbolizer_path = 'llvm-symbolizer'
-    return LLVMSymbolizer(symbolizer_path)
-  return None
+  symbolizer_path = os.getenv('LLVM_SYMBOLIZER_PATH')
+  if not symbolizer_path:
+    # Assume llvm-symbolizer is in PATH.
+    symbolizer_path = 'llvm-symbolizer'
+  return LLVMSymbolizer(symbolizer_path)
 
 
 class Addr2LineSymbolizer(Symbolizer):





More information about the llvm-commits mailing list