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
27 // FDR mode use of the union field in the XRayFileHeader.
28 struct alignas(16) FdrAdditionalHeaderData {
29 uint64_t ThreadBufferSize;
32 static_assert(sizeof(FdrAdditionalHeaderData) == 16,
33 "FdrAdditionalHeaderData != 16 bytes");
35 // This data structure is used to describe the contents of the file. We use this
36 // for versioning the supported XRay file formats.
37 struct alignas(32) XRayFileHeader {
40 // The type of file we're writing out. See the FileTypes enum for more
41 // information. This allows different implementations of the XRay logging to
42 // have different files for different information being stored.
45 // What follows are a set of flags that indicate useful things for when
46 // reading the data in the file.
50 // The frequency by which TSC increases per-second.
51 alignas(8) uint64_t CycleFrequency = 0;
55 // The current civiltime timestamp, as retrived from 'clock_gettime'. This
56 // allows readers of the file to determine when the file was created or
60 struct FdrAdditionalHeaderData FdrData;
62 } __attribute__((packed));
64 static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
70 struct alignas(32) XRayRecord {
71 // This is the type of the record being written. We use 16 bits to allow us to
72 // treat this as a discriminant, and so that the first 4 bytes get packed
73 // properly. See RecordTypes for more supported types.
74 uint16_t RecordType = 0;
76 // The CPU where the thread is running. We assume number of CPUs <= 256.
79 // The type of the event. Usually either ENTER = 0 or EXIT = 1.
82 // The function ID for the record.
85 // Get the full 8 bytes of the TSC when we get the log record.
88 // The thread ID for the currently running thread.
91 // Use some bytes in the end of the record for buffers.
93 } __attribute__((packed));
95 static_assert(sizeof(XRayRecord) == 32, "XRayRecord != 32 bytes");
99 #endif // XRAY_XRAY_RECORDS_H