LLDB  mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::Trace Class Referenceabstract

#include "lldb/Target/Trace.h"

Inheritance diagram for lldb_private::Trace:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::Trace:
Collaboration graph
[legend]

Classes

struct  Storage
 We package all the data that can change upon process stops to make sure this contract is very visible. More...
 

Public Types

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

virtual void Dump (Stream *s) const =0
 Dump the trace data that this plug-in has access to. More...
 
virtual llvm::Error SaveLiveTraceToDisk (FileSpec directory)=0
 Save the trace of a live process to the specified directory, which will be created if needed. More...
 
virtual lldb::CommandObjectSP GetProcessTraceStartCommand (CommandInterpreter &interpreter)=0
 Get the command handle for the "process trace start" command. More...
 
virtual lldb::CommandObjectSP GetThreadTraceStartCommand (CommandInterpreter &interpreter)=0
 Get the command handle for the "thread trace start" command. More...
 
virtual llvm::StringRef GetSchema ()=0
 
virtual llvm::Expected< lldb::TraceCursorUP > CreateNewCursor (Thread &thread)=0
 Get a TraceCursor for the given thread's trace. More...
 
virtual void DumpTraceInfo (Thread &thread, Stream &s, bool verbose)=0
 Dump general info about a given thread's trace. More...
 
virtual bool IsTraced (lldb::tid_t tid)=0
 Check if a thread is currently traced by this object. More...
 
virtual const char * GetStartConfigurationHelp ()=0
 
virtual llvm::Error Start (StructuredData::ObjectSP configuration=StructuredData::ObjectSP())=0
 Start tracing a live process. More...
 
virtual llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, StructuredData::ObjectSP configuration=StructuredData::ObjectSP())=0
 Start tracing live threads. More...
 
llvm::Error Stop (llvm::ArrayRef< lldb::tid_t > tids)
 Stop tracing live threads. More...
 
llvm::Error Stop ()
 Stop tracing all current and future threads of a live process. More...
 
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. More...
 
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. More...
 
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. More...
 
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 llvm::Expected< lldb::TraceSP > FindPluginForPostMortemProcess (Debugger &debugger, const llvm::json::Value &bundle_description, llvm::StringRef session_file_dir)
 Find a trace plug-in using JSON data. More...
 
static llvm::Expected< lldb::TraceSP > FindPluginForLiveProcess (llvm::StringRef plugin_name, Process &process)
 Find a trace plug-in to trace a live process. More...
 
static llvm::Expected< llvm::StringRef > FindPluginSchema (llvm::StringRef plugin_name)
 Get the schema of a Trace plug-in given its name. More...
 
static llvm::Expected< lldb::TraceSP > LoadPostMortemTraceFromFile (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. More...
 
static llvm::Error OnDataFileRead (FileSpec file, OnBinaryDataReadCallback callback)
 Helper method for reading a data file and passing its data to the given callback. More...
 

Protected Member Functions

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

Private Member Functions

StorageGetUpdatedStorage ()
 Get the storage after refreshing the data in the case of a live process. More...
 

Private Attributes

uint32_t m_stop_id = LLDB_INVALID_STOP_ID
 
Processm_live_process = nullptr
 Process traced by this object if doing live tracing. Otherwise it's null. More...
 
struct lldb_private::Trace::Storage m_storage
 

Detailed Description

A plug-in interface definition class for trace information.

Trace plug-ins allow processor trace information to be loaded into LLDB so that the data can be dumped, used for reverse and forward stepping to allow introspection into the reason your process crashed or found its way to its current state.

Trace information can be loaded into a target without a process to allow introspection of the trace information during post mortem analysis, such as when loading core files.

Processor trace information can also be fetched through the process interfaces during a live debug session if your process supports gathering this information.

In order to support live tracing, the name of the plug-in should match the name of the tracing type returned by the gdb-remote packet jLLDBTraceSupported.

Definition at line 46 of file Trace.h.

Member Typedef Documentation

◆ OnBinaryDataReadCallback

using lldb_private::Trace::OnBinaryDataReadCallback = std::function<llvm::Error(llvm::ArrayRef<uint8_t> data)>

Definition at line 256 of file Trace.h.

◆ OnCpusBinaryDataReadCallback

using lldb_private::Trace::OnCpusBinaryDataReadCallback = std::function<llvm::Error( const llvm::DenseMap<lldb::cpu_id_t, llvm::ArrayRef<uint8_t> > &cpu_to_data)>

Definition at line 259 of file Trace.h.

Constructor & Destructor Documentation

◆ Trace() [1/2]

lldb_private::Trace::Trace ( llvm::ArrayRef< lldb::ProcessSP >  postmortem_processes,
llvm::Optional< std::vector< lldb::cpu_id_t >>  postmortem_cpus 
)
protected

Constructor for post mortem processes.

◆ Trace() [2/2]

lldb_private::Trace::Trace ( Process live_process)
inlineprotected

Constructor for a live process.

Definition at line 478 of file Trace.h.

Member Function Documentation

◆ CreateNewCursor()

virtual llvm::Expected<lldb::TraceCursorUP> lldb_private::Trace::CreateNewCursor ( Thread thread)
pure virtual

Get a TraceCursor for the given thread's trace.

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

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ DoRefreshLiveProcessState()

virtual llvm::Error lldb_private::Trace::DoRefreshLiveProcessState ( TraceGetStateResponse  state,
llvm::StringRef  json_response 
)
protectedpure virtual

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.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ Dump()

virtual void lldb_private::Trace::Dump ( Stream s) const
pure virtual

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.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ DumpTraceInfo()

virtual void lldb_private::Trace::DumpTraceInfo ( Thread thread,
Stream s,
bool  verbose 
)
pure virtual

Dump general info about a given thread's trace.

Each Trace plug-in decides which data to show.

Parameters
[in]threadThe thread that owns the trace in question.
[in]sThe stream object where the info will be printed printed.
[in]verboseIf true, print detailed info If false, print compact info

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ FindPluginForLiveProcess()

Expected< lldb::TraceSP > Trace::FindPluginForLiveProcess ( llvm::StringRef  plugin_name,
Process process 
)
static

Find a trace plug-in to trace a live process.

Parameters
[in]plugin_namePlug-in name to search.
[in]processLive process to trace.
Returns
A TraceSP instance, or an llvm::Error if the plug-in name doesn't match any registered plug-ins or tracing couldn't be started.

Definition at line 132 of file Trace.cpp.

References createInvalidPlugInError(), and lldb_private::Process::IsLiveDebugSession().

Referenced by lldb_private::Target::CreateTrace().

◆ FindPluginForPostMortemProcess()

Expected< lldb::TraceSP > Trace::FindPluginForPostMortemProcess ( Debugger debugger,
const llvm::json::Value &  bundle_description,
llvm::StringRef  session_file_dir 
)
static

Find a trace plug-in using JSON data.

When loading trace data from disk, the information for the trace data can be contained in multiple files and require plug-in specific information about the CPU. Using data like JSON provides an easy way to specify all of the settings and information that we will need to load trace data into LLDB. This structured data can include:

  • The plug-in name (this allows a specific plug-in to be selected)
  • Architecture or target triple
  • one or more paths to the trace data file on disk
    • cpu trace data
    • thread events or related information
  • shared library load information to use for this trace data that allows a target to be created so the trace information can be symbolicated so that the trace information can be displayed to the user
    • shared library path
    • load address
    • information on how to fetch the shared library
      • path to locally cached file on disk
      • URL to download the file
  • Any information needed to load the trace file
    • CPU information
    • Custom plug-in information needed to decode the trace information correctly.
Parameters
[in]debuggerThe debugger instance where new Targets will be created as part of the JSON data parsing.
[in]bundle_descriptionThe trace bundle description object describing the trace session.
[in]bundle_dirThe path to the directory that contains the trace bundle.

Definition at line 117 of file Trace.cpp.

References createInvalidPlugInError(), llvm::json::fromJSON(), and JSONSimpleTraceBundleDescription::type.

◆ FindPluginSchema()

Expected< StringRef > Trace::FindPluginSchema ( llvm::StringRef  plugin_name)
static

Get the schema of a Trace plug-in given its name.

Parameters
[in]plugin_nameName of the trace plugin.

Definition at line 145 of file Trace.cpp.

References createInvalidPlugInError().

◆ GetAllProcesses()

std::vector< Process * > Trace::GetAllProcesses ( )
Returns
All the currently traced processes.

Definition at line 359 of file Trace.cpp.

Referenced by BuildProcessesSection().

◆ GetLiveCpuBinaryData()

Expected< std::vector< uint8_t > > Trace::GetLiveCpuBinaryData ( lldb::cpu_id_t  cpu_id,
llvm::StringRef  kind 
)
protected

Get binary data of a live cpu given a data identifier.

Parameters
[in]cpu_idThe cpu whose data is requested.
[in]kindThe kind of data requested.
Returns
A vector of bytes with the requested data, or an llvm::Error in case of failures.

Definition at line 244 of file Trace.cpp.

◆ GetLiveCpuBinaryDataSize()

Optional< uint64_t > Trace::GetLiveCpuBinaryDataSize ( lldb::cpu_id_t  cpu_id,
llvm::StringRef  kind 
)
protected

Get the size of the data returned by GetLiveCpuBinaryData.

Definition at line 191 of file Trace.cpp.

References lldb_private::Trace::Storage::live_cpu_data_sizes, and Lookup().

◆ GetLiveProcess()

Process * Trace::GetLiveProcess ( )
protected

Get the currently traced live process.

Returns
If it's not a live process, return nullptr.

Definition at line 353 of file Trace.cpp.

Referenced by lldb_private::trace_intel_pt::TraceIntelPT::DoRefreshLiveProcessState(), and lldb_private::trace_intel_pt::TraceIntelPT::GetRawTraceSize().

◆ GetLiveProcessBinaryData()

Expected< std::vector< uint8_t > > Trace::GetLiveProcessBinaryData ( llvm::StringRef  kind)
protected

Get binary data of the current process given a data identifier.

Parameters
[in]kindThe kind of data requested.
Returns
A vector of bytes with the requested data, or an llvm::Error in case of failures.

Definition at line 262 of file Trace.cpp.

Referenced by lldb_private::trace_intel_pt::TraceIntelPT::GetCPUInfoForLiveProcess().

◆ GetLiveProcessBinaryDataSize()

Optional< uint64_t > Trace::GetLiveProcessBinaryDataSize ( llvm::StringRef  kind)
protected

Get the size of the data returned by GetLiveProcessBinaryData.

Definition at line 197 of file Trace.cpp.

References lldb_private::Trace::Storage::live_process_data, and Lookup().

◆ GetLiveProcessState()

Expected< std::string > Trace::GetLiveProcessState ( )
protected

Get the current tracing state of a live process and its threads.

Returns
A JSON object string with custom data depending on the trace technology, or an llvm::Error in case of errors.

Definition at line 177 of file Trace.cpp.

◆ GetLiveThreadBinaryData()

Expected< std::vector< uint8_t > > Trace::GetLiveThreadBinaryData ( lldb::tid_t  tid,
llvm::StringRef  kind 
)
protected

Get binary data of a live thread given a data identifier.

Parameters
[in]tidThe thread whose data is requested.
[in]kindThe kind of data requested.
Returns
A vector of bytes with the requested data, or an llvm::Error in case of failures.

Definition at line 230 of file Trace.cpp.

◆ GetLiveThreadBinaryDataSize()

Optional< uint64_t > Trace::GetLiveThreadBinaryDataSize ( lldb::tid_t  tid,
llvm::StringRef  kind 
)
protected

Get the size of the data returned by GetLiveThreadBinaryData.

Definition at line 185 of file Trace.cpp.

References lldb_private::Trace::Storage::live_thread_data, and Lookup().

Referenced by lldb_private::trace_intel_pt::TraceIntelPT::GetRawTraceSize().

◆ GetLiveTraceBinaryData()

Expected< std::vector< uint8_t > > Trace::GetLiveTraceBinaryData ( const TraceGetBinaryDataRequest request,
uint64_t  expected_size 
)
protected

Dispatcher for live trace data requests with some additional error checking.

Definition at line 203 of file Trace.cpp.

References lldb_private::TraceGetBinaryDataRequest::cpu_id, lldb_private::TraceGetBinaryDataRequest::kind, and lldb_private::TraceGetBinaryDataRequest::tid.

◆ GetPostMortemCpuDataFile()

llvm::Expected< FileSpec > Trace::GetPostMortemCpuDataFile ( lldb::cpu_id_t  cpu_id,
llvm::StringRef  kind 
)
protected

Get the file path containing data of a postmortem cpu given a data identifier.

Parameters
[in]cpu_idThe cpu whose data is requested.
[in]kindThe kind of data requested.
Returns
The file spec containing the requested data, or an llvm::Error in case of failures.

Definition at line 383 of file Trace.cpp.

References Lookup(), and lldb_private::Trace::Storage::postmortem_cpu_data.

◆ GetPostMortemProcesses()

ArrayRef< Process * > Trace::GetPostMortemProcesses ( )
protected

Get the currently traced postmortem processes.

Returns
If it's not a live process session, return an empty list.

Definition at line 355 of file Trace.cpp.

◆ GetPostMortemThreadDataFile()

llvm::Expected< FileSpec > Trace::GetPostMortemThreadDataFile ( lldb::tid_t  tid,
llvm::StringRef  kind 
)
protected

Get the file path containing data of a postmortem thread given a data identifier.

Parameters
[in]tidThe thread whose data is requested.
[in]kindThe kind of data requested.
Returns
The file spec containing the requested data, or an llvm::Error in case of failures.

Definition at line 371 of file Trace.cpp.

References Lookup(), and lldb_private::Trace::Storage::postmortem_thread_data.

◆ GetProcessTraceStartCommand()

virtual lldb::CommandObjectSP lldb_private::Trace::GetProcessTraceStartCommand ( CommandInterpreter interpreter)
pure virtual

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

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

Referenced by CommandObjectProcessTraceStart::GetDelegateCommand().

◆ GetSchema()

virtual llvm::StringRef lldb_private::Trace::GetSchema ( )
pure virtual
Returns
The JSON schema of this Trace plug-in.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ GetStartConfigurationHelp()

virtual const char* lldb_private::Trace::GetStartConfigurationHelp ( )
pure virtual
Returns
A description of the parameters to use for the Trace::Start method.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ GetStopID()

uint32_t Trace::GetStopID ( )
Returns
The stop ID of the live process being traced, or an invalid stop ID if the trace is in an error or invalid state.

Definition at line 365 of file Trace.cpp.

◆ GetThreadTraceStartCommand()

virtual lldb::CommandObjectSP lldb_private::Trace::GetThreadTraceStartCommand ( CommandInterpreter interpreter)
pure virtual

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

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

Referenced by CommandObjectTraceStart::GetDelegateCommand().

◆ GetTracedCpus()

ArrayRef< lldb::cpu_id_t > Trace::GetTracedCpus ( )
Returns
The list of cpus being traced. Might be empty depending on the plugin.

Definition at line 509 of file Trace.cpp.

References lldb_private::Trace::Storage::cpus.

Referenced by BuildCpusSection().

◆ GetTracedProcesses()

std::vector< Process * > Trace::GetTracedProcesses ( )
protected

Return the list of processes traced by this instance.

None of the returned pointers are invalid.

Definition at line 516 of file Trace.cpp.

References lldb_private::Trace::Storage::postmortem_processes.

◆ GetUpdatedStorage()

Trace::Storage & Trace::GetUpdatedStorage ( )
private

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

Definition at line 274 of file Trace.cpp.

◆ IsTraced()

virtual bool lldb_private::Trace::IsTraced ( lldb::tid_t  tid)
pure virtual

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.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ LoadPostMortemTraceFromFile()

Expected< lldb::TraceSP > Trace::LoadPostMortemTraceFromFile ( Debugger debugger,
const FileSpec trace_description_file 
)
static

Load a trace from a trace description file and create Targets, Processes and Threads based on the contents of such file.

Parameters
[in]debuggerThe debugger instance where new Targets will be created as part of the JSON data parsing.
[in]trace_description_fileThe file containing the necessary information to load the trace.
Returns
A TraceSP instance, or an llvm::Error if loading the trace fails.

Definition at line 94 of file Trace.cpp.

References lldb_private::ConstString::AsCString(), lldb_private::FileSpec::GetDirectory(), and lldb_private::FileSpec::GetPath().

◆ OnAllCpusBinaryDataRead()

llvm::Error Trace::OnAllCpusBinaryDataRead ( llvm::StringRef  kind,
OnCpusBinaryDataReadCallback  callback 
)

Similar to OnCpuBinaryDataRead but this is able to fetch the same data from all cpus at once.

Definition at line 477 of file Trace.cpp.

References lldb_private::Trace::Storage::cpus.

◆ OnCpuBinaryDataRead()

llvm::Error Trace::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.

The reason of having a callback is to free the caller from having to manage the life cycle of the data and to hide the different data fetching procedures that exist for live and post mortem cpus.

The fetched data is not persisted after the callback is invoked.

Parameters
[in]cpu_idThe cpu who owns the data.
[in]kindThe kind of data to read.
[in]callbackThe callback to be invoked once the data was successfully read. Its return value, which is an llvm::Error, is returned by this function.
Returns
An llvm::Error if the data couldn't be fetched, or the return value of the callback, otherwise.

Definition at line 500 of file Trace.cpp.

Referenced by BuildCpusSection(), and GetIntelPTSubtracesForCpu().

◆ OnDataFileRead()

llvm::Error Trace::OnDataFileRead ( FileSpec  file,
OnBinaryDataReadCallback  callback 
)
static

Helper method for reading a data file and passing its data to the given callback.

Definition at line 433 of file Trace.cpp.

References lldb_private::FileSpec::GetCString(), lldb_private::FileSpec::GetPath(), and lldb_private::toString().

◆ OnLiveCpuBinaryDataRead()

llvm::Error Trace::OnLiveCpuBinaryDataRead ( lldb::cpu_id_t  cpu,
llvm::StringRef  kind,
OnBinaryDataReadCallback  callback 
)
protected

Implementation of OnLiveBinaryDataRead() for live cpus.

Definition at line 417 of file Trace.cpp.

References lldb_private::Trace::Storage::live_cpu_data, and LookupAsPtr().

◆ OnLiveThreadBinaryDataRead()

llvm::Error Trace::OnLiveThreadBinaryDataRead ( lldb::tid_t  tid,
llvm::StringRef  kind,
OnBinaryDataReadCallback  callback 
)
protected

Implementation of OnThreadBinaryDataRead() for live threads.

Definition at line 409 of file Trace.cpp.

◆ OnPostMortemCpuBinaryDataRead()

llvm::Error Trace::OnPostMortemCpuBinaryDataRead ( lldb::cpu_id_t  cpu_id,
llvm::StringRef  kind,
OnBinaryDataReadCallback  callback 
)
protected

Implementation of OnCpuBinaryDataRead() for post mortem cpus.

Definition at line 459 of file Trace.cpp.

◆ OnPostMortemThreadBinaryDataRead()

llvm::Error Trace::OnPostMortemThreadBinaryDataRead ( lldb::tid_t  tid,
llvm::StringRef  kind,
OnBinaryDataReadCallback  callback 
)
protected

Implementation of OnThreadBinaryDataRead() for post mortem threads.

Definition at line 450 of file Trace.cpp.

◆ OnThreadBinaryDataRead()

llvm::Error Trace::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.

The reason of having a callback is to free the caller from having to manage the life cycle of the data and to hide the different data fetching procedures that exist for live and post mortem threads.

The fetched data is not persisted after the callback is invoked.

Parameters
[in]tidThe tid who owns the data.
[in]kindThe kind of data to read.
[in]callbackThe callback to be invoked once the data was successfully read. Its return value, which is an llvm::Error, is returned by this function.
Returns
An llvm::Error if the data couldn't be fetched, or the return value of the callback, otherwise.

Definition at line 468 of file Trace.cpp.

Referenced by lldb_private::trace_intel_pt::TraceIntelPT::OnThreadBufferRead().

◆ RefreshLiveProcessState()

const char * Trace::RefreshLiveProcessState ( )
protected

Method to be invoked by the plug-in to refresh the live process state.

It will invoked DoRefreshLiveProcessState at some point, which should be implemented by the plug-in for custom state handling.

The result is cached through the same process stop. Even in the case of errors, it caches the error.

Returns
An error message if this operation failed, or nullptr otherwise.

Definition at line 279 of file Trace.cpp.

References lldb_private::TraceThreadState::binary_data, lldb_private::TraceCpuState::binary_data, lldb_private::GetLog(), lldb_private::TraceCpuState::id, lldb_private::TraceBinaryData::kind, LLDB_LOG, lldb_private::TraceBinaryData::size, string(), lldb_private::TraceThreadState::tid, lldb_private::toString(), and warning().

Referenced by lldb_private::trace_intel_pt::TraceIntelPT::Decode(), and lldb_private::trace_intel_pt::TraceIntelPT::GetUpdatedStorage().

◆ SaveLiveTraceToDisk()

virtual llvm::Error lldb_private::Trace::SaveLiveTraceToDisk ( FileSpec  directory)
pure virtual

Save the trace of a live process to the specified directory, which will be created if needed.

This will also create a 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. The process being trace is not a live process, return an error.

Parameters
[in]directoryThe directory where the trace files will be saved.
Returns
llvm::success if the operation was successful, or an llvm::Error otherwise.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ SetPostMortemCpuDataFile()

void Trace::SetPostMortemCpuDataFile ( lldb::cpu_id_t  cpu_id,
llvm::StringRef  kind,
FileSpec  file_spec 
)
protected

Associate a given cpu with a data file using a data identifier.

Parameters
[in]cpu_idThe cpu associated with the data file.
[in]kindThe kind of data being registered.
[in]file_specThe path of the data file.

Definition at line 402 of file Trace.cpp.

References lldb_private::Trace::Storage::postmortem_cpu_data.

◆ SetPostMortemThreadDataFile()

void Trace::SetPostMortemThreadDataFile ( lldb::tid_t  tid,
llvm::StringRef  kind,
FileSpec  file_spec 
)
protected

Associate a given thread with a data file using a data identifier.

Parameters
[in]tidThe thread associated with the data file.
[in]kindThe kind of data being registered.
[in]file_specThe path of the data file.

Definition at line 396 of file Trace.cpp.

References lldb_private::Trace::Storage::postmortem_thread_data.

◆ Start() [1/3]

Error Trace::Start ( const llvm::json::Value &  request)
protected

Start tracing a live process or its threads.

Parameters
[in]requestJSON object with the information necessary to start tracing. In the case of gdb-remote processes, this JSON object should conform to the jLLDBTraceStart packet.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Definition at line 153 of file Trace.cpp.

◆ Start() [2/3]

virtual llvm::Error lldb_private::Trace::Start ( llvm::ArrayRef< lldb::tid_t tids,
StructuredData::ObjectSP  configuration = StructuredData::ObjectSP() 
)
pure virtual

Start tracing live threads.

Parameters
[in]tidsThreads to trace. This method tries to trace as many threads as possible.
[in]configurationSee SBTrace::Start(const lldb::SBThread &, const lldb::SBStructuredData &) for more information.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ Start() [3/3]

virtual llvm::Error lldb_private::Trace::Start ( StructuredData::ObjectSP  configuration = StructuredData::ObjectSP())
pure virtual

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.

Implemented in lldb_private::trace_intel_pt::TraceIntelPT.

◆ Stop() [1/2]

Error Trace::Stop ( )

Stop tracing all current and future threads of a live process.

Parameters
[in]requestThe information determining which threads or process to stop tracing.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Definition at line 161 of file Trace.cpp.

◆ Stop() [2/2]

Error Trace::Stop ( llvm::ArrayRef< lldb::tid_t tids)

Stop tracing live threads.

Parameters
[in]tidsThe threads to stop tracing on.
Returns
llvm::Error::success if the operation was successful, or llvm::Error otherwise.

Definition at line 169 of file Trace.cpp.

Member Data Documentation

◆ m_live_process

Process* lldb_private::Trace::m_live_process = nullptr
private

Process traced by this object if doing live tracing. Otherwise it's null.

Definition at line 536 of file Trace.h.

◆ m_stop_id

uint32_t lldb_private::Trace::m_stop_id = LLDB_INVALID_STOP_ID
private

Definition at line 533 of file Trace.h.

◆ m_storage

struct lldb_private::Trace::Storage lldb_private::Trace::m_storage
private

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