1// RUN: %clangxx_xray -g -std=c++11 %s -o %t
2// RUN: rm -f fdr-logging-1thr-*
3// RUN: 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>&1
7// RUN: %llvm_xray convert --output-format=yaml --symbolize --instr_map=%t \
8// RUN: "`ls fdr-logging-1thr-* | head -n1`" | FileCheck %s
9// RUN: rm fdr-logging-1thr-*
10
11// UNSUPPORTED: target=arm{{.*}}
12
13#include "xray/xray_log_interface.h"
14#include <cassert>
15
16[[clang::xray_always_instrument]] void __attribute__((noinline)) fn() { }
17
18int main(int argc, char *argv[]) {
19 auto status = __xray_log_init_mode(Mode: "xray-fdr", Config: "");
20 assert(status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);
21
22 __xray_patch();
23 fn();
24 __xray_unpatch();
25 assert(__xray_log_finalize() == XRAY_LOG_FINALIZED);
26 assert(__xray_log_flushLog() == XRAY_LOG_FLUSHED);
27 return 0;
28}
29
30// CHECK: records:
31// 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: '' }
32// 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: '' }
33

source code of compiler-rt/test/xray/TestCases/Posix/fdr-single-thread.cpp