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>

Collaboration diagram for lldb_private::trace_intel_pt::TraceIntelPTBundleLoader:
Collaboration graph
[legend]

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. More...
 

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. More...
 
lldb::ThreadPostMortemTraceSP ParseThread (Process &process, const JSONThread &thread)
 Create a post-mortem thread associated with the given process using the definition from thread. More...
 
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. More...
 
llvm::Expected< ParsedProcessParseProcess (const JSONProcess &process)
 Create the corresponding Threads and Process objects given the JSON process definition. More...
 
llvm::Error ParseModule (Target &target, const JSONModule &module)
 Create a module associated with the given target using the definition from module. More...
 
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. More...
 
llvm::Expected< std::vector< ParsedProcess > > LoadBundle (const JSONTraceBundleDescription &bundle_description)
 Create the corresponding Process, Thread and Module objects given this bundle description. More...
 
llvm::Error AugmentThreadsFromContextSwitches (JSONTraceBundleDescription &bundle_description)
 When applicable, augment the list of threads in the trace bundle by inspecting the context switch trace. More...
 
void NormalizeAllPaths (JSONTraceBundleDescription &bundle_description)
 Modifiy the bundle description by normalizing all the paths relative to the session file directory. More...
 

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 36 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 229 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::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.

◆ 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 66 of file TraceIntelPTBundleLoader.cpp.

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

◆ CreateTraceIntelPTInstance()

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

Given a bundle description and a list of fully parsed processes, create an actual Trace instance that "traces" these processes.

Definition at line 277 of file TraceIntelPTBundleLoader.cpp.

◆ GetSchema()

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

Definition at line 152 of file TraceIntelPTBundleLoader.cpp.

References string().

◆ 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 317 of file TraceIntelPTBundleLoader.cpp.

References lldb_private::fromJSON().

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

◆ LoadBundle()

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

Create the corresponding Process, Thread and Module objects given this bundle description.

Definition at line 131 of file TraceIntelPTBundleLoader.cpp.

References lldb_private::trace_intel_pt::JSONTraceBundleDescription::processes.

◆ 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 25 of file TraceIntelPTBundleLoader.cpp.

References lldb_private::FileSpec::IsRelative(), and lldb_private::FileSpec::PrependPathComponent().

◆ ParseModule()

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

◆ ParseProcess()

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

◆ 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 77 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.

Member Data Documentation

◆ m_bundle_description

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

Definition at line 112 of file TraceIntelPTBundleLoader.h.

◆ m_bundle_dir

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

Definition at line 113 of file TraceIntelPTBundleLoader.h.

◆ m_debugger

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

Definition at line 111 of file TraceIntelPTBundleLoader.h.


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