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
29 // FDR mode use of the union field in the XRayFileHeader.
30 struct alignas(16) FdrAdditionalHeaderData {
31 uint64_t ThreadBufferSize;
34 static_assert(sizeof(FdrAdditionalHeaderData) == 16,
35 "FdrAdditionalHeaderData != 16 bytes");
37 // This data structure is used to describe the contents of the file. We use this
38 // for versioning the supported XRay file formats.
39 struct alignas(32) XRayFileHeader {
42 // The type of file we're writing out. See the FileTypes enum for more
43 // information. This allows different implementations of the XRay logging to
44 // have different files for different information being stored.
47 // What follows are a set of flags that indicate useful things for when
48 // reading the data in the file.
52 // The frequency by which TSC increases per-second.
53 alignas(8) uint64_t CycleFrequency = 0;
57 // The current civiltime timestamp, as retrived from 'clock_gettime'. This
58 // allows readers of the file to determine when the file was created or
62 struct FdrAdditionalHeaderData FdrData;
64 } __attribute__((packed));
66 static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
73 struct alignas(32) XRayRecord {
74 // This is the type of the record being written. We use 16 bits to allow us to
75 // treat this as a discriminant, and so that the first 4 bytes get packed
76 // properly. See RecordTypes for more supported types.
77 uint16_t RecordType = RecordTypes::NORMAL;
79 // The CPU where the thread is running. We assume number of CPUs <= 256.
82 // The type of the event. One of the following:
89 // The function ID for the record.
92 // Get the full 8 bytes of the TSC when we get the log record.
95 // The thread ID for the currently running thread.
98 // Use some bytes in the end of the record for buffers.
100 } __attribute__((packed));
102 static_assert(sizeof(XRayRecord) == 32, "XRayRecord != 32 bytes");
104 struct alignas(32) XRayArgPayload {
105 // We use the same 16 bits as a discriminant for the records in the log here
106 // too, and so that the first 4 bytes are packed properly.
107 uint16_t RecordType = RecordTypes::ARG_PAYLOAD;
109 // Add a few bytes to pad.
110 uint8_t Padding[2] = {};
112 // The function ID for the record.
115 // The thread ID for the currently running thread.
119 uint8_t Padding2[4] = {};
121 // The argument payload.
124 // The rest of this record ought to be left as padding.
125 uint8_t TailPadding[8] = {};
126 } __attribute__((packed));
128 static_assert(sizeof(XRayArgPayload) == 32, "XRayArgPayload != 32 bytes");
130 } // namespace __xray
132 #endif // XRAY_XRAY_RECORDS_H