1 // Checking that DSOs are automatically patched upon load, if patch_premain is passed.
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
7 // RUN: XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s
9 // REQUIRES: target={{(aarch64|x86_64)-.*}}
13 #include "xray/xray_interface.h"
17 void test_handler(int32_t fid
, XRayEntryType type
) {
18 printf("called: %d, type=%d\n", fid
, static_cast<int32_t>(type
));
21 [[clang::xray_always_instrument
]] void instrumented_in_executable() {
22 printf("instrumented_in_executable called\n");
25 extern void instrumented_in_dso();
28 __xray_set_handler(test_handler
);
29 instrumented_in_executable();
30 // CHECK: called: {{.*}}, type=0
31 // CHECK-NEXT: instrumented_in_executable called
32 // CHECK-NEXT: called: {{.*}}, type=1
33 instrumented_in_dso();
34 // CHECK-NEXT: called: {{.*}}, type=0
35 // CHECK-NEXT: instrumented_in_dso called
36 // CHECK-NEXT: called: {{.*}}, type=1
43 [[clang::xray_always_instrument
]] void instrumented_in_dso() {
44 printf("instrumented_in_dso called\n");