xref: /openbsd-src/gnu/llvm/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.h (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1*f6aab3d8Srobert //===-- TraceIntelPTBundleSaver.h ----------------------------*- C++ //-*-===//
2*f6aab3d8Srobert //
3*f6aab3d8Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*f6aab3d8Srobert // See https://llvm.org/LICENSE.txt for license information.
5*f6aab3d8Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*f6aab3d8Srobert //
7*f6aab3d8Srobert //===----------------------------------------------------------------------===//
8*f6aab3d8Srobert 
9*f6aab3d8Srobert #ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTBUNDLESAVER_H
10*f6aab3d8Srobert #define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTBUNDLESAVER_H
11*f6aab3d8Srobert 
12*f6aab3d8Srobert #include "TraceIntelPT.h"
13*f6aab3d8Srobert #include "TraceIntelPTJSONStructs.h"
14*f6aab3d8Srobert 
15*f6aab3d8Srobert namespace lldb_private {
16*f6aab3d8Srobert namespace trace_intel_pt {
17*f6aab3d8Srobert 
18*f6aab3d8Srobert class TraceIntelPTBundleSaver {
19*f6aab3d8Srobert public:
20*f6aab3d8Srobert   /// Save the Intel PT trace of a live process to the specified directory,
21*f6aab3d8Srobert   /// which will be created if needed. This will also create a file
22*f6aab3d8Srobert   /// \a <directory>/trace.json with the description of the trace
23*f6aab3d8Srobert   /// bundle, along with others files which contain the actual trace data.
24*f6aab3d8Srobert   /// The trace.json file can be used later as input for the "trace load"
25*f6aab3d8Srobert   /// command to load the trace in LLDB.
26*f6aab3d8Srobert   ///
27*f6aab3d8Srobert   /// \param[in] trace_ipt
28*f6aab3d8Srobert   ///     The Intel PT trace to be saved to disk.
29*f6aab3d8Srobert   ///
30*f6aab3d8Srobert   /// \param[in] directory
31*f6aab3d8Srobert   ///     The directory where the trace bundle will be created.
32*f6aab3d8Srobert   ///
33*f6aab3d8Srobert   /// \param[in] compact
34*f6aab3d8Srobert   ///     Filter out information irrelevant to the traced processes in the
35*f6aab3d8Srobert   ///     context switch and intel pt traces when using per-cpu mode. This
36*f6aab3d8Srobert   ///     effectively reduces the size of those traces.
37*f6aab3d8Srobert   ///
38*f6aab3d8Srobert   /// \return
39*f6aab3d8Srobert   ///   A \a FileSpec pointing to the bundle description file, or an \a
40*f6aab3d8Srobert   ///   llvm::Error otherwise.
41*f6aab3d8Srobert   llvm::Expected<FileSpec> SaveToDisk(TraceIntelPT &trace_ipt,
42*f6aab3d8Srobert                                       FileSpec directory, bool compact);
43*f6aab3d8Srobert };
44*f6aab3d8Srobert 
45*f6aab3d8Srobert } // namespace trace_intel_pt
46*f6aab3d8Srobert } // namespace lldb_private
47*f6aab3d8Srobert 
48*f6aab3d8Srobert #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTBUNDLESAVER_H
49