LLDB mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
lldb_private::trace_intel_pt::TraceIntelPT Class Reference

#include <TraceIntelPT.h>

Inheritance diagram for lldb_private::trace_intel_pt::TraceIntelPT:
Inheritance graph
[legend]

Classes

class  PluginProperties
 Properties to be used with the settings command. More...
 
struct  Storage
 We package all the data that can change upon process stops to make sure this contract is very visible. More...
 

Public Types

enum class  TraceMode { UserMode , KernelMode }
 
- Public Types inherited from lldb_private::Trace
using OnBinaryDataReadCallback = std::function< llvm::Error(llvm::ArrayRef< uint8_t > data)>
 
using OnCpusBinaryDataReadCallback = std::function< llvm::Error(const llvm::DenseMap< lldb::cpu_id_t, llvm::ArrayRef< uint8_t > > &cpu_to_data)>
 

Public Member Functions

void Dump (Stream *s) const override
 Dump the trace data that this plug-in has access to.
 
llvm::Expected< FileSpecSaveToDisk (FileSpec directory, bool compact) override
 Save the trace to the specified directory, which will be created if needed.
 
 ~TraceIntelPT () override=default
 
lldb::CommandObjectSP GetProcessTraceStartCommand (CommandInterpreter &interpreter) override
 Get the command handle for the "process trace start" command.
 
lldb::CommandObjectSP GetThreadTraceStartCommand (CommandInterpreter &interpreter) override
 Get the command handle for the "thread trace start" command.
 
llvm::StringRef GetSchema () override
 
llvm::Expected< lldb::TraceCursorSPCreateNewCursor (Thread &thread) override
 Get a TraceCursor for the given thread's trace.
 
void DumpTraceInfo (Thread &thread, Stream &s, bool verbose, bool json) override
 Dump general info about a given thread's trace.
 
llvm::Expected< std::optional< uint64_t > > GetRawTraceSize (Thread &thread)
 
llvm::Error DoRefreshLiveProcessState (TraceGetStateResponse state, llvm::StringRef json_response) override
 Method to be overriden by the plug-in to refresh its own state.
 
bool IsTraced (lldb::tid_t tid) override
 Check if a thread is currently traced by this object.
 
const char * GetStartConfigurationHelp () override
 
llvm::Error Start (uint64_t ipt_trace_size, uint64_t total_buffer_size_limit, bool enable_tsc, std::optional< uint64_t > psb_period, bool m_per_cpu_tracing, bool disable_cgroup_filtering)
 Start tracing a live process.
 
llvm::Error Start (StructuredData::ObjectSP configuration=StructuredData::ObjectSP()) override
 Start tracing a live process.
 
llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, uint64_t ipt_trace_size, bool enable_tsc, std::optional< uint64_t > psb_period)
 Start tracing live threads.
 
llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, StructuredData::ObjectSP configuration=StructuredData::ObjectSP()) override
 Start tracing a live process.
 
llvm::Error OnThreadBufferRead (lldb::tid_t tid, OnBinaryDataReadCallback callback)
 See Trace::OnThreadBinaryDataRead().
 
llvm::Expected< pt_cpu > GetCPUInfo ()
 Get or fetch the cpu information from, for example, /proc/cpuinfo.
 
std::optional< LinuxPerfZeroTscConversionGetPerfZeroTscConversion ()
 Get or fetch the values used to convert to and from TSCs and nanos.
 
TaskTimerGetTimer ()
 
ScopedTaskTimerGetThreadTimer (lldb::tid_t tid)
 
ScopedTaskTimerGetGlobalTimer ()
 
TraceIntelPTSP GetSharedPtr ()
 
TraceMode GetTraceMode ()
 
- Public Member Functions inherited from lldb_private::Trace
virtual void Dump (Stream *s) const =0
 Dump the trace data that this plug-in has access to.
 
virtual llvm::Expected< FileSpecSaveToDisk (FileSpec directory, bool compact)=0
 Save the trace to the specified directory, which will be created if needed.
 
virtual lldb::CommandObjectSP GetProcessTraceStartCommand (CommandInterpreter &interpreter)=0
 Get the command handle for the "process trace start" command.
 
virtual lldb::CommandObjectSP GetThreadTraceStartCommand (CommandInterpreter &interpreter)=0
 Get the command handle for the "thread trace start" command.
 
virtual llvm::StringRef GetSchema ()=0
 
virtual llvm::Expected< lldb::TraceCursorSPCreateNewCursor (Thread &thread)=0
 Get a TraceCursor for the given thread's trace.
 
virtual void DumpTraceInfo (Thread &thread, Stream &s, bool verbose, bool json)=0
 Dump general info about a given thread's trace.
 
virtual bool IsTraced (lldb::tid_t tid)=0
 Check if a thread is currently traced by this object.
 
virtual const char * GetStartConfigurationHelp ()=0
 
virtual llvm::Error Start (StructuredData::ObjectSP configuration=StructuredData::ObjectSP())=0
 Start tracing a live process.
 
virtual llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, StructuredData::ObjectSP configuration=StructuredData::ObjectSP())=0
 Start tracing live threads.
 
llvm::Error Stop (llvm::ArrayRef< lldb::tid_t > tids)
 Stop tracing live threads.
 
llvm::Error Stop ()
 Stop tracing all current and future threads of a live process.
 
uint32_t GetStopID ()
 
llvm::Error OnThreadBinaryDataRead (lldb::tid_t tid, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Fetch binary data associated with a thread, either live or postmortem, and pass it to the given callback.
 
llvm::Error OnCpuBinaryDataRead (lldb::cpu_id_t cpu_id, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Fetch binary data associated with a cpu, either live or postmortem, and pass it to the given callback.
 
llvm::Error OnAllCpusBinaryDataRead (llvm::StringRef kind, OnCpusBinaryDataReadCallback callback)
 Similar to OnCpuBinaryDataRead but this is able to fetch the same data from all cpus at once.
 
std::vector< Process * > GetAllProcesses ()
 
llvm::ArrayRef< lldb::cpu_id_tGetTracedCpus ()
 
- Public Member Functions inherited from lldb_private::PluginInterface
 PluginInterface ()=default
 
virtual ~PluginInterface ()=default
 
virtual llvm::StringRef GetPluginName ()=0
 
 PluginInterface (const PluginInterface &)=delete
 
PluginInterfaceoperator= (const PluginInterface &)=delete
 

Static Public Member Functions

static PluginPropertiesGetGlobalProperties ()
 Return the global properties for this trace plug-in.
 
- Static Public Member Functions inherited from lldb_private::Trace
static llvm::Expected< lldb::TraceSPFindPluginForPostMortemProcess (Debugger &debugger, const llvm::json::Value &bundle_description, llvm::StringRef session_file_dir)
 Find a trace plug-in using JSON data.
 
static llvm::Expected< lldb::TraceSPFindPluginForLiveProcess (llvm::StringRef plugin_name, Process &process)
 Find a trace plug-in to trace a live process.
 
static llvm::Expected< llvm::StringRef > FindPluginSchema (llvm::StringRef plugin_name)
 Get the schema of a Trace plug-in given its name.
 
static llvm::Expected< lldb::TraceSPLoadPostMortemTraceFromFile (Debugger &debugger, const FileSpec &trace_description_file)
 Load a trace from a trace description file and create Targets, Processes and Threads based on the contents of such file.
 
static llvm::Error OnDataFileRead (FileSpec file, OnBinaryDataReadCallback callback)
 Helper method for reading a data file and passing its data to the given callback.
 

Private Member Functions

llvm::Expected< pt_cpu > GetCPUInfoForLiveProcess ()
 
 TraceIntelPT (Process &live_process)
 Constructor for live processes.
 
llvm::Expected< DecodedThreadSPDecode (Thread &thread)
 Decode the trace of the given thread that, i.e.
 
llvm::Expected< std::optional< uint64_t > > FindBeginningOfTimeNanos ()
 
void DumpTraceInfoAsJson (Thread &thread, Stream &s, bool verbose)
 
StorageGetUpdatedStorage ()
 Get the storage after refreshing the data in the case of a live process.
 

Private Attributes

struct lldb_private::trace_intel_pt::TraceIntelPT::Storage m_storage
 
std::optional< pt_cpu > m_cpu_info
 It is provided by either a trace bundle or a live process' "cpuInfo" binary data.
 
TraceMode trace_mode
 The tracing mode of post mortem trace.
 

Friends

class TraceIntelPTBundleLoader
 
static void Initialize ()
 
static void Terminate ()
 
static llvm::Expected< lldb::TraceSPCreateInstanceForTraceBundle (const llvm::json::Value &trace_bundle_description, llvm::StringRef bundle_dir, Debugger &debugger)
 Create an instance of this class from a trace bundle.
 
static llvm::Expected< lldb::TraceSPCreateInstanceForLiveProcess (Process &process)
 
static llvm::StringRef GetPluginNameStatic ()
 
static void DebuggerInitialize (Debugger &debugger)
 
llvm::StringRef GetPluginName () override
 PluginInterface protocol.
 
 TraceIntelPT (JSONTraceBundleDescription &bundle_description, llvm::ArrayRef< lldb::ProcessSP > traced_processes, TraceMode trace_mode)
 This constructor is used by CreateInstanceForPostmortemTrace to get the instance ready before using shared pointers, which is a limitation of C++.
 
static TraceIntelPTSP CreateInstanceForPostmortemTrace (JSONTraceBundleDescription &bundle_description, llvm::ArrayRef< lldb::ProcessSP > traced_processes, llvm::ArrayRef< lldb::ThreadPostMortemTraceSP > traced_threads, TraceMode trace_mode)
 Postmortem trace constructor.
 

Additional Inherited Members

- Protected Member Functions inherited from lldb_private::Trace
ProcessGetLiveProcess ()
 Get the currently traced live process.
 
llvm::ArrayRef< Process * > GetPostMortemProcesses ()
 Get the currently traced postmortem processes.
 
llvm::Expected< std::vector< uint8_t > > GetLiveTraceBinaryData (const TraceGetBinaryDataRequest &request, uint64_t expected_size)
 Dispatcher for live trace data requests with some additional error checking.
 
llvm::Error OnLiveThreadBinaryDataRead (lldb::tid_t tid, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Implementation of OnThreadBinaryDataRead() for live threads.
 
llvm::Error OnLiveCpuBinaryDataRead (lldb::cpu_id_t cpu, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Implementation of OnLiveBinaryDataRead() for live cpus.
 
llvm::Error OnPostMortemThreadBinaryDataRead (lldb::tid_t tid, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Implementation of OnThreadBinaryDataRead() for post mortem threads.
 
llvm::Error OnPostMortemCpuBinaryDataRead (lldb::cpu_id_t cpu_id, llvm::StringRef kind, OnBinaryDataReadCallback callback)
 Implementation of OnCpuBinaryDataRead() for post mortem cpus.
 
llvm::Expected< FileSpecGetPostMortemThreadDataFile (lldb::tid_t tid, llvm::StringRef kind)
 Get the file path containing data of a postmortem thread given a data identifier.
 
llvm::Expected< FileSpecGetPostMortemCpuDataFile (lldb::cpu_id_t cpu_id, llvm::StringRef kind)
 Get the file path containing data of a postmortem cpu given a data identifier.
 
void SetPostMortemThreadDataFile (lldb::tid_t tid, llvm::StringRef kind, FileSpec file_spec)
 Associate a given thread with a data file using a data identifier.
 
void SetPostMortemCpuDataFile (lldb::cpu_id_t cpu_id, llvm::StringRef kind, FileSpec file_spec)
 Associate a given cpu with a data file using a data identifier.
 
llvm::Expected< std::vector< uint8_t > > GetLiveThreadBinaryData (lldb::tid_t tid, llvm::StringRef kind)
 Get binary data of a live thread given a data identifier.
 
llvm::Expected< std::vector< uint8_t > > GetLiveCpuBinaryData (lldb::cpu_id_t cpu_id, llvm::StringRef kind)
 Get binary data of a live cpu given a data identifier.
 
llvm::Expected< std::vector< uint8_t > > GetLiveProcessBinaryData (llvm::StringRef kind)
 Get binary data of the current process given a data identifier.
 
std::optional< uint64_t > GetLiveThreadBinaryDataSize (lldb::tid_t tid, llvm::StringRef kind)
 Get the size of the data returned by GetLiveThreadBinaryData.
 
std::optional< uint64_t > GetLiveCpuBinaryDataSize (lldb::cpu_id_t cpu_id, llvm::StringRef kind)
 Get the size of the data returned by GetLiveCpuBinaryData.
 
std::optional< uint64_t > GetLiveProcessBinaryDataSize (llvm::StringRef kind)
 Get the size of the data returned by GetLiveProcessBinaryData.
 
 Trace (llvm::ArrayRef< lldb::ProcessSP > postmortem_processes, std::optional< std::vector< lldb::cpu_id_t > > postmortem_cpus)
 Constructor for post mortem processes.
 
 Trace (Process &live_process)
 Constructor for a live process.
 
llvm::Error Start (const llvm::json::Value &request)
 Start tracing a live process or its threads.
 
llvm::Expected< std::string > GetLiveProcessState ()
 Get the current tracing state of a live process and its threads.
 
virtual llvm::Error DoRefreshLiveProcessState (TraceGetStateResponse state, llvm::StringRef json_response)=0
 Method to be overriden by the plug-in to refresh its own state.
 
std::vector< Process * > GetTracedProcesses ()
 Return the list of processes traced by this instance.
 
const char * RefreshLiveProcessState ()
 Method to be invoked by the plug-in to refresh the live process state.
 

Detailed Description

Definition at line 24 of file TraceIntelPT.h.

Member Enumeration Documentation

◆ TraceMode

Enumerator
UserMode 
KernelMode 

Definition at line 194 of file TraceIntelPT.h.

Constructor & Destructor Documentation

◆ ~TraceIntelPT()

lldb_private::trace_intel_pt::TraceIntelPT::~TraceIntelPT ( )
overridedefault

◆ TraceIntelPT() [1/2]

lldb_private::trace_intel_pt::TraceIntelPT::TraceIntelPT ( JSONTraceBundleDescription bundle_description,
llvm::ArrayRef< lldb::ProcessSP traced_processes,
TraceMode  trace_mode 
)
private

This constructor is used by CreateInstanceForPostmortemTrace to get the instance ready before using shared pointers, which is a limitation of C++.

◆ TraceIntelPT() [2/2]

lldb_private::trace_intel_pt::TraceIntelPT::TraceIntelPT ( Process live_process)
inlineprivate

Constructor for live processes.

Definition at line 235 of file TraceIntelPT.h.

Member Function Documentation

◆ CreateInstanceForLiveProcess()

Expected< TraceSP > TraceIntelPT::CreateInstanceForLiveProcess ( Process process)
static

Definition at line 117 of file TraceIntelPT.cpp.

References lldb_private::Process::GetTarget(), and lldb_private::Target::SetTrace().

Referenced by Initialize().

◆ CreateInstanceForPostmortemTrace()

TraceIntelPTSP TraceIntelPT::CreateInstanceForPostmortemTrace ( JSONTraceBundleDescription bundle_description,
llvm::ArrayRef< lldb::ProcessSP traced_processes,
llvm::ArrayRef< lldb::ThreadPostMortemTraceSP traced_threads,
TraceMode  trace_mode 
)
staticprivate

Postmortem trace constructor.

Parameters
[in]bundle_descriptionThe definition file for the postmortem bundle.
[in]traced_processesThe processes traced in the postmortem session.
[in]trace_threadsThe threads traced in the postmortem session. They must belong to the processes mentioned above.
[in]trace_modeThe tracing mode of the postmortem session.
Returns
A TraceIntelPT shared pointer instance.

Definition at line 129 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::JSONCpu::context_switch_trace, lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpus, lldb_private::trace_intel_pt::JSONCpu::id, lldb_private::trace_intel_pt::JSONCpu::ipt_trace, KernelMode, lldb_private::IntelPTDataKinds::kIptTrace, lldb_private::IntelPTDataKinds::kPerfContextSwitchTrace, trace_mode, lldb_private::trace_intel_pt::JSONTraceBundleDescription::tsc_perf_zero_conversion, and UserMode.

Referenced by lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::CreateTraceIntelPTInstance().

◆ CreateInstanceForTraceBundle()

Expected< TraceSP > TraceIntelPT::CreateInstanceForTraceBundle ( const llvm::json::Value &  trace_bundle_description,
llvm::StringRef  bundle_dir,
Debugger debugger 
)
static

Create an instance of this class from a trace bundle.

Parameters
[in]trace_bundle_descriptionThe description of the trace bundle. See Trace::FindPlugin.
[in]bundle_dirThe path to the directory that contains the trace bundle.
[in]debuggerThe debugger instance where new Targets will be created as part of the JSON data parsing.
Returns
A trace instance or an error in case of failures.

Definition at line 110 of file TraceIntelPT.cpp.

References TraceIntelPTBundleLoader.

Referenced by Initialize(), and Terminate().

◆ CreateNewCursor()

llvm::Expected< lldb::TraceCursorSP > TraceIntelPT::CreateNewCursor ( Thread thread)
overridevirtual

Get a TraceCursor for the given thread's trace.

Returns
A TraceCursorSP. If the thread is not traced or its trace information failed to load, an llvm::Error is returned.

Implements lldb_private::Trace.

Definition at line 229 of file TraceIntelPT.cpp.

References Decode(), FindBeginningOfTimeNanos(), m_storage, and lldb_private::trace_intel_pt::TraceIntelPT::Storage::tsc_conversion.

◆ DebuggerInitialize()

void TraceIntelPT::DebuggerInitialize ( Debugger debugger)
static

◆ Decode()

Expected< DecodedThreadSP > TraceIntelPT::Decode ( Thread thread)
private

Decode the trace of the given thread that, i.e.

recontruct the traced instructions.

Parameters
[in]threadIf thread is a ThreadTrace, then its internal trace file will be decoded. Live threads are not currently supported.
Returns
A DecodedThread shared pointer with the decoded instructions. Any errors are embedded in the instruction list. An llvm::Error is returned if the decoder couldn't be properly set up.

Definition at line 178 of file TraceIntelPT.cpp.

References error(), lldb_private::UserID::GetID(), GetUpdatedStorage(), lldb_private::trace_intel_pt::TraceIntelPT::Storage::multicpu_decoder, lldb_private::Trace::RefreshLiveProcessState(), and lldb_private::trace_intel_pt::TraceIntelPT::Storage::thread_decoders.

Referenced by CreateNewCursor(), DumpTraceInfo(), and DumpTraceInfoAsJson().

◆ DoRefreshLiveProcessState()

Error TraceIntelPT::DoRefreshLiveProcessState ( TraceGetStateResponse  state,
llvm::StringRef  json_response 
)
overridevirtual

Method to be overriden by the plug-in to refresh its own state.

This is invoked by RefreshLiveProcessState when a new state is found.

Parameters
[in]stateThe jLLDBTraceGetState response.
[in]json_responseThe original JSON response as a string. It might be useful to redecode it if it contains custom data for a specific trace plug-in.
Returns
Error::success() if this operation succeedes, or an actual error otherwise.

Implements lldb_private::Trace.

Definition at line 556 of file TraceIntelPT.cpp.

References lldb_private::ThreadList::FindThreadByID(), lldb_private::Trace::GetLiveProcess(), lldb_private::GetLog(), GetSharedPtr(), lldb_private::Process::GetThreadList(), lldb_private::TraceCpuState::id, LLDB_LOG, m_storage, lldb_private::trace_intel_pt::TraceIntelPT::Storage::multicpu_decoder, lldb_private::Target, lldb_private::trace_intel_pt::TraceIntelPT::Storage::thread_decoders, lldb_private::TraceThreadState::tid, lldb_private::TraceGetStateResponse::traced_threads, and lldb_private::trace_intel_pt::TraceIntelPT::Storage::tsc_conversion.

◆ Dump()

void TraceIntelPT::Dump ( Stream s) const
overridevirtual

Dump the trace data that this plug-in has access to.

This function will dump all of the trace data for all threads in a user readable format. Options for dumping can be added as this API is iterated on.

Parameters
[in]sA stream object to dump the information to.

Implements lldb_private::Trace.

Definition at line 103 of file TraceIntelPT.cpp.

◆ DumpTraceInfo()

void TraceIntelPT::DumpTraceInfo ( Thread thread,
Stream s,
bool  verbose,
bool  json 
)
overridevirtual

◆ DumpTraceInfoAsJson()

void TraceIntelPT::DumpTraceInfoAsJson ( Thread thread,
Stream s,
bool  verbose 
)
private

◆ FindBeginningOfTimeNanos()

Expected< std::optional< uint64_t > > TraceIntelPT::FindBeginningOfTimeNanos ( )
private
Returns
The lowest timestamp in nanoseconds in all traces if available, std::nullopt if all the traces were empty or no trace contained no timing information, or an llvm::Error if it was not possible to set up the decoder for some trace.

Definition at line 192 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::TraceIntelPT::Storage::beginning_of_time_nanos, lldb_private::trace_intel_pt::TraceIntelPT::Storage::beginning_of_time_nanos_calculated, GetUpdatedStorage(), lldb_private::trace_intel_pt::TraceIntelPT::Storage::multicpu_decoder, lldb_private::trace_intel_pt::TraceIntelPT::Storage::thread_decoders, and lldb_private::trace_intel_pt::TraceIntelPT::Storage::tsc_conversion.

Referenced by CreateNewCursor().

◆ GetCPUInfo()

Expected< pt_cpu > TraceIntelPT::GetCPUInfo ( )

Get or fetch the cpu information from, for example, /proc/cpuinfo.

Definition at line 536 of file TraceIntelPT.cpp.

References GetCPUInfoForLiveProcess(), and m_cpu_info.

Referenced by CreateBasicLibiptConfig(), and lldb_private::trace_intel_pt::TraceIntelPTBundleSaver::SaveToDisk().

◆ GetCPUInfoForLiveProcess()

Expected< pt_cpu > TraceIntelPT::GetCPUInfoForLiveProcess ( )
private

◆ GetGlobalProperties()

TraceIntelPT::PluginProperties & TraceIntelPT::GetGlobalProperties ( )
static

Return the global properties for this trace plug-in.

Definition at line 73 of file TraceIntelPT.cpp.

Referenced by DebuggerInitialize(), and PSBBlockAnomalyDetector::PSBBlockAnomalyDetector().

◆ GetGlobalTimer()

ScopedTaskTimer & TraceIntelPT::GetGlobalTimer ( )
Returns
The global copedTaskTimer object for this trace.

Definition at line 742 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::TaskTimer::ForGlobal(), and GetTimer().

Referenced by DumpTraceInfo().

◆ GetPerfZeroTscConversion()

std::optional< LinuxPerfZeroTscConversion > TraceIntelPT::GetPerfZeroTscConversion ( )

◆ GetPluginName()

llvm::StringRef lldb_private::trace_intel_pt::TraceIntelPT::GetPluginName ( )
inlineoverridevirtual

PluginInterface protocol.

Implements lldb_private::PluginInterface.

Definition at line 52 of file TraceIntelPT.h.

References GetPluginNameStatic().

Referenced by DumpTraceInfo(), and Start().

◆ GetPluginNameStatic()

static llvm::StringRef lldb_private::trace_intel_pt::TraceIntelPT::GetPluginNameStatic ( )
inlinestatic

◆ GetProcessTraceStartCommand()

lldb::CommandObjectSP TraceIntelPT::GetProcessTraceStartCommand ( CommandInterpreter interpreter)
overridevirtual

Get the command handle for the "process trace start" command.

Implements lldb_private::Trace.

Definition at line 32 of file TraceIntelPT.cpp.

◆ GetRawTraceSize()

llvm::Expected< std::optional< uint64_t > > TraceIntelPT::GetRawTraceSize ( Thread thread)

◆ GetSchema()

StringRef TraceIntelPT::GetSchema ( )
overridevirtual
Returns
The JSON schema of this Trace plug-in.

Implements lldb_private::Trace.

Definition at line 99 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::GetSchema().

◆ GetSharedPtr()

TraceIntelPTSP TraceIntelPT::GetSharedPtr ( )

Definition at line 123 of file TraceIntelPT.cpp.

Referenced by DoRefreshLiveProcessState().

◆ GetStartConfigurationHelp()

const char * TraceIntelPT::GetStartConfigurationHelp ( )
overridevirtual

◆ GetThreadTimer()

ScopedTaskTimer & TraceIntelPT::GetThreadTimer ( lldb::tid_t  tid)
Returns
The ScopedTaskTimer object for the given thread in this trace.

Definition at line 738 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::TaskTimer::ForThread(), and GetTimer().

Referenced by lldb_private::trace_intel_pt::ThreadDecoder::DoDecode(), and DumpTraceInfo().

◆ GetThreadTraceStartCommand()

lldb::CommandObjectSP TraceIntelPT::GetThreadTraceStartCommand ( CommandInterpreter interpreter)
overridevirtual

Get the command handle for the "thread trace start" command.

Implements lldb_private::Trace.

Definition at line 38 of file TraceIntelPT.cpp.

◆ GetTimer()

TaskTimer & TraceIntelPT::GetTimer ( )
Returns
The timer object for this trace.

Definition at line 736 of file TraceIntelPT.cpp.

References GetUpdatedStorage(), and lldb_private::trace_intel_pt::TraceIntelPT::Storage::task_timer.

Referenced by DumpTraceInfoAsJson(), GetGlobalTimer(), and GetThreadTimer().

◆ GetTraceMode()

TraceIntelPT::TraceMode TraceIntelPT::GetTraceMode ( )

◆ GetUpdatedStorage()

TraceIntelPT::Storage & TraceIntelPT::GetUpdatedStorage ( )
private

Get the storage after refreshing the data in the case of a live process.

Definition at line 551 of file TraceIntelPT.cpp.

References m_storage, and lldb_private::Trace::RefreshLiveProcessState().

Referenced by Decode(), DumpTraceInfo(), DumpTraceInfoAsJson(), FindBeginningOfTimeNanos(), GetPerfZeroTscConversion(), GetRawTraceSize(), GetTimer(), and IsTraced().

◆ Initialize()

void TraceIntelPT::Initialize ( )
static

◆ IsTraced()

bool TraceIntelPT::IsTraced ( lldb::tid_t  tid)
overridevirtual

Check if a thread is currently traced by this object.

Parameters
[in]tidThe id of the thread in question.
Returns
true if the thread is traced by this instance, false otherwise.

Implements lldb_private::Trace.

Definition at line 597 of file TraceIntelPT.cpp.

References GetUpdatedStorage(), lldb_private::trace_intel_pt::TraceIntelPT::Storage::multicpu_decoder, and lldb_private::trace_intel_pt::TraceIntelPT::Storage::thread_decoders.

Referenced by DumpTraceInfo(), and DumpTraceInfoAsJson().

◆ OnThreadBufferRead()

Error TraceIntelPT::OnThreadBufferRead ( lldb::tid_t  tid,
OnBinaryDataReadCallback  callback 
)

◆ SaveToDisk()

Expected< FileSpec > TraceIntelPT::SaveToDisk ( FileSpec  directory,
bool  compact 
)
overridevirtual

Save the trace to the specified directory, which will be created if needed.

This will also create a file <directory>/trace.json with the main properties of the trace session, along with others files which contain the actual trace data. The trace.json file can be used later as input for the "trace load" command to load the trace in LLDB.

Parameters
[in]directoryThe directory where the trace files will be saved.
[in]compactTry not to save to disk information irrelevant to the traced processes. Each trace plug-in implements this in a different fashion.
Returns
A FileSpec pointing to the bundle description file, or an llvm::Error otherwise.

Implements lldb_private::Trace.

Definition at line 105 of file TraceIntelPT.cpp.

References lldb_private::Trace::RefreshLiveProcessState(), and lldb_private::trace_intel_pt::TraceIntelPTBundleSaver::SaveToDisk().

◆ Start() [1/4]

Error TraceIntelPT::Start ( llvm::ArrayRef< lldb::tid_t tids,
StructuredData::ObjectSP  configuration = StructuredData::ObjectSP() 
)
overridevirtual

Start tracing a live process.

Parameters
[in]configurationSee SBTrace::Start(const lldb::SBStructuredData &) for more information.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Implements lldb_private::Trace.

Definition at line 698 of file TraceIntelPT.cpp.

References lldb_private::StructuredData::Object::GetAsDictionary(), lldb_private::trace_intel_pt::kDefaultEnableTscValue, lldb_private::trace_intel_pt::kDefaultIptTraceSize, lldb_private::trace_intel_pt::kDefaultPsbPeriod, lldb_private::trace_intel_pt::ParsingUtils::ParseUserFriendlySizeExpression(), and Start().

◆ Start() [2/4]

llvm::Error TraceIntelPT::Start ( llvm::ArrayRef< lldb::tid_t tids,
uint64_t  ipt_trace_size,
bool  enable_tsc,
std::optional< uint64_t >  psb_period 
)

Start tracing live threads.

More information on the parameters below can be found in the jLLDBTraceStart section in lldb/docs/lldb-gdb-remote.txt.

Parameters
[in]tidsThreads to trace.
[in]ipt_trace_sizeTrace size per thread or per cpu core in bytes.
[in]enable_tscWhether to use enable TSC timestamps or not.
[in]psb_periodThis value defines the period in which PSB packets will be generated.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Definition at line 684 of file TraceIntelPT.cpp.

References lldb_private::TraceIntelPTStartRequest::enable_tsc, GetPluginName(), lldb_private::TraceIntelPTStartRequest::ipt_trace_size, lldb_private::TraceIntelPTStartRequest::psb_period, lldb_private::Trace::Start(), lldb_private::TraceStartRequest::tids, lldb_private::trace_intel_pt::toJSON(), and lldb_private::TraceStartRequest::type.

◆ Start() [3/4]

Error TraceIntelPT::Start ( StructuredData::ObjectSP  configuration = StructuredData::ObjectSP())
overridevirtual

Start tracing a live process.

Parameters
[in]configurationSee SBTrace::Start(const lldb::SBStructuredData &) for more information.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Implements lldb_private::Trace.

Definition at line 656 of file TraceIntelPT.cpp.

References lldb_private::StructuredData::Object::GetAsDictionary(), lldb_private::trace_intel_pt::kDefaultDisableCgroupFiltering, lldb_private::trace_intel_pt::kDefaultEnableTscValue, lldb_private::trace_intel_pt::kDefaultIptTraceSize, lldb_private::trace_intel_pt::kDefaultPerCpuTracing, lldb_private::trace_intel_pt::kDefaultProcessBufferSizeLimit, lldb_private::trace_intel_pt::kDefaultPsbPeriod, and Start().

◆ Start() [4/4]

Error TraceIntelPT::Start ( uint64_t  ipt_trace_size,
uint64_t  total_buffer_size_limit,
bool  enable_tsc,
std::optional< uint64_t >  psb_period,
bool  m_per_cpu_tracing,
bool  disable_cgroup_filtering 
)

Start tracing a live process.

More information on the parameters below can be found in the jLLDBTraceStart section in lldb/docs/lldb-gdb-remote.txt.

Parameters
[in]ipt_trace_sizeTrace size per thread in bytes.
[in]total_buffer_size_limitMaximum total trace size per process in bytes.
[in]enable_tscWhether to use enable TSC timestamps or not.
[in]psb_periodThis value defines the period in which PSB packets will be generated.
[in]per_cpu_tracingThis value defines whether to have an intel pt trace buffer per thread or per cpu core.
[in]disable_cgroup_filteringDisable the cgroup filtering that is automatically applied when doing per cpu tracing.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Definition at line 641 of file TraceIntelPT.cpp.

References lldb_private::TraceIntelPTStartRequest::disable_cgroup_filtering, lldb_private::TraceIntelPTStartRequest::enable_tsc, GetPluginName(), lldb_private::TraceIntelPTStartRequest::ipt_trace_size, lldb_private::TraceIntelPTStartRequest::per_cpu_tracing, lldb_private::TraceIntelPTStartRequest::process_buffer_size_limit, lldb_private::TraceIntelPTStartRequest::psb_period, lldb_private::Trace::Start(), lldb_private::trace_intel_pt::toJSON(), and lldb_private::TraceStartRequest::type.

Referenced by lldb_private::trace_intel_pt::CommandObjectProcessTraceStartIntelPT::DoExecute(), lldb_private::trace_intel_pt::CommandObjectThreadTraceStartIntelPT::DoExecuteOnThreads(), and Start().

◆ Terminate()

void TraceIntelPT::Terminate ( )
static

Friends And Related Function Documentation

◆ TraceIntelPTBundleLoader

friend class TraceIntelPTBundleLoader
friend

Definition at line 199 of file TraceIntelPT.h.

Referenced by CreateInstanceForTraceBundle().

Member Data Documentation

◆ m_cpu_info

std::optional<pt_cpu> lldb_private::trace_intel_pt::TraceIntelPT::m_cpu_info
private

It is provided by either a trace bundle or a live process' "cpuInfo" binary data.

We don't put it in the Storage because this variable doesn't change.

Definition at line 281 of file TraceIntelPT.h.

Referenced by GetCPUInfo().

◆ m_storage

struct lldb_private::trace_intel_pt::TraceIntelPT::Storage lldb_private::trace_intel_pt::TraceIntelPT::m_storage
private

◆ trace_mode

TraceMode lldb_private::trace_intel_pt::TraceIntelPT::trace_mode
private

The tracing mode of post mortem trace.

Definition at line 287 of file TraceIntelPT.h.

Referenced by CreateInstanceForPostmortemTrace(), and GetTraceMode().


The documentation for this class was generated from the following files: