2016-07-21 15:39:55 +08:00
|
|
|
//===-- xray_interface_internal.h -------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-07-21 15:39:55 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of XRay, a dynamic runtime instrumentation system.
|
|
|
|
//
|
|
|
|
// Implementation of the API functions. See also include/xray/xray_interface.h.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef XRAY_INTERFACE_INTERNAL_H
|
|
|
|
#define XRAY_INTERFACE_INTERNAL_H
|
|
|
|
|
2016-09-20 22:35:57 +08:00
|
|
|
#include "sanitizer_common/sanitizer_platform.h"
|
2016-10-06 15:09:40 +08:00
|
|
|
#include "xray/xray_interface.h"
|
2016-07-21 15:39:55 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
struct XRaySledEntry {
|
2016-09-20 22:35:57 +08:00
|
|
|
#if SANITIZER_WORDSIZE == 64
|
2016-07-21 15:39:55 +08:00
|
|
|
uint64_t Address;
|
|
|
|
uint64_t Function;
|
|
|
|
unsigned char Kind;
|
|
|
|
unsigned char AlwaysInstrument;
|
2017-08-23 12:42:37 +08:00
|
|
|
unsigned char Version;
|
|
|
|
unsigned char Padding[13]; // Need 32 bytes
|
2016-09-20 22:35:57 +08:00
|
|
|
#elif SANITIZER_WORDSIZE == 32
|
|
|
|
uint32_t Address;
|
|
|
|
uint32_t Function;
|
|
|
|
unsigned char Kind;
|
|
|
|
unsigned char AlwaysInstrument;
|
2017-08-23 12:42:37 +08:00
|
|
|
unsigned char Version;
|
|
|
|
unsigned char Padding[5]; // Need 16 bytes
|
2016-09-20 22:35:57 +08:00
|
|
|
#else
|
2016-10-06 15:09:40 +08:00
|
|
|
#error "Unsupported word size."
|
2016-09-20 22:35:57 +08:00
|
|
|
#endif
|
2016-07-21 15:39:55 +08:00
|
|
|
};
|
2017-05-04 12:59:20 +08:00
|
|
|
|
|
|
|
struct XRayFunctionSledIndex {
|
2018-04-18 05:28:53 +08:00
|
|
|
const XRaySledEntry *Begin;
|
|
|
|
const XRaySledEntry *End;
|
2017-05-04 12:59:20 +08:00
|
|
|
};
|
2016-07-21 15:39:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace __xray {
|
|
|
|
|
|
|
|
struct XRaySledMap {
|
|
|
|
const XRaySledEntry *Sleds;
|
|
|
|
size_t Entries;
|
2017-05-04 12:59:20 +08:00
|
|
|
const XRayFunctionSledIndex *SledsIndex;
|
|
|
|
size_t Functions;
|
2016-07-21 15:39:55 +08:00
|
|
|
};
|
|
|
|
|
2018-04-18 05:28:53 +08:00
|
|
|
bool patchFunctionEntry(bool Enable, uint32_t FuncId, const XRaySledEntry &Sled,
|
|
|
|
void (*Trampoline)());
|
2016-10-14 07:56:54 +08:00
|
|
|
bool patchFunctionExit(bool Enable, uint32_t FuncId, const XRaySledEntry &Sled);
|
|
|
|
bool patchFunctionTailExit(bool Enable, uint32_t FuncId,
|
|
|
|
const XRaySledEntry &Sled);
|
2017-05-12 09:07:41 +08:00
|
|
|
bool patchCustomEvent(bool Enable, uint32_t FuncId, const XRaySledEntry &Sled);
|
2018-04-18 05:28:53 +08:00
|
|
|
bool patchTypedEvent(bool Enable, uint32_t FuncId, const XRaySledEntry &Sled);
|
2016-09-20 22:35:57 +08:00
|
|
|
|
2016-07-21 15:39:55 +08:00
|
|
|
} // namespace __xray
|
|
|
|
|
2016-09-20 22:35:57 +08:00
|
|
|
extern "C" {
|
|
|
|
// The following functions have to be defined in assembler, on a per-platform
|
|
|
|
// basis. See xray_trampoline_*.S files for implementations.
|
|
|
|
extern void __xray_FunctionEntry();
|
|
|
|
extern void __xray_FunctionExit();
|
2016-11-02 12:11:29 +08:00
|
|
|
extern void __xray_FunctionTailExit();
|
2017-03-06 15:25:41 +08:00
|
|
|
extern void __xray_ArgLoggerEntry();
|
2017-05-12 09:07:41 +08:00
|
|
|
extern void __xray_CustomEvent();
|
2018-04-18 05:28:53 +08:00
|
|
|
extern void __xray_TypedEvent();
|
2016-09-20 22:35:57 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:39:55 +08:00
|
|
|
#endif
|