34 lines · cpp
1// RUN: %clangxx_xray -g -std=c++11 %s -o %t2// RUN: rm -f fdr-logging-1thr-*3// RUN: env XRAY_OPTIONS=XRAY_OPTIONS="verbosity=1 patch_premain=true \4// RUN: xray_fdr_log=true \5// RUN: xray_fdr_log_func_duration_threshold_us=0 \6// RUN: xray_logfile_base=fdr-logging-1thr-" %run %t 2>&17// RUN: ls fdr-logging-1thr-* | head -n1 | tr -d '\n' > %t.xray_input8// RUN: %llvm_xray convert --output-format=yaml --symbolize --instr_map=%t \9// RUN: "%{readfile:%t.xray_input}" | FileCheck %s10// RUN: rm fdr-logging-1thr-*11 12// UNSUPPORTED: target=arm{{.*}}13 14#include "xray/xray_log_interface.h"15#include <cassert>16 17[[clang::xray_always_instrument]] void __attribute__((noinline)) fn() { }18 19int main(int argc, char *argv[]) {20 auto status = __xray_log_init_mode("xray-fdr", "");21 assert(status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);22 23 __xray_patch();24 fn();25 __xray_unpatch();26 assert(__xray_log_finalize() == XRAY_LOG_FINALIZED);27 assert(__xray_log_flushLog() == XRAY_LOG_FLUSHED);28 return 0;29}30 31// CHECK: records:32// CHECK-NEXT: - { type: 0, func-id: [[FID1:[0-9]+]], function: {{.*fn.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], process: [[PROCESS:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}}, data: '' }33// CHECK-NEXT: - { type: 0, func-id: [[FID1:[0-9]+]], function: {{.*fn.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], process: [[PROCESS:[0-9]+]], kind: function-exit, tsc: {{[0-9]+}}, data: '' }34