1 //===-- xray_interface.h ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of XRay, a dynamic runtime instrumentation system.
12 // APIs for controlling XRay functionality explicitly.
13 //===----------------------------------------------------------------------===//
14 #ifndef XRAY_XRAY_INTERFACE_H
15 #define XRAY_XRAY_INTERFACE_H
21 // Synchronize this with AsmPrinter::SledKind in LLVM.
29 // Provide a function to invoke for when instrumentation points are hit. This is
30 // a user-visible control surface that overrides the default implementation. The
31 // function provided should take the following arguments:
33 // - function id: an identifier that indicates the id of a function; this id
34 // is generated by xray; the mapping between the function id
35 // and the actual function pointer is available through
37 // - entry type: identifies what kind of instrumentation point was encountered
38 // (function entry, function exit, etc.). See the enum
39 // XRayEntryType for more details.
41 // The user handler must handle correctly spurious calls after this handler is
42 // removed or replaced with another handler, because it would be too costly for
43 // XRay runtime to avoid spurious calls.
44 // To prevent circular calling, the handler function itself and all its
45 // direct&indirect callees must not be instrumented with XRay, which can be
46 // achieved by marking them all with: __attribute__((xray_never_instrument))
48 // Returns 1 on success, 0 on error.
49 extern int __xray_set_handler(void (*entry)(int32_t, XRayEntryType));
51 // This removes whatever the currently provided handler is. Returns 1 on
52 // success, 0 on error.
53 extern int __xray_remove_handler();
55 enum XRayPatchingStatus {
62 // This tells XRay to patch the instrumentation points. See XRayPatchingStatus
63 // for possible result values.
64 extern XRayPatchingStatus __xray_patch();
66 // Reverses the effect of __xray_patch(). See XRayPatchingStatus for possible
68 extern XRayPatchingStatus __xray_unpatch();
70 // Use XRay to log the first argument of each (instrumented) function call.
71 // When this function exits, all threads will have observed the effect and
72 // start logging their subsequent affected function calls (if patched).
74 // Returns 1 on success, 0 on error.
75 extern int __xray_set_handler_arg1(void (*)(int32_t, XRayEntryType, uint64_t));
77 // Disables the XRay handler used to log first arguments of function calls.
78 // Returns 1 on success, 0 on error.
79 extern int __xray_remove_handler_arg1();