1 // Use the clang feature for custom xray event logging.
3 // RUN: %clangxx_xray -std=c++11 %s -o %t
4 // RUN: XRAY_OPTIONS="patch_premain=false verbosity=1 xray_logfile_base=custom-event-logging.xray-" %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_xray -std=c++11 -fpic -fpie %s -o %t
6 // RUN: XRAY_OPTIONS="patch_premain=false verbosity=1 xray_logfile_base=custom-event-logging.xray-" %run %t 2>&1 | FileCheck %s
7 // FIXME: Support this in non-x86_64 as well
8 // REQUIRES: target={{(aarch64|x86_64)-.*linux.*}}
9 // REQUIRES: built-in-llvm-tree
11 #include "xray/xray_interface.h"
13 [[clang::xray_always_instrument
]] void foo() {
14 static constexpr char CustomLogged
[] = "hello custom logging!";
15 printf("before calling the custom logging...\n");
16 __xray_customevent(CustomLogged
, sizeof(CustomLogged
));
17 printf("after calling the custom logging...\n");
20 void myprinter(void* ptr
, size_t size
) {
21 printf("%.*s\n", static_cast<int>(size
), static_cast<const char*>(ptr
));
26 // CHECK: before calling the custom logging...
27 // CHECK-NEXT: after calling the custom logging...
28 printf("setting up custom event handler...\n");
29 // CHECK-NEXT: setting up custom event handler...
30 __xray_set_customevent_handler(myprinter
);
32 // CHECK-NEXT: before calling the custom logging...
34 // CHECK-NEXT: hello custom logging!
35 // CHECK-NEXT: after calling the custom logging...
36 printf("removing custom event handler...\n");
37 // CHECK-NEXT: removing custom event handler...
38 __xray_remove_customevent_handler();
40 // CHECK-NEXT: before calling the custom logging...
41 // CHECK-NEXT: after calling the custom logging...