blob: db6d2b1614ee2394f16b9be61514bf92c0014085 [file] [log] [blame]
Dean Michael Berrisf8f909f2017-01-10 02:38:11 +00001//===- xray-converter.h - XRay Trace Conversion ---------------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dean Michael Berrisf8f909f2017-01-10 02:38:11 +00006//
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"
Dean Michael Berrisd6c18652017-01-11 06:39:09 +000017#include "llvm/XRay/Trace.h"
Keith Wyss42427992017-11-07 00:28:28 +000018#include "llvm/XRay/XRayRecord.h"
Dean Michael Berrisf8f909f2017-01-10 02:38:11 +000019
20namespace llvm {
21namespace xray {
22
23class TraceConverter {
24 FuncIdConversionHelper &FuncIdHelper;
25 bool Symbolize;
26
27public:
28 TraceConverter(FuncIdConversionHelper &FuncIdHelper, bool Symbolize = false)
29 : FuncIdHelper(FuncIdHelper), Symbolize(Symbolize) {}
30
Dean Michael Berrisd6c18652017-01-11 06:39:09 +000031 void exportAsYAML(const Trace &Records, raw_ostream &OS);
32 void exportAsRAWv1(const Trace &Records, raw_ostream &OS);
Keith Wyss42427992017-11-07 00:28:28 +000033
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);
Dean Michael Berrisf8f909f2017-01-10 02:38:11 +000038};
39
40} // namespace xray
41} // namespace llvm
42
43#endif // LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H