LLDB mainline
|
#include <TraceIntelPTBundleLoader.h>
Classes | |
struct | ParsedProcess |
Helper struct holding the objects created when parsing a process. More... | |
Public Member Functions | |
TraceIntelPTBundleLoader (Debugger &debugger, const llvm::json::Value &bundle_description, llvm::StringRef bundle_dir) | |
llvm::Expected< lldb::TraceSP > | Load () |
Parse the trace bundle description and create the corresponding Target objects. | |
Static Public Member Functions | |
static llvm::StringRef | GetSchema () |
Private Member Functions | |
FileSpec | NormalizePath (const std::string &path) |
Resolve non-absolute paths relative to the bundle folder. | |
lldb::ThreadPostMortemTraceSP | ParseThread (Process &process, const JSONThread &thread) |
Create a post-mortem thread associated with the given process using the definition from thread . | |
llvm::Expected< lldb::TraceSP > | CreateTraceIntelPTInstance (JSONTraceBundleDescription &bundle_description, std::vector< ParsedProcess > &parsed_processes) |
Given a bundle description and a list of fully parsed processes, create an actual Trace instance that "traces" these processes. | |
llvm::Expected< ParsedProcess > | CreateEmptyProcess (lldb::pid_t pid, llvm::StringRef triple) |
Create an empty Process object with given pid and target. | |
llvm::Expected< ParsedProcess > | ParseProcess (const JSONProcess &process) |
Create the corresponding Threads and Process objects given the JSON process definition. | |
llvm::Error | ParseModule (Target &target, const JSONModule &module) |
Create a module associated with the given target using the definition from module . | |
llvm::Expected< ParsedProcess > | ParseKernel (const JSONTraceBundleDescription &bundle_description) |
Create a kernel process and cpu threads given the JSON kernel definition. | |
llvm::Error | CreateJSONError (llvm::json::Path::Root &root, const llvm::json::Value &value) |
Create a user-friendly error message upon a JSON-parsing failure using the json::ObjectMapper functionality. | |
llvm::Expected< std::vector< ParsedProcess > > | LoadBundle (const JSONTraceBundleDescription &bundle_description) |
Create the corresponding Process, Thread and Module objects given this bundle description. | |
llvm::Error | AugmentThreadsFromContextSwitches (JSONTraceBundleDescription &bundle_description) |
When applicable, augment the list of threads in the trace bundle by inspecting the context switch trace. | |
void | NormalizeAllPaths (JSONTraceBundleDescription &bundle_description) |
Modifiy the bundle description by normalizing all the paths relative to the session file directory. | |
Private Attributes | |
Debugger & | m_debugger |
const llvm::json::Value & | m_bundle_description |
const std::string | m_bundle_dir |
Definition at line 20 of file TraceIntelPTBundleLoader.h.
|
inline |
[in] | debugger | The debugger that will own the targets to create. |
[in] | bundle_description | The JSON description of a trace bundle that follows the schema of the intel pt trace plug-in. |
[in] | bundle_dir | The folder where the trace bundle is located. |
Definition at line 37 of file TraceIntelPTBundleLoader.h.
|
private |
When applicable, augment the list of threads in the trace bundle by inspecting the context switch trace.
This only applies for threads of processes already specified in this bundle description.
Definition at line 322 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::trace_intel_pt::JSONCpu::context_switch_trace, lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpus, lldb_private::Trace::OnDataFileRead(), lldb_private::trace_intel_pt::JSONProcess::pid, lldb_private::trace_intel_pt::JSONTraceBundleDescription::processes, lldb_private::trace_intel_pt::JSONProcess::threads, lldb_private::trace_intel_pt::JSONThread::tid, and lldb_private::trace_intel_pt::JSONTraceBundleDescription::tsc_perf_zero_conversion.
Referenced by Load().
|
private |
Create an empty Process object with given pid and target.
Definition at line 94 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::TargetList::CreateTarget(), lldb_private::eLoadDependentsNo, error(), lldb_private::Debugger::GetTargetList(), lldb_private::ProcessTrace::Initialize(), m_debugger, and lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::ParsedProcess::target_sp.
Referenced by ParseKernel(), and ParseProcess().
|
private |
Create a user-friendly error message upon a JSON-parsing failure using the json::ObjectMapper functionality.
[in] | root | The llvm::json::Path::Root used to parse the JSON value. |
[in] | value | The json value that failed to parse. |
Definition at line 68 of file TraceIntelPTBundleLoader.cpp.
References GetSchema(), and lldb_private::toString().
Referenced by Load().
|
private |
Given a bundle description and a list of fully parsed processes, create an actual Trace instance that "traces" these processes.
Definition at line 370 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::trace_intel_pt::TraceIntelPT::CreateInstanceForPostmortemTrace(), lldb_private::trace_intel_pt::JSONTraceBundleDescription::kernel, lldb_private::trace_intel_pt::TraceIntelPT::KernelMode, and lldb_private::trace_intel_pt::TraceIntelPT::UserMode.
Referenced by Load().
|
static |
Definition at line 229 of file TraceIntelPTBundleLoader.cpp.
Referenced by CreateJSONError(), lldb_private::trace_intel_pt::TraceIntelPT::GetSchema(), and lldb_private::trace_intel_pt::TraceIntelPT::Initialize().
Expected< TraceSP > TraceIntelPTBundleLoader::Load | ( | ) |
Parse the trace bundle description and create the corresponding Target objects.
In case of an error, no targets are created.
Definition at line 421 of file TraceIntelPTBundleLoader.cpp.
References AugmentThreadsFromContextSwitches(), CreateJSONError(), CreateTraceIntelPTInstance(), lldb_private::trace_intel_pt::fromJSON(), LoadBundle(), m_bundle_description, and NormalizeAllPaths().
|
private |
Create the corresponding Process, Thread and Module objects given this bundle description.
Definition at line 198 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::TargetList::DeleteTarget(), lldb_private::Debugger::GetTargetList(), lldb_private::trace_intel_pt::JSONTraceBundleDescription::kernel, m_debugger, ParseKernel(), ParseProcess(), and lldb_private::trace_intel_pt::JSONTraceBundleDescription::processes.
Referenced by Load().
|
private |
Modifiy the bundle description by normalizing all the paths relative to the session file directory.
Definition at line 393 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::trace_intel_pt::JSONCpu::context_switch_trace, lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpus, lldb_private::trace_intel_pt::JSONModule::file, lldb_private::FileSpec::GetPath(), lldb_private::trace_intel_pt::JSONThread::ipt_trace, lldb_private::trace_intel_pt::JSONCpu::ipt_trace, lldb_private::trace_intel_pt::JSONTraceBundleDescription::kernel, lldb_private::trace_intel_pt::JSONProcess::modules, NormalizePath(), lldb_private::trace_intel_pt::JSONTraceBundleDescription::processes, lldb_private::trace_intel_pt::JSONModule::system_path, and lldb_private::trace_intel_pt::JSONProcess::threads.
Referenced by Load().
|
private |
Resolve non-absolute paths relative to the bundle folder.
Definition at line 27 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::FileSpec::IsRelative(), m_bundle_dir, and lldb_private::FileSpec::PrependPathComponent().
Referenced by NormalizeAllPaths().
|
private |
Create a kernel process and cpu threads given the JSON kernel definition.
Definition at line 147 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpus, CreateEmptyProcess(), error(), lldb_private::ModuleSpec::GetFileSpec(), lldb_private::trace_intel_pt::JSONCpu::id, lldb_private::trace_intel_pt::JSONCpu::ipt_trace, lldb_private::trace_intel_pt::kDefaultKernelLoadAddress, lldb_private::trace_intel_pt::kDefaultKernelProcessID, and lldb_private::trace_intel_pt::JSONTraceBundleDescription::kernel.
Referenced by LoadBundle().
|
private |
Create a module associated with the given target
using the definition from module
.
Definition at line 34 of file TraceIntelPTBundleLoader.cpp.
References error(), lldb_private::trace_intel_pt::JSONModule::file, lldb_private::ModuleSpec::GetFileSpec(), lldb_private::Target::GetOrCreateModule(), lldb_private::ModuleSpec::GetPlatformFileSpec(), lldb_private::ModuleSpec::GetUUID(), lldb_private::trace_intel_pt::JSONModule::load_address, lldb_private::UUID::SetFromStringRef(), lldb_private::trace_intel_pt::JSONModule::system_path, lldb_private::toString(), lldb_private::trace_intel_pt::JSONModule::uuid, and lldb_private::JSONUINT64::value.
Referenced by ParseProcess().
|
private |
Create the corresponding Threads and Process objects given the JSON process definition.
[in] | process | The JSON process definition |
Definition at line 119 of file TraceIntelPTBundleLoader.cpp.
References CreateEmptyProcess(), lldb_private::trace_intel_pt::JSONProcess::modules, ParseModule(), ParseThread(), lldb_private::trace_intel_pt::JSONProcess::pid, lldb_private::trace_intel_pt::JSONProcess::threads, and lldb_private::trace_intel_pt::JSONProcess::triple.
Referenced by LoadBundle().
|
private |
Create a post-mortem thread associated with the given process
using the definition from thread
.
Definition at line 79 of file TraceIntelPTBundleLoader.cpp.
References lldb_private::ThreadCollection::AddThread(), lldb_private::Process::GetThreadList(), lldb_private::trace_intel_pt::JSONThread::ipt_trace, and lldb_private::trace_intel_pt::JSONThread::tid.
Referenced by ParseProcess().
|
private |
Definition at line 123 of file TraceIntelPTBundleLoader.h.
Referenced by Load().
|
private |
Definition at line 124 of file TraceIntelPTBundleLoader.h.
Referenced by NormalizePath().
|
private |
Definition at line 122 of file TraceIntelPTBundleLoader.h.
Referenced by CreateEmptyProcess(), and LoadBundle().