9#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPT_H
10#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPT_H
18#include "llvm/Support/raw_ostream.h"
22namespace trace_intel_pt {
46 bool compact)
override;
73 const llvm::json::Value &trace_bundle_description,
74 llvm::StringRef bundle_dir,
Debugger &debugger);
76 static llvm::Expected<lldb::TraceSP>
100 llvm::StringRef json_response)
override;
134 llvm::Error
Start(uint64_t ipt_trace_size, uint64_t total_buffer_size_limit,
135 bool enable_tsc, std::optional<uint64_t> psb_period,
136 bool m_per_cpu_tracing,
bool disable_cgroup_filtering);
162 llvm::Error
Start(llvm::ArrayRef<lldb::tid_t> tids, uint64_t ipt_trace_size,
163 bool enable_tsc, std::optional<uint64_t> psb_period);
166 llvm::Error
Start(llvm::ArrayRef<lldb::tid_t> tids,
223 llvm::ArrayRef<lldb::ProcessSP> traced_processes,
224 llvm::ArrayRef<lldb::ThreadPostMortemTraceSP> traced_threads,
230 llvm::ArrayRef<lldb::ProcessSP> traced_processes,
A class to manage flag bits.
A plug-in interface definition class for debugging a process.
A stream class that can stream formatted output to a file.
std::shared_ptr< Object > ObjectSP
A plug-in interface definition class for trace information.
std::function< llvm::Error(llvm::ArrayRef< uint8_t > data)> OnBinaryDataReadCallback
Class used to track the duration of long running tasks related to a single scope for reporting.
Class used to track the duration of long running tasks for reporting.
Properties to be used with the settings command.
uint64_t GetExtremelyLargeDecodingThreshold()
~PluginProperties() override=default
static llvm::StringRef GetSettingName()
uint64_t GetInfiniteDecodingLoopVerificationThreshold()
static TraceIntelPTSP CreateInstanceForPostmortemTrace(JSONTraceBundleDescription &bundle_description, llvm::ArrayRef< lldb::ProcessSP > traced_processes, llvm::ArrayRef< lldb::ThreadPostMortemTraceSP > traced_threads, TraceMode trace_mode)
Postmortem trace constructor.
TraceIntelPT(Process &live_process)
Constructor for live processes.
void DumpTraceInfo(Thread &thread, Stream &s, bool verbose, bool json) override
Dump general info about a given thread's trace.
llvm::StringRef GetSchema() override
llvm::Error DoRefreshLiveProcessState(TraceGetStateResponse state, llvm::StringRef json_response) override
Method to be overriden by the plug-in to refresh its own state.
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.
static void DebuggerInitialize(Debugger &debugger)
llvm::Error OnThreadBufferRead(lldb::tid_t tid, OnBinaryDataReadCallback callback)
See Trace::OnThreadBinaryDataRead().
void Dump(Stream *s) const override
Dump the trace data that this plug-in has access to.
static llvm::Expected< lldb::TraceSP > CreateInstanceForLiveProcess(Process &process)
~TraceIntelPT() override=default
ScopedTaskTimer & GetGlobalTimer()
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.
struct lldb_private::trace_intel_pt::TraceIntelPT::Storage m_storage
Storage & GetUpdatedStorage()
Get the storage after refreshing the data in the case of a live process.
llvm::Expected< lldb::TraceCursorSP > CreateNewCursor(Thread &thread) override
Get a TraceCursor for the given thread's trace.
const char * GetStartConfigurationHelp() override
void DumpTraceInfoAsJson(Thread &thread, Stream &s, bool verbose)
llvm::Expected< pt_cpu > GetCPUInfoForLiveProcess()
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.
static llvm::StringRef GetPluginNameStatic()
static PluginProperties & GetGlobalProperties()
Return the global properties for this trace plug-in.
lldb::CommandObjectSP GetThreadTraceStartCommand(CommandInterpreter &interpreter) override
Get the command handle for the "thread trace start" command.
TraceIntelPTSP GetSharedPtr()
llvm::Expected< DecodedThreadSP > Decode(Thread &thread)
Decode the trace of the given thread that, i.e.
llvm::Expected< std::optional< uint64_t > > GetRawTraceSize(Thread &thread)
ScopedTaskTimer & GetThreadTimer(lldb::tid_t tid)
lldb::CommandObjectSP GetProcessTraceStartCommand(CommandInterpreter &interpreter) override
Get the command handle for the "process trace start" command.
llvm::Expected< pt_cpu > GetCPUInfo()
Get or fetch the cpu information from, for example, /proc/cpuinfo.
llvm::StringRef GetPluginName() override
PluginInterface protocol.
llvm::Expected< std::optional< uint64_t > > FindBeginningOfTimeNanos()
std::optional< LinuxPerfZeroTscConversion > GetPerfZeroTscConversion()
Get or fetch the values used to convert to and from TSCs and nanos.
bool IsTraced(lldb::tid_t tid) override
Check if a thread is currently traced by this object.
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 s...
llvm::Expected< FileSpec > SaveToDisk(FileSpec directory, bool compact) override
Save the trace to the specified directory, which will be created if needed.
std::shared_ptr< TraceIntelPT > TraceIntelPTSP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
We package all the data that can change upon process stops to make sure this contract is very visible...
std::optional< LinuxPerfZeroTscConversion > tsc_conversion
It is provided by either a trace bundle or a live process to convert TSC counters to and from nanos.
std::optional< TraceIntelPTMultiCpuDecoder > multicpu_decoder
bool beginning_of_time_nanos_calculated
std::optional< uint64_t > beginning_of_time_nanos
llvm::DenseMap< lldb::tid_t, std::unique_ptr< ThreadDecoder > > thread_decoders
These decoders are used for the non-per-cpu case.
TaskTimer task_timer
Helper variable used to track long running operations for telemetry.