File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
compiler-rt/test/xray/TestCases/Posix Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx_xray %s -o %t
2
+ // RUN: XRAY_OPTIONS=patch_premain=false:verbosity=1 %run %t 2>&1 | FileCheck %s
3
+
4
+ // REQUIRES: target={{x86_64-.*linux.*}}
5
+
6
+ #include < assert.h>
7
+ #include < stdio.h>
8
+ #include " xray/xray_interface.h"
9
+
10
+ [[clang::xray_always_instrument]] void foo () {
11
+ static constexpr char CustomLogged[] = " hello custom logging!" ;
12
+ printf (" before calling the custom logging...\n " );
13
+ __xray_typedevent (42 , CustomLogged, sizeof (CustomLogged));
14
+ printf (" after calling the custom logging...\n " );
15
+ }
16
+
17
+ static void myprinter (uint16_t type, const void *ptr, size_t size) {
18
+ assert (type == 42 );
19
+ printf (" %.*s\n " , static_cast <int >(size), static_cast <const char *>(ptr));
20
+ }
21
+
22
+ int main () {
23
+ // CHECK: before calling the custom logging...
24
+ // CHECK-NEXT: after calling the custom logging...
25
+ foo ();
26
+ __xray_set_typedevent_handler (myprinter);
27
+ __xray_patch ();
28
+ // CHECK-NEXT: before calling the custom logging...
29
+ // CHECK-NEXT: hello custom logging!
30
+ // CHECK-NEXT: after calling the custom logging...
31
+ foo ();
32
+ // CHECK-NEXT: before calling the custom logging...
33
+ // CHECK-NEXT: after calling the custom logging...
34
+ __xray_remove_typedevent_handler ();
35
+ foo ();
36
+ }
You can’t perform that action at this time.
0 commit comments