LLDB mainline
SBTrace.h
Go to the documentation of this file.
1//===-- SBTrace.h -----------------------------------------------*- C++ -*-===//
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#ifndef LLDB_API_SBTRACE_H
10#define LLDB_API_SBTRACE_H
11
12#include "lldb/API/SBDefines.h"
13#include "lldb/API/SBError.h"
15
16namespace lldb {
17
19public:
20 /// Default constructor for an invalid Trace object.
21 SBTrace();
22
23#ifndef SWIG
24 SBTrace(const lldb::TraceSP &trace_sp);
25#endif
26
27 /// See SBDebugger::LoadTraceFromFile.
28 static SBTrace LoadTraceFromFile(SBError &error, SBDebugger &debugger,
29 const SBFileSpec &trace_description_file);
30
31 /// Get a \a TraceCursor for the given thread's trace.
32 ///
33 /// \param[out] error
34 /// This will be set with an error in case of failures.
35 //
36 /// \param[in] thread
37 /// The thread to get a \a TraceCursor for.
38 //
39 /// \return
40 /// A \a SBTraceCursor. If the thread is not traced or its trace
41 /// information failed to load, an invalid \a SBTraceCursor is returned
42 /// and the \p error parameter is set.
43 SBTraceCursor CreateNewCursor(SBError &error, SBThread &thread);
44
45 /// Save the trace to the specified directory, which will be created if
46 /// needed. This will also create a a file \a <directory>/trace.json with the
47 /// main properties of the trace session, along with others files which
48 /// contain the actual trace data. The trace.json file can be used later as
49 /// input for the "trace load" command to load the trace in LLDB, or for the
50 /// method \a SBDebugger.LoadTraceFromFile().
51 ///
52 /// \param[out] error
53 /// This will be set with an error in case of failures.
54 ///
55 /// \param[in] directory
56 /// The directory where the trace files will be saved.
57 ///
58 /// \param[in] compact
59 /// Try not to save to disk information irrelevant to the traced processes.
60 /// Each trace plug-in implements this in a different fashion.
61 ///
62 /// \return
63 /// A \a SBFileSpec pointing to the bundle description file.
64 SBFileSpec SaveToDisk(SBError &error, const SBFileSpec &bundle_dir,
65 bool compact = false);
66
67 /// \return
68 /// A description of the parameters to use for the \a SBTrace::Start
69 /// method, or \b null if the object is invalid.
70 const char *GetStartConfigurationHelp();
71
72 /// Start tracing all current and future threads in a live process using a
73 /// provided configuration. This is referred as "process tracing" in the
74 /// documentation.
75 ///
76 /// This is equivalent to the command "process trace start".
77 ///
78 /// This operation fails if it is invoked twice in a row without
79 /// first stopping the process trace with \a SBTrace::Stop().
80 ///
81 /// If a thread is already being traced explicitly, e.g. with \a
82 /// SBTrace::Start(const SBThread &thread, const SBStructuredData
83 /// &configuration), it is left unaffected by this operation.
84 ///
85 /// \param[in] configuration
86 /// Dictionary object with custom fields for the corresponding trace
87 /// technology.
88 ///
89 /// Full details for the trace start parameters that can be set can be
90 /// retrieved by calling \a SBTrace::GetStartConfigurationHelp().
91 ///
92 /// \return
93 /// An error explaining any failures.
94 SBError Start(const SBStructuredData &configuration);
95
96 /// Start tracing a specific thread in a live process using a provided
97 /// configuration. This is referred as "thread tracing" in the documentation.
98 ///
99 /// This is equivalent to the command "thread trace start".
100 ///
101 /// If the thread is already being traced by a "process tracing" operation,
102 /// e.g. with \a SBTrace::Start(const SBStructuredData &configuration), this
103 /// operation fails.
104 ///
105 /// \param[in] configuration
106 /// Dictionary object with custom fields for the corresponding trace
107 /// technology.
108 ///
109 /// Full details for the trace start parameters that can be set can be
110 /// retrieved by calling \a SBTrace::GetStartConfigurationHelp().
111 ///
112 /// \return
113 /// An error explaining any failures.
114 SBError Start(const SBThread &thread, const SBStructuredData &configuration);
115
116 /// Stop tracing all threads in a live process.
117 ///
118 /// If a "process tracing" operation is active, e.g. \a SBTrace::Start(const
119 /// SBStructuredData &configuration), this effectively prevents future threads
120 /// from being traced.
121 ///
122 /// This is equivalent to the command "process trace stop".
123 ///
124 /// \return
125 /// An error explaining any failures.
126 SBError Stop();
127
128 /// Stop tracing a specific thread in a live process regardless of whether the
129 /// thread was traced explicitly or as part of a "process tracing" operation.
130 ///
131 /// This is equivalent to the command "thread trace stop".
132 ///
133 /// \return
134 /// An error explaining any failures.
135 SBError Stop(const SBThread &thread);
136
137 explicit operator bool() const;
138
139 bool IsValid();
140
141protected:
142 lldb::TraceSP m_opaque_sp;
143 /// deprecated
144 lldb::ProcessWP m_opaque_wp;
145};
146} // namespace lldb
147
148#endif // LLDB_API_SBTRACE_H
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_API
Definition: SBDefines.h:26
lldb::ProcessWP m_opaque_wp
deprecated
Definition: SBTrace.h:144
lldb::TraceSP m_opaque_sp
Definition: SBTrace.h:142
Definition: SBAddress.h:15