1 //===- xray-converter.h - XRay Trace Conversion ---------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Defines the TraceConverter class for turning binary traces into
10 // human-readable text and vice versa.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
14 #define LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
15 
16 #include "func-id-helper.h"
17 #include "llvm/XRay/Trace.h"
18 #include "llvm/XRay/XRayRecord.h"
19 
20 namespace llvm {
21 namespace xray {
22 
23 class TraceConverter {
24   FuncIdConversionHelper &FuncIdHelper;
25   bool Symbolize;
26 
27 public:
28   TraceConverter(FuncIdConversionHelper &FuncIdHelper, bool Symbolize = false)
29       : FuncIdHelper(FuncIdHelper), Symbolize(Symbolize) {}
30 
31   void exportAsYAML(const Trace &Records, raw_ostream &OS);
32   void exportAsRAWv1(const Trace &Records, raw_ostream &OS);
33 
34   /// For this conversion, the Function records within each thread are expected
35   /// to be in sorted TSC order. The trace event format encodes stack traces, so
36   /// the linear history is essential for correct output.
37   void exportAsChromeTraceEventFormat(const Trace &Records, raw_ostream &OS);
38 };
39 
40 } // namespace xray
41 } // namespace llvm
42 
43 #endif // LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
44