1 //===-- xray_records.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of XRay, a dynamic runtime instrumentation system.
12 // This header exposes some record types useful for the XRay in-memory logging
15 //===----------------------------------------------------------------------===//
17 #ifndef XRAY_XRAY_RECORDS_H
18 #define XRAY_XRAY_RECORDS_H
26 // This data structure is used to describe the contents of the file. We use this
27 // for versioning the supported XRay file formats.
28 struct alignas(32) XRayFileHeader {
31 // The type of file we're writing out. See the FileTypes enum for more
32 // information. This allows different implementations of the XRay logging to
33 // have different files for different information being stored.
36 // What follows are a set of flags that indicate useful things for when
37 // reading the data in the file.
41 // The frequency by which TSC increases per-second.
42 alignas(8) uint64_t CycleFrequency = 0;
43 } __attribute__((packed));
45 static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
51 struct alignas(32) XRayRecord {
52 // This is the type of the record being written. We use 16 bits to allow us to
53 // treat this as a discriminant, and so that the first 4 bytes get packed
54 // properly. See RecordTypes for more supported types.
55 uint16_t RecordType = 0;
57 // The CPU where the thread is running. We assume number of CPUs <= 256.
60 // The type of the event. Usually either ENTER = 0 or EXIT = 1.
63 // The function ID for the record.
66 // Get the full 8 bytes of the TSC when we get the log record.
69 // The thread ID for the currently running thread.
72 // Use some bytes in the end of the record for buffers.
74 } __attribute__((packed));
76 static_assert(sizeof(XRayRecord) == 32, "XRayRecord != 32 bytes");
80 #endif // XRAY_XRAY_RECORDS_H