LLDB  mainline
Classes | Public Types | 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]
Collaboration diagram for lldb_private::trace_intel_pt::TraceIntelPT:
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

enum  TraceMode { TraceMode::UserMode, TraceMode::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. More...
 
llvm::Expected< FileSpecSaveToDisk (FileSpec directory, bool compact) override
 Save the trace to the specified directory, which will be created if needed. More...
 
 ~TraceIntelPT () override=default
 
lldb::CommandObjectSP GetProcessTraceStartCommand (CommandInterpreter &interpreter) override
 Get the command handle for the "process trace start" command. More...
 
lldb::CommandObjectSP GetThreadTraceStartCommand (CommandInterpreter &interpreter) override
 Get the command handle for the "thread trace start" command. More...
 
llvm::StringRef GetSchema () override
 
llvm::Expected< lldb::TraceCursorSP > CreateNewCursor (Thread &thread) override
 Get a TraceCursor for the given thread's trace. More...
 
void DumpTraceInfo (Thread &thread, Stream &s, bool verbose, bool json) override
 Dump general info about a given thread's trace. More...
 
llvm::Expected< llvm::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. More...
 
bool IsTraced (lldb::tid_t tid) override
 Check if a thread is currently traced by this object. More...
 
const char * GetStartConfigurationHelp () override
 
llvm::Error Start (uint64_t ipt_trace_size, uint64_t total_buffer_size_limit, bool enable_tsc, llvm::Optional< uint64_t > psb_period, bool m_per_cpu_tracing, bool disable_cgroup_filtering)
 Start tracing a live process. More...
 
llvm::Error Start (StructuredData::ObjectSP configuration=StructuredData::ObjectSP()) override
 Start tracing a live process. More...
 
llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, uint64_t ipt_trace_size, bool enable_tsc, llvm::Optional< uint64_t > psb_period)
 Start tracing live threads. More...
 
llvm::Error Start (llvm::ArrayRef< lldb::tid_t > tids, StructuredData::ObjectSP configuration=StructuredData::ObjectSP()) override
 Start tracing a live process. More...
 
llvm::Error OnThreadBufferRead (lldb::tid_t tid, OnBinaryDataReadCallback callback)
 See Trace::OnThreadBinaryDataRead(). More...
 
llvm::Expected< pt_cpu > GetCPUInfo ()
 Get or fetch the cpu information from, for example, /proc/cpuinfo. More...
 
llvm::Optional< LinuxPerfZeroTscConversionGetPerfZeroTscConversion ()
 Get or fetch the values used to convert to and from TSCs and nanos. More...
 
TaskTimerGetTimer ()
 
ScopedTaskTimerGetThreadTimer (lldb::tid_t tid)
 
ScopedTaskTimerGetGlobalTimer ()
 
TraceIntelPTSP GetSharedPtr ()
 
TraceMode GetTraceMode ()
 
- Public Member Functions inherited from lldb_private::Trace
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
 
 PluginInterface (const PluginInterface &)=delete
 
PluginInterfaceoperator= (const PluginInterface &)=delete
 

Private Member Functions

llvm::Expected< pt_cpu > GetCPUInfoForLiveProcess ()
 
 TraceIntelPT (Process &live_process)
 Constructor for live processes. More...
 
llvm::Expected< DecodedThreadSPDecode (Thread &thread)
 Decode the trace of the given thread that, i.e. More...
 
llvm::Expected< llvm::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. More...
 

Private Attributes

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

Friends

class TraceIntelPTBundleLoader
 
llvm::StringRef GetPluginName () override
 PluginInterface protocol. More...
 
static void Initialize ()
 
static void Terminate ()
 
static llvm::Expected< lldb::TraceSP > CreateInstanceForTraceBundle (const llvm::json::Value &trace_bundle_description, llvm::StringRef bundle_dir, Debugger &debugger)
 Create an instance of this class from a trace bundle. More...
 
static llvm::Expected< lldb::TraceSP > CreateInstanceForLiveProcess (Process &process)
 
static llvm::StringRef GetPluginNameStatic ()
 
 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++. More...
 
static TraceIntelPTSP CreateInstanceForPostmortemTrace (JSONTraceBundleDescription &bundle_description, llvm::ArrayRef< lldb::ProcessSP > traced_processes, llvm::ArrayRef< lldb::ThreadPostMortemTraceSP > traced_threads, TraceMode trace_mode)
 Postmortem trace constructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lldb_private::Trace
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 inherited from lldb_private::Trace
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...
 
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...
 

Detailed Description

Definition at line 23 of file TraceIntelPT.h.

Member Enumeration Documentation

◆ TraceMode

Enumerator
UserMode 
KernelMode 

Definition at line 174 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 215 of file TraceIntelPT.h.

Member Function Documentation

◆ CreateInstanceForLiveProcess()

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

◆ 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 83 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, and lldb_private::trace_intel_pt::JSONTraceBundleDescription::tsc_perf_zero_conversion.

◆ 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 64 of file TraceIntelPT.cpp.

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

◆ 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 179 of file TraceIntelPT.cpp.

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

◆ 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 128 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 479 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 57 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< Optional< uint64_t > > TraceIntelPT::FindBeginningOfTimeNanos ( )
private
Returns
The lowest timestamp in nanoseconds in all traces if available, llvm::None 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 142 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 459 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

◆ GetGlobalTimer()

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

Definition at line 665 of file TraceIntelPT.cpp.

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

Referenced by DumpTraceInfo().

◆ GetPerfZeroTscConversion()

llvm::Optional< LinuxPerfZeroTscConversion > TraceIntelPT::GetPerfZeroTscConversion ( )

Get or fetch the values used to convert to and from TSCs and nanos.

Definition at line 470 of file TraceIntelPT.cpp.

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

Referenced by lldb_private::trace_intel_pt::TraceIntelPTBundleSaver::SaveToDisk().

◆ GetPluginName()

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

PluginInterface protocol.

Implements lldb_private::PluginInterface.

Definition at line 34 of file TraceIntelPT.h.

References GetPluginNameStatic().

Referenced by DumpTraceInfo().

◆ GetPluginNameStatic()

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

Definition at line 61 of file TraceIntelPT.h.

Referenced by GetPluginName().

◆ 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 31 of file TraceIntelPT.cpp.

◆ GetRawTraceSize()

llvm::Expected< 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 53 of file TraceIntelPT.cpp.

◆ GetSharedPtr()

TraceIntelPTSP TraceIntelPT::GetSharedPtr ( )

Definition at line 77 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 661 of file TraceIntelPT.cpp.

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

Referenced by 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 37 of file TraceIntelPT.cpp.

◆ GetTimer()

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

Definition at line 659 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 474 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

Definition at line 42 of file TraceIntelPT.cpp.

◆ 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 520 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 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 59 of file TraceIntelPT.cpp.

References lldb_private::trace_intel_pt::TraceIntelPTBundleSaver::SaveToDisk().

◆ Start() [1/4]

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

◆ Start() [2/4]

llvm::Error lldb_private::trace_intel_pt::TraceIntelPT::Start ( llvm::ArrayRef< lldb::tid_t tids,
uint64_t  ipt_trace_size,
bool  enable_tsc,
llvm::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.

◆ 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 579 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]

llvm::Error lldb_private::trace_intel_pt::TraceIntelPT::Start ( uint64_t  ipt_trace_size,
uint64_t  total_buffer_size_limit,
bool  enable_tsc,
llvm::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.

Referenced by Start().

◆ Terminate()

void TraceIntelPT::Terminate ( )
static

Definition at line 49 of file TraceIntelPT.cpp.

Friends And Related Function Documentation

◆ TraceIntelPTBundleLoader

friend class TraceIntelPTBundleLoader
friend

Definition at line 179 of file TraceIntelPT.h.

Member Data Documentation

◆ m_cpu_info

llvm::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 261 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 267 of file TraceIntelPT.h.


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