1 //===-- xray_interface_internal.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 // Implementation of the API functions. See also include/xray/xray_interface.h.
13 //
14 //===----------------------------------------------------------------------===//
15 #ifndef XRAY_INTERFACE_INTERNAL_H
16 #define XRAY_INTERFACE_INTERNAL_H
17 
18 #include "sanitizer_common/sanitizer_platform.h"
19 #include "xray/xray_interface.h"
20 #include <cstddef>
21 #include <cstdint>
22 
23 extern "C" {
24 
25 struct XRaySledEntry {
26 #if SANITIZER_WORDSIZE == 64
27   uint64_t Address;
28   uint64_t Function;
29   unsigned char Kind;
30   unsigned char AlwaysInstrument;
31   unsigned char Padding[14]; // Need 32 bytes
32 #elif SANITIZER_WORDSIZE == 32
33   uint32_t Address;
34   uint32_t Function;
35   unsigned char Kind;
36   unsigned char AlwaysInstrument;
37   unsigned char Padding[6]; // Need 16 bytes
38 #else
39 #error "Unsupported word size."
40 #endif
41 };
42 }
43 
44 namespace __xray {
45 
46 struct XRaySledMap {
47   const XRaySledEntry *Sleds;
48   size_t Entries;
49 };
50 
51 bool patchFunctionEntry(bool Enable, uint32_t FuncId,
52                         const XRaySledEntry &Sled);
53 bool patchFunctionExit(bool Enable, uint32_t FuncId, const XRaySledEntry &Sled);
54 bool patchFunctionTailExit(bool Enable, uint32_t FuncId,
55                            const XRaySledEntry &Sled);
56 
57 } // namespace __xray
58 
59 extern "C" {
60 // The following functions have to be defined in assembler, on a per-platform
61 // basis. See xray_trampoline_*.S files for implementations.
62 extern void __xray_FunctionEntry();
63 extern void __xray_FunctionExit();
64 extern void __xray_FunctionTailExit();
65 }
66 
67 #endif
68