| 1 | // Test to check if we handle pic code properly. |
| 2 | |
| 3 | // RUN: %clangxx_xray -fxray-instrument -std=c++11 -ffunction-sections \ |
| 4 | // RUN: -fdata-sections -fpic -fpie -Wl,--gc-sections %s -o %t |
| 5 | // RUN: rm -f pic-test-logging-* |
| 6 | // RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \ |
| 7 | // RUN: xray_logfile_base=pic-test-logging-" %run %t 2>&1 | FileCheck %s |
| 8 | // After all that, clean up the output xray log. |
| 9 | // |
| 10 | // RUN: rm -f pic-test-logging-* |
| 11 | |
| 12 | // UNSUPPORTED: target-is-mips64,target-is-mips64el |
| 13 | |
| 14 | #include <cstdio> |
| 15 | |
| 16 | [[clang::xray_always_instrument]] |
| 17 | unsigned short foo (unsigned b); |
| 18 | |
| 19 | [[clang::xray_always_instrument]] |
| 20 | unsigned short bar (unsigned short a) |
| 21 | { |
| 22 | printf(format: "bar() is always instrumented!\n" ); |
| 23 | return foo(b: a); |
| 24 | } |
| 25 | |
| 26 | unsigned short foo (unsigned b) |
| 27 | { |
| 28 | printf(format: "foo() is always instrumented!\n" ); |
| 29 | return b + b + 5; |
| 30 | } |
| 31 | |
| 32 | int main () |
| 33 | { |
| 34 | // CHECK: XRay: Log file in 'pic-test-logging-{{.*}}' |
| 35 | bar(a: 10); |
| 36 | // CHECK: bar() is always instrumented! |
| 37 | // CHECK-NEXT: foo() is always instrumented! |
| 38 | } |
| 39 | |