brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 954c7ef Raw
50 lines · cpp
1// Testing shared library support in basic logging mode.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=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 %s8// RUN: ls basic-mode-dso-* | head -1 | tr -d '\n' > %t.log9// RUN: %llvm_xray account --format=csv --sort=funcid "%{readfile:%t.log}" | FileCheck --check-prefix=ACCOUNT %s10// RUN: rm basic-mode-dso-*11 12// REQUIRES: target={{(aarch64|x86_64)-.*}}13// REQUIRES: built-in-llvm-tree14 15//--- main.cpp16 17#include "xray/xray_interface.h"18 19#include <cstdio>20#include <unistd.h>21 22[[clang::xray_always_instrument]] void instrumented_in_executable() {23  printf("instrumented_in_executable called\n");24  sleep(1);25}26 27extern void instrumented_in_dso();28 29int main() {30  // Explicit patching to ensure the DSO has been loaded31  __xray_patch();32  instrumented_in_executable();33  // CHECK: instrumented_in_executable called34  instrumented_in_dso();35  // CHECK-NEXT: instrumented_in_dso called36}37 38//--- testlib.cpp39 40#include <cstdio>41#include <unistd.h>42 43[[clang::xray_always_instrument]] void instrumented_in_dso() {44  printf("instrumented_in_dso called\n");45}46 47// ACCOUNT: funcid,count,min,median,90%ile,99%ile,max,sum,debug,function48// ACCOUNT-NEXT: 1,1,{{.*}}49// ACCOUNT-NEXT: 16777217,1,{{.*}}50