Line data Source code
1 : //===- XRayRecord.h - XRay Trace Record -----------------------------------===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : //
10 : // This file replicates the record definition for XRay log entries. This should
11 : // follow the evolution of the log record versions supported in the compiler-rt
12 : // xray project.
13 : //
14 : //===----------------------------------------------------------------------===//
15 : #ifndef LLVM_XRAY_XRAY_RECORD_H
16 : #define LLVM_XRAY_XRAY_RECORD_H
17 :
18 : #include <cstdint>
19 : #include <vector>
20 :
21 : namespace llvm {
22 : namespace xray {
23 :
24 : /// XRay traces all have a header providing some top-matter information useful
25 : /// to help tools determine how to interpret the information available in the
26 : /// trace.
27 99 : struct XRayFileHeader {
28 : /// Version of the XRay implementation that produced this file.
29 : uint16_t Version = 0;
30 :
31 : /// A numeric identifier for the type of file this is. Best used in
32 : /// combination with Version.
33 : uint16_t Type = 0;
34 :
35 : /// Whether the CPU that produced the timestamp counters (TSC) move at a
36 : /// constant rate.
37 : bool ConstantTSC;
38 :
39 : /// Whether the CPU that produced the timestamp counters (TSC) do not stop.
40 : bool NonstopTSC;
41 :
42 : /// The number of cycles per second for the CPU that produced the timestamp
43 : /// counter (TSC) values. Useful for estimating the amount of time that
44 : /// elapsed between two TSCs on some platforms.
45 : uint64_t CycleFrequency = 0;
46 :
47 : // This is different depending on the type of xray record. The naive format
48 : // stores a Wallclock timespec. FDR logging stores the size of a thread
49 : // buffer.
50 : char FreeFormData[16];
51 : };
52 :
53 : /// Determines the supported types of records that could be seen in XRay traces.
54 : /// This may or may not correspond to actual record types in the raw trace (as
55 : /// the loader implementation may synthesize this information in the process of
56 : /// of loading).
57 : enum class RecordTypes { ENTER, EXIT, TAIL_EXIT, ENTER_ARG };
58 :
59 4920 : struct XRayRecord {
60 : /// The type of record.
61 : uint16_t RecordType;
62 :
63 : /// The CPU where the thread is running. We assume number of CPUs <= 65536.
64 : uint16_t CPU;
65 :
66 : /// Identifies the type of record.
67 : RecordTypes Type;
68 :
69 : /// The function ID for the record.
70 : int32_t FuncId;
71 :
72 : /// Get the full 8 bytes of the TSC when we get the log record.
73 : uint64_t TSC;
74 :
75 : /// The thread ID for the currently running thread.
76 : uint32_t TId;
77 :
78 : /// The process ID for the currently running process.
79 : uint32_t PId;
80 :
81 : /// The function call arguments.
82 : std::vector<uint64_t> CallArgs;
83 : };
84 :
85 : } // namespace xray
86 : } // namespace llvm
87 :
88 : #endif // LLVM_XRAY_XRAY_RECORD_H
|