From 10dfe2dbc7c64b7f1a9a6f060f8f1f5940febb29 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 6 Mar 2017 07:25:41 +0000 Subject: [XRay] [compiler-rt] Allow logging the first argument of a function call. Summary: Functions with the LOG_ARGS_ENTRY sled kind at their beginning will be handled in a way to (optionally) pass their first call argument to your logging handler. For practical and performance reasons, only the first argument is supported, and only up to 64 bits. Reviewers: javed.absar, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29703 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297000 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/xray/xray_interface.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include/xray') diff --git a/include/xray/xray_interface.h b/include/xray/xray_interface.h index 9e712b1fa..52a7e1d9e 100644 --- a/include/xray/xray_interface.h +++ b/include/xray/xray_interface.h @@ -18,7 +18,13 @@ extern "C" { -enum XRayEntryType { ENTRY = 0, EXIT = 1, TAIL = 2 }; +// Synchronize this with AsmPrinter::SledKind in LLVM. +enum XRayEntryType { + ENTRY = 0, + EXIT = 1, + TAIL = 2, + LOG_ARGS_ENTRY = 3, +}; // Provide a function to invoke for when instrumentation points are hit. This is // a user-visible control surface that overrides the default implementation. The @@ -60,6 +66,17 @@ extern XRayPatchingStatus __xray_patch(); // Reverses the effect of __xray_patch(). See XRayPatchingStatus for possible // result values. extern XRayPatchingStatus __xray_unpatch(); + +// Use XRay to log the first argument of each (instrumented) function call. +// When this function exits, all threads will have observed the effect and +// start logging their subsequent affected function calls (if patched). +// +// Returns 1 on success, 0 on error. +extern int __xray_set_handler_arg1(void (*)(int32_t, XRayEntryType, uint64_t)); + +// Disables the XRay handler used to log first arguments of function calls. +// Returns 1 on success, 0 on error. +extern int __xray_remove_handler_arg1(); } #endif -- cgit v1.2.3