|
| 1 | +//===-- xray_interface.h ----------------------------------------*- C++ -*-===// |
| 2 | +// |
| 3 | +// The LLVM Compiler Infrastructure |
| 4 | +// |
| 5 | +// This file is distributed under the University of Illinois Open Source |
| 6 | +// License. See LICENSE.TXT for details. |
| 7 | +// |
| 8 | +//===----------------------------------------------------------------------===// |
| 9 | +// |
| 10 | +// This file is a part of XRay, a dynamic runtime instrumentation system. |
| 11 | +// |
| 12 | +// APIs for controlling XRay functionality explicitly. |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | +#ifndef XRAY_XRAY_INTERFACE_H |
| 15 | +#define XRAY_XRAY_INTERFACE_H |
| 16 | + |
| 17 | +#include <cstdint> |
| 18 | + |
| 19 | +extern "C" { |
| 20 | + |
| 21 | +enum XRayEntryType { ENTRY = 0, EXIT = 1 }; |
| 22 | + |
| 23 | +// Provide a function to invoke for when instrumentation points are hit. This is |
| 24 | +// a user-visible control surface that overrides the default implementation. The |
| 25 | +// function provided should take the following arguments: |
| 26 | +// |
| 27 | +// - function id: an identifier that indicates the id of a function; this id |
| 28 | +// is generated by xray; the mapping between the function id |
| 29 | +// and the actual function pointer is available through |
| 30 | +// __xray_table. |
| 31 | +// - entry type: identifies what kind of instrumentation point was encountered |
| 32 | +// (function entry, function exit, etc.). See the enum |
| 33 | +// XRayEntryType for more details. |
| 34 | +// |
| 35 | +// Returns 1 on success, 0 on error. |
| 36 | +extern int __xray_set_handler(void (*entry)(int32_t, XRayEntryType)); |
| 37 | + |
| 38 | +// This removes whatever the currently provided handler is. Returns 1 on |
| 39 | +// success, 0 on error. |
| 40 | +extern int __xray_remove_handler(); |
| 41 | + |
| 42 | +enum XRayPatchingStatus { |
| 43 | + NOT_INITIALIZED = 0, |
| 44 | + NOTIFIED = 1, |
| 45 | + ONGOING = 2, |
| 46 | + FAILED = 3 |
| 47 | +}; |
| 48 | + |
| 49 | +// This tells XRay to patch the instrumentation points. This is an asynchronous |
| 50 | +// process, and returns the following status in specific cases: |
| 51 | +// |
| 52 | +// - 0 : XRay is not initialized. |
| 53 | +// - 1 : We've done the notification. |
| 54 | +// - 2 : Patching / un-patching is on-going. |
| 55 | +extern XRayPatchingStatus __xray_patch(); |
| 56 | + |
| 57 | +// Reverses the effect of __xray_patch(). This is an asynchronous process, and |
| 58 | +// returns the following status in specific cases. |
| 59 | +// |
| 60 | +// - 0 : XRay is not initialized. |
| 61 | +// - 1 : We've done the notification. |
| 62 | +// - 2 : Patching / un-patching is on-going. |
| 63 | +extern int __xray_unpatch(); |
| 64 | +} |
| 65 | + |
| 66 | +#endif |
0 commit comments