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

#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::TraceSPLoad ()
 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::TraceSPCreateTraceIntelPTInstance (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< ParsedProcessCreateEmptyProcess (lldb::pid_t pid, llvm::StringRef triple)
 Create an empty Process object with given pid and target.
 
llvm::Expected< ParsedProcessParseProcess (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< ParsedProcessParseKernel (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

Debuggerm_debugger
 
const llvm::json::Value & m_bundle_description
 
const std::string m_bundle_dir
 

Detailed Description

Definition at line 20 of file TraceIntelPTBundleLoader.h.

Constructor & Destructor Documentation

◆ TraceIntelPTBundleLoader()

lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::TraceIntelPTBundleLoader ( Debugger debugger,
const llvm::json::Value &  bundle_description,
llvm::StringRef  bundle_dir 
)
inline
Parameters
[in]debuggerThe debugger that will own the targets to create.
[in]bundle_descriptionThe JSON description of a trace bundle that follows the schema of the intel pt trace plug-in.
[in]bundle_dirThe folder where the trace bundle is located.

Definition at line 37 of file TraceIntelPTBundleLoader.h.

Member Function Documentation

◆ AugmentThreadsFromContextSwitches()

Error TraceIntelPTBundleLoader::AugmentThreadsFromContextSwitches ( JSONTraceBundleDescription bundle_description)
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.

Returns
An llvm::Error in case if failures, or llvm::Error::success otherwise.

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().

◆ CreateEmptyProcess()

Expected< TraceIntelPTBundleLoader::ParsedProcess > TraceIntelPTBundleLoader::CreateEmptyProcess ( lldb::pid_t  pid,
llvm::StringRef  triple 
)
private

◆ CreateJSONError()

Error TraceIntelPTBundleLoader::CreateJSONError ( llvm::json::Path::Root &  root,
const llvm::json::Value &  value 
)
private

Create a user-friendly error message upon a JSON-parsing failure using the json::ObjectMapper functionality.

Parameters
[in]rootThe llvm::json::Path::Root used to parse the JSON value.
[in]valueThe json value that failed to parse.
Returns
An llvm::Error containing the user-friendly error message.

Definition at line 68 of file TraceIntelPTBundleLoader.cpp.

References GetSchema(), and lldb_private::toString().

Referenced by Load().

◆ CreateTraceIntelPTInstance()

Expected< TraceSP > TraceIntelPTBundleLoader::CreateTraceIntelPTInstance ( JSONTraceBundleDescription bundle_description,
std::vector< ParsedProcess > &  parsed_processes 
)
private

◆ GetSchema()

StringRef TraceIntelPTBundleLoader::GetSchema ( )
static
Returns
The JSON schema for the bundle description.

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().

◆ Load()

Expected< TraceSP > TraceIntelPTBundleLoader::Load ( )

Parse the trace bundle description and create the corresponding Target objects.

In case of an error, no targets are created.

Returns
A lldb::TraceSP instance created according to the trace bundle information. In case of errors, return a null pointer.

Definition at line 421 of file TraceIntelPTBundleLoader.cpp.

References AugmentThreadsFromContextSwitches(), CreateJSONError(), CreateTraceIntelPTInstance(), lldb_private::trace_intel_pt::fromJSON(), LoadBundle(), m_bundle_description, and NormalizeAllPaths().

◆ LoadBundle()

Expected< std::vector< TraceIntelPTBundleLoader::ParsedProcess > > TraceIntelPTBundleLoader::LoadBundle ( const JSONTraceBundleDescription bundle_description)
private

◆ NormalizeAllPaths()

void TraceIntelPTBundleLoader::NormalizeAllPaths ( JSONTraceBundleDescription bundle_description)
private

◆ NormalizePath()

FileSpec TraceIntelPTBundleLoader::NormalizePath ( const std::string &  path)
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().

◆ ParseKernel()

Expected< TraceIntelPTBundleLoader::ParsedProcess > TraceIntelPTBundleLoader::ParseKernel ( const JSONTraceBundleDescription bundle_description)
private

◆ ParseModule()

Error TraceIntelPTBundleLoader::ParseModule ( Target target,
const JSONModule module 
)
private

◆ ParseProcess()

Expected< TraceIntelPTBundleLoader::ParsedProcess > TraceIntelPTBundleLoader::ParseProcess ( const JSONProcess process)
private

Create the corresponding Threads and Process objects given the JSON process definition.

Parameters
[in]processThe 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().

◆ ParseThread()

ThreadPostMortemTraceSP TraceIntelPTBundleLoader::ParseThread ( Process process,
const JSONThread thread 
)
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().

Member Data Documentation

◆ m_bundle_description

const llvm::json::Value& lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::m_bundle_description
private

Definition at line 123 of file TraceIntelPTBundleLoader.h.

Referenced by Load().

◆ m_bundle_dir

const std::string lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::m_bundle_dir
private

Definition at line 124 of file TraceIntelPTBundleLoader.h.

Referenced by NormalizePath().

◆ m_debugger

Debugger& lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::m_debugger
private

Definition at line 122 of file TraceIntelPTBundleLoader.h.

Referenced by CreateEmptyProcess(), and LoadBundle().


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