1 //===-- SBTrace.h -----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBTrace_h_
11 #define LLDB_SBTrace_h_
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBError.h"
20 class LLDB_API SBTrace {
23 //------------------------------------------------------------------
24 /// Obtain the trace data as raw bytes.
27 /// An error explaining what went wrong.
30 /// Buffer to write the trace data to.
33 /// The size of the buffer used to read the data. This is
34 /// also the size of the data intended to read. It is also
35 /// possible to partially read the trace data for some trace
36 /// technologies by specifying a smaller buffer.
39 /// The start offset to begin reading the trace data.
41 /// @param[in] thread_id
42 /// Tracing could be started for the complete process or a
43 /// single thread, in the first case the uid obtained would
44 /// map to all the threads existing within the process and the
45 /// ones spawning later. The thread_id parameter can be used in
46 /// such a scenario to select the trace data for a specific
50 /// The size of the trace data effectively read by the API call.
51 //------------------------------------------------------------------
52 size_t GetTraceData(SBError &error, void *buf, size_t size, size_t offset = 0,
53 lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
55 //------------------------------------------------------------------
56 /// Obtain any meta data as raw bytes for the tracing instance.
57 /// The input parameter definition is similar to the previous
59 //------------------------------------------------------------------
60 size_t GetMetaData(SBError &error, void *buf, size_t size, size_t offset = 0,
61 lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
63 //------------------------------------------------------------------
64 /// Stop the tracing instance. Stopping the trace will also
65 /// lead to deletion of any gathered trace data.
68 /// An error explaining what went wrong.
70 /// @param[in] thread_id
71 /// The user id could map to a tracing instance for a thread
72 /// or could also map to a group of threads being traced with
73 /// the same trace options. A thread_id is normally optional
74 /// except in the case of tracing a complete process and tracing
75 /// needs to switched off on a particular thread.
76 /// A situation could occur where initially a thread (lets say
77 /// thread A) is being individually traced with a particular uid
78 /// and then tracing is started on the complete process, in this
79 /// case thread A will continue without any change. All newly
80 /// spawned threads would be traced with the uid of the process.
81 /// Now if the StopTrace API is called for the whole process,
82 /// thread A will not be stopped and must be stopped separately.
83 //------------------------------------------------------------------
84 void StopTrace(SBError &error,
85 lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
87 //------------------------------------------------------------------
88 /// Get the trace configuration being used for the trace instance.
89 /// The threadid in the SBTraceOptions needs to be set when the
90 /// configuration used by a specific thread is being requested.
92 /// @param[out] options
93 /// The trace options actually used by the trace instance
94 /// would be filled by the API.
97 /// An error explaining what went wrong.
98 //------------------------------------------------------------------
99 void GetTraceConfig(SBTraceOptions &options, SBError &error);
101 lldb::user_id_t GetTraceUID();
106 typedef std::shared_ptr<TraceImpl> TraceImplSP;
108 friend class SBProcess;
110 void SetTraceUID(lldb::user_id_t uid);
112 TraceImplSP m_trace_impl_sp;
114 lldb::ProcessSP GetSP() const;
116 void SetSP(const ProcessSP &process_sp);
118 lldb::ProcessWP m_opaque_wp;
122 #endif // LLDB_SBTrace_h_