]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/xray/TestCases/Linux/patching-unpatching.cc
1 // Check that we can patch and un-patch on demand, and that logging gets invoked
4 // RUN: %clangxx_xray -fxray-instrument -std=c++11 %s -o %t
5 // RUN: XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s
7 // UNSUPPORTED: target-is-mips64,target-is-mips64el
9 #include "xray/xray_interface.h"
15 void test_handler(int32_t fid
, XRayEntryType type
) {
16 printf("called: %d, type=%d\n", fid
, static_cast<int32_t>(type
));
20 [[clang::xray_always_instrument
]] void always_instrument() {
21 printf("always instrumented called\n");
25 __xray_set_handler(test_handler
);
27 // CHECK: always instrumented called
28 auto status
= __xray_patch();
29 printf("patching status: %d\n", static_cast<int32_t>(status
));
30 // CHECK-NEXT: patching status: 1
32 // CHECK-NEXT: called: {{.*}}, type=0
33 // CHECK-NEXT: always instrumented called
34 // CHECK-NEXT: called: {{.*}}, type=1
35 status
= __xray_unpatch();
36 printf("patching status: %d\n", static_cast<int32_t>(status
));
37 // CHECK-NEXT: patching status: 1
39 // CHECK-NEXT: always instrumented called
40 status
= __xray_patch();
41 printf("patching status: %d\n", static_cast<int32_t>(status
));
42 // CHECK-NEXT: patching status: 1
43 __xray_remove_handler();
45 // CHECK-NEXT: always instrumented called
46 status
= __xray_unpatch();
47 printf("patching status: %d\n", static_cast<int32_t>(status
));
48 // CHECK-NEXT: patching status: 1