LLDB  mainline
Static Public Member Functions | List of all members
lldb_private::TraceSessionSaver Class Reference

#include <TraceSessionSaver.h>

Static Public Member Functions

static llvm::Error WriteSessionToFile (const llvm::json::Value &trace_session_description, FileSpec directory)
 Save the trace session description JSON object inside the given directory as a file named trace.json. More...
 
static llvm::Expected< JSONTraceSessionBaseBuildProcessesSection (Process &live_process, std::function< llvm::Expected< llvm::Optional< std::vector< uint8_t >>>(lldb::tid_t tid)> raw_trace_fetcher, FileSpec directory)
 Build the processes section of the trace session description file. More...
 
static llvm::Expected< std::vector< JSONThread > > BuildThreadsSection (Process &live_process, std::function< llvm::Expected< llvm::Optional< std::vector< uint8_t >>>(lldb::tid_t tid)> raw_trace_fetcher, FileSpec directory)
 Build the threads sub-section of the trace session description file. More...
 
static llvm::Expected< std::vector< JSONModule > > BuildModulesSection (Process &live_process, FileSpec directory)
 Build modules sub-section of the trace's session. More...
 

Detailed Description

Definition at line 16 of file TraceSessionSaver.h.

Member Function Documentation

◆ BuildModulesSection()

llvm::Expected< std::vector< JSONModule > > TraceSessionSaver::BuildModulesSection ( Process live_process,
FileSpec  directory 
)
static

Build modules sub-section of the trace's session.

The original modules will be copied over to the <directory/modules> folder. Invalid modules are skipped. Copying the modules has the benefit of making these trace session directories self-contained, as the raw traces and modules are part of the output directory and can be sent to another machine, where lldb can load them and replicate exactly the same trace session.

Parameters
[in]live_processThe process being traced.
[in]directoryThe directory where the modules files will be saved when building the modules section. Example: If a module libbar.so exists in the path /usr/lib/foo/libbar.so, then it will be copied to <directory>/modules/usr/lib/foo/libbar.so.
Returns
The modules section or llvm::Error in case of failures.

Definition at line 105 of file TraceSessionSaver.cpp.

References lldb_private::FileSpec::AppendPathComponent(), lldb_private::ConstString::AsCString(), lldb_private::ObjectFile::GetBaseAddress(), lldb_private::FileSpec::GetDirectory(), lldb_private::Target::GetImages(), lldb_private::Address::GetLoadAddress(), lldb_private::ModuleList::GetModuleAtIndex(), lldb_private::FileSpec::GetPath(), lldb_private::Target::GetSectionLoadList(), lldb_private::ModuleList::GetSize(), lldb_private::Process::GetTarget(), lldb_private::SectionLoadList::IsEmpty(), lldb_private::Address::IsValid(), LLDB_INVALID_ADDRESS, and string().

◆ BuildProcessesSection()

llvm::Expected< JSONTraceSessionBase > TraceSessionSaver::BuildProcessesSection ( Process live_process,
std::function< llvm::Expected< llvm::Optional< std::vector< uint8_t >>>(lldb::tid_t tid)>  raw_trace_fetcher,
FileSpec  directory 
)
static

Build the processes section of the trace session description file.

Besides returning the processes information, this method saves to disk all modules and raw traces corresponding to the traced threads of the given process.

Parameters
[in]live_processThe process being traced.
[in]raw_trace_fetcherCallback function that receives a thread ID and returns its raw trace. This callback should return None if the thread is not being traced. Otherwise, it should return the raw trace in bytes or an llvm::Error in case of failures.
[in]directoryThe directory where files will be saved when building the processes section.
Returns
The processes section or llvm::Error in case of failures.

Definition at line 41 of file TraceSessionSaver.cpp.

References lldb_private::Target::GetArchitecture(), lldb_private::Process::GetID(), lldb_private::Process::GetTarget(), lldb_private::ArchSpec::GetTriple(), and lldb_private::JSONTraceSessionBase::processes.

◆ BuildThreadsSection()

llvm::Expected< std::vector< JSONThread > > TraceSessionSaver::BuildThreadsSection ( Process live_process,
std::function< llvm::Expected< llvm::Optional< std::vector< uint8_t >>>(lldb::tid_t tid)>  raw_trace_fetcher,
FileSpec  directory 
)
static

Build the threads sub-section of the trace session description file.

For each traced thread, its raw trace is also written to the file thread_id_.trace inside of the given directory.

Parameters
[in]live_processThe process being traced.
[in]raw_trace_fetcherCallback function that receives a thread ID and returns its raw trace. This callback should return None if the thread is not being traced. Otherwise, it should return the raw trace in bytes or an llvm::Error in case of failures.
[in]directoryThe directory where files will be saved when building the threads section.
Returns
The threads section or llvm::Error in case of failures.

Definition at line 66 of file TraceSessionSaver.cpp.

References lldb_private::FileSpec::AppendPathComponent(), lldb_private::FileSpec::GetPath(), and lldb_private::Process::Threads().

◆ WriteSessionToFile()

llvm::Error TraceSessionSaver::WriteSessionToFile ( const llvm::json::Value &  trace_session_description,
FileSpec  directory 
)
static

Save the trace session description JSON object inside the given directory as a file named trace.json.

Parameters
[in]trace_session_descriptionThe trace's session, as JSON Object.
[in]directoryThe directory where the JSON file will be saved.
Returns
llvm::success if the operation was successful, or an llvm::Error otherwise.

Definition at line 26 of file TraceSessionSaver.cpp.

References lldb_private::FileSpec::AppendPathComponent(), lldb_private::FileSpec::GetPath(), and string().


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