1 | // Check to make sure that we are actually filtering records from the basic mode |
2 | // logging implementation. |
3 | |
4 | // RUN: %clangxx_xray -std=c++11 %s -o %t -g |
5 | // RUN: rm -f basic-filtering-* |
6 | // RUN: XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1 \ |
7 | // RUN: xray_logfile_base=basic-filtering- \ |
8 | // RUN: xray_naive_log_func_duration_threshold_us=1000 \ |
9 | // RUN: xray_naive_log_max_stack_depth=2" %run %t 2>&1 | \ |
10 | // RUN: FileCheck %s |
11 | // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \ |
12 | // RUN: "`ls basic-filtering-* | head -1`" | \ |
13 | // RUN: FileCheck %s --check-prefix TRACE |
14 | // RUN: rm -f basic-filtering-* |
15 | // |
16 | // Now check support for the XRAY_BASIC_OPTIONS environment variable. |
17 | // RUN: XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1 \ |
18 | // RUN: xray_logfile_base=basic-filtering-" \ |
19 | // RUN: XRAY_BASIC_OPTIONS="func_duration_threshold_us=1000 max_stack_depth=2" \ |
20 | // RUN: %run %t 2>&1 | FileCheck %s |
21 | // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \ |
22 | // RUN: "`ls basic-filtering-* | head -1`" | \ |
23 | // RUN: FileCheck %s --check-prefix TRACE |
24 | // RUN: rm -f basic-filtering-* |
25 | |
26 | // REQUIRES: built-in-llvm-tree |
27 | |
28 | #include <cstdio> |
29 | #include <time.h> |
30 | |
31 | [[clang::xray_always_instrument]] void __attribute__((noinline)) filtered() { |
32 | printf(format: "filtered was called.\n" ); |
33 | } |
34 | |
35 | [[clang::xray_always_instrument]] void __attribute__((noinline)) beyond_stack() { |
36 | printf(format: "beyond stack was called.\n" ); |
37 | } |
38 | |
39 | [[clang::xray_always_instrument]] void __attribute__((noinline)) |
40 | always_shows() { |
41 | struct timespec sleep; |
42 | sleep.tv_nsec = 2000000; |
43 | sleep.tv_sec = 0; |
44 | struct timespec rem; |
45 | while (nanosleep(requested_time: &sleep, remaining: &rem) == -1) |
46 | sleep = rem; |
47 | printf(format: "always_shows was called.\n" ); |
48 | beyond_stack(); |
49 | } |
50 | |
51 | [[clang::xray_always_instrument]] int main(int argc, char *argv[]) { |
52 | filtered(); // CHECK: filtered was called. |
53 | always_shows(); // CHECK: always_shows was called. |
54 | // CHECK: beyond stack was called. |
55 | } |
56 | |
57 | // TRACE-NOT: - { type: 0, func-id: {{.*}}, function: {{.*filtered.*}}, {{.*}} } |
58 | // TRACE-NOT: - { type: 0, func-id: {{.*}}, function: {{.*beyond_stack.*}}, {{.*}} } |
59 | // TRACE-DAG: - { type: 0, func-id: [[FID:[0-9]+]], function: {{.*always_shows.*}}, cpu: {{.*}}, thread: {{.*}}, kind: function-enter, tsc: {{[0-9]+}}, data: '' } |
60 | // TRACE-DAG: - { type: 0, func-id: [[FID]], function: {{.*always_shows.*}}, cpu: {{.*}}, thread: {{.*}}, kind: function-{{exit|tail-exit}}, tsc: {{[0-9]+}}, data: '' } |
61 | |