1 | // Testing shared library support in basic logging mode. |
2 | |
3 | // RUN: split-file %s %t |
4 | // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so |
5 | // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o |
6 | |
7 | // RUN: XRAY_OPTIONS="patch_premain=false,xray_mode=xray-basic,xray_logfile_base=basic-mode-dso-,verbosity=1" XRAY_BASIC_OPTIONS="func_duration_threshold_us=0" %run %t/main.o 2>&1 | FileCheck %s |
8 | // RUN: %llvm_xray account --format=csv --sort=funcid "`ls basic-mode-dso-* | head -1`" | FileCheck --check-prefix=ACCOUNT %s |
9 | // RUN: rm basic-mode-dso-* |
10 | |
11 | // REQUIRES: target={{(aarch64|x86_64)-.*}} |
12 | // REQUIRES: built-in-llvm-tree |
13 | |
14 | //--- main.cpp |
15 | |
16 | #include "xray/xray_interface.h" |
17 | |
18 | #include <cstdio> |
19 | #include <unistd.h> |
20 | |
21 | [[clang::xray_always_instrument]] void instrumented_in_executable() { |
22 | printf(format: "instrumented_in_executable called\n" ); |
23 | sleep(seconds: 1); |
24 | } |
25 | |
26 | extern void instrumented_in_dso(); |
27 | |
28 | int main() { |
29 | // Explicit patching to ensure the DSO has been loaded |
30 | __xray_patch(); |
31 | instrumented_in_executable(); |
32 | // CHECK: instrumented_in_executable called |
33 | instrumented_in_dso(); |
34 | // CHECK-NEXT: instrumented_in_dso called |
35 | } |
36 | |
37 | //--- testlib.cpp |
38 | |
39 | #include <cstdio> |
40 | #include <unistd.h> |
41 | |
42 | [[clang::xray_always_instrument]] void instrumented_in_dso() { |
43 | printf(format: "instrumented_in_dso called\n" ); |
44 | } |
45 | |
46 | // ACCOUNT: funcid,count,min,median,90%ile,99%ile,max,sum,debug,function |
47 | // ACCOUNT-NEXT: 1,1,{{.*}} |
48 | // ACCOUNT-NEXT: 16777217,1,{{.*}} |
49 | |