Unfortunately, the `sanitizer_common` tests are disabled on many targets that are supported by `sanitizer_common`, making it easy to miss issues with that support. This patch enables SPARC testing. Beside the enabling proper, the patch fixes (together with D91607 <https://reviews.llvm.org/D91607>) the failures of the `symbolize_pc.cpp`, `symbolize_pc_demangle.cpp`, and `symbolize_pc_inline.cpp` tests. They lack calls to `__builtin_extract_return_addr`. When those are added, they `PASS` when compiled with `gcc`. `clang` incorrectly doesn't implement a non-default `__builtin_extract_return_addr` on several targets, SPARC included. Because `__builtin_extract_return_addr(__builtin_return_addr(0))` is quite a mouthful and I'm uncertain if the code needs to compile with msvc which appparently has it's own `_ReturnAddress`, I've introduced `__sanitizer_return_addr` to hide the difference and complexity. Because on 32-bit SPARC `__builtin_extract_return_addr` differs when the calling function returns a struct, I've added a testcase for that. There are a couple more tests failing on SPARC that I will deal with separately. Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`. Differential Revision: https://reviews.llvm.org/D91608
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
// RUN: %clangxx -O3 %s -o %t
|
|
// RUN: %env_tool_opts=strip_path_prefix=/TestCases/ %run %t 2>&1 | FileCheck %s
|
|
// RUN: %env_tool_opts=strip_path_prefix=/TestCases/:symbolize_inline_frames=0 %run %t 2>&1 | FileCheck %s --check-prefixes=NOINLINE
|
|
// RUN: %env_tool_opts=strip_path_prefix=/TestCases/:symbolize_inline_frames=1 %run %t 2>&1 | FileCheck %s
|
|
|
|
// XFAIL: darwin
|
|
|
|
#include <sanitizer/common_interface_defs.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
char buffer[10000];
|
|
|
|
__attribute__((noinline)) static void Symbolize() {
|
|
__sanitizer_symbolize_pc(__sanitizer_return_address(), "%p %F %L", buffer,
|
|
sizeof(buffer));
|
|
for (char *p = buffer; strlen(p); p += strlen(p) + 1)
|
|
printf("%s\n", p);
|
|
}
|
|
|
|
// NOINLINE: {{0x[0-9a-f]+}} in main symbolize_pc_inline.cpp:[[@LINE+2]]
|
|
// CHECK: [[ADDR:0x[0-9a-f]+]] in C2 symbolize_pc_inline.cpp:[[@LINE+1]]
|
|
static inline void C2() { Symbolize(); }
|
|
|
|
// CHECK: [[ADDR]] in C3 symbolize_pc_inline.cpp:[[@LINE+1]]
|
|
static inline void C3() { C2(); }
|
|
|
|
// CHECK: [[ADDR]] in C4 symbolize_pc_inline.cpp:[[@LINE+1]]
|
|
static inline void C4() { C3(); }
|
|
|
|
// CHECK: [[ADDR]] in main symbolize_pc_inline.cpp:[[@LINE+1]]
|
|
int main() { C4(); }
|