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