1*60a55337SAmy Huang // If the binary looks up libraries using an rpath, we can't test this 2*60a55337SAmy Huang // without copying the whole lib dir or polluting the build dir. 3*60a55337SAmy Huang // REQUIRES: static-libs 4*60a55337SAmy Huang 5*60a55337SAmy Huang // The above also applies if the binary is built with libc++. 6*60a55337SAmy Huang // UNSUPPORTED: libcxx-used 7*60a55337SAmy Huang 89ba623c6SAmy Huang // RUN: rm -rf %t.bin 99ba623c6SAmy Huang // RUN: mkdir %t.bin 109ba623c6SAmy Huang // RUN: cp $(which llvm-symbolizer) %t.bin 119ba623c6SAmy Huang // RUN: rm -rf %t.dir 129ba623c6SAmy Huang // RUN: mkdir %t.dir 139ba623c6SAmy Huang // RUN: %clangxx -O0 %s -o %t && cd %t.dir 149ba623c6SAmy Huang // RUN: %env_tool_opts=external_symbolizer_path=%d/external_symbolizer_path.cpp.tmp.bin/llvm-symbolizer \ 159ba623c6SAmy Huang // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=FOUND 169ba623c6SAmy Huang // RUN: rm -rf %t.bin/llvm-symbolizer 179ba623c6SAmy Huang // RUN: cd .. 189ba623c6SAmy Huang // RUN: %clangxx -O0 %s -o %t && cd %t.dir 199ba623c6SAmy Huang // RUN: %env_tool_opts=external_symbolizer_path=%d/external_symbolizer_path.cpp.tmp.bin/llvm-symbolizer \ 209ba623c6SAmy Huang // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=NOT-FOUND 219ba623c6SAmy Huang 225815b71eSAmy Huang // REQUIRES: shell 235815b71eSAmy Huang 24758928e3SVitaly Buka // Mobile device will not have symbolizer in provided path. 25758928e3SVitaly Buka // UNSUPPORTED: ios, android 26758928e3SVitaly Buka 271e92b173SAmy Huang // FIXME: Figure out why this fails on certain buildbots and re-enable. 281e92b173SAmy Huang // UNSUPPORTED: linux 295815b71eSAmy Huang 309ba623c6SAmy Huang #include <sanitizer/common_interface_defs.h> 319ba623c6SAmy Huang #include <stdio.h> 329ba623c6SAmy Huang Symbolize()339ba623c6SAmy Huangstatic void Symbolize() { 349ba623c6SAmy Huang char buffer[100]; 359ba623c6SAmy Huang __sanitizer_symbolize_pc(__builtin_return_address(0), "%p %F %L", buffer, 369ba623c6SAmy Huang sizeof(buffer)); 379ba623c6SAmy Huang printf("%s\n", buffer); 389ba623c6SAmy Huang } 399ba623c6SAmy Huang main()409ba623c6SAmy Huangint main() { 419ba623c6SAmy Huang // FOUND: {{0x.* in main}} 429ba623c6SAmy Huang // NOT-FOUND: WARNING: invalid path to external symbolizer! 439ba623c6SAmy Huang Symbolize(); 449ba623c6SAmy Huang } 45