brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 5014fce Raw
46 lines · cpp
1// Checking that DSOs are automatically patched upon load, if patch_premain is passed.2 3// RUN: split-file %s %t4// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so5// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o6 7// RUN: env XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s8 9// REQUIRES: target={{(aarch64|x86_64)-.*}}10 11//--- main.cpp12 13#include "xray/xray_interface.h"14 15#include <cstdio>16 17void test_handler(int32_t fid, XRayEntryType type) {18  printf("called: %d, type=%d\n", fid, static_cast<int32_t>(type));19}20 21[[clang::xray_always_instrument]] void instrumented_in_executable() {22  printf("instrumented_in_executable called\n");23}24 25extern void instrumented_in_dso();26 27int main() {28  __xray_set_handler(test_handler);29  instrumented_in_executable();30  // CHECK: called: {{.*}}, type=031  // CHECK-NEXT: instrumented_in_executable called32  // CHECK-NEXT: called: {{.*}}, type=133  instrumented_in_dso();34  // CHECK-NEXT: called: {{.*}}, type=035  // CHECK-NEXT: instrumented_in_dso called36  // CHECK-NEXT: called: {{.*}}, type=137}38 39//--- testlib.cpp40 41#include <cstdio>42 43[[clang::xray_always_instrument]] void instrumented_in_dso() {44  printf("instrumented_in_dso called\n");45}46