2016-07-21 15:39:55 +08:00
|
|
|
//===-- xray_interface_internal.h -------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
unsigned char Padding[14]; // 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;
|
|
|
|
unsigned char Padding[6]; // Need 16 bytes
|
|
|
|
#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
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace __xray {
|
|
|
|
|
|
|
|
struct XRaySledMap {
|
|
|
|
const XRaySledEntry *Sleds;
|
|
|
|
size_t Entries;
|
|
|
|
};
|
|
|
|
|
2016-12-22 15:35:56 +08:00
|
|
|
uint64_t cycleFrequency();
|
|
|
|
|
2016-10-14 07:56:54 +08:00
|
|
|
bool patchFunctionEntry(bool Enable, uint32_t FuncId,
|
2016-10-06 15:09:40 +08:00
|
|
|
const XRaySledEntry &Sled);
|
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);
|
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();
|
2016-09-20 22:35:57 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:39:55 +08:00
|
|
|
#endif
|