LLDB  mainline
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
lldb_private::repro::Recorder Class Reference

RAII object that records function invocations and their return value. More...

#include <ReproducerInstrumentation.h>

Collaboration diagram for lldb_private::repro::Recorder:
Collaboration graph
[legend]

Public Member Functions

 Recorder ()
 
 Recorder (llvm::StringRef pretty_func, std::string &&pretty_args={})
 
 ~Recorder ()
 
template<typename Result , typename... FArgs, typename... RArgs>
void Record (Serializer &serializer, Registry &registry, Result(*f)(FArgs...), const RArgs &... args)
 Records a single function call. More...
 
template<typename... Args>
void Record (Serializer &serializer, Registry &registry, void(*f)(Args...), const Args &... args)
 Records a single function call. More...
 
template<typename Result >
void Record (Serializer &serializer, Registry &registry, Result(*f)(), const EmptyArg &arg)
 Specializations for the no-argument methods. More...
 
template<typename Result >
Result RecordResult (Result &&r, bool update_boundary)
 Record the result of a function call. More...
 
template<typename Result , typename T >
Result Replay (Deserializer &deserializer, Registry &registry, uintptr_t addr, bool update_boundary)
 
void Replay (Deserializer &deserializer, Registry &registry, uintptr_t addr)
 
template<typename Result >
Result ReplayResult (Result &&r, bool update_boundary)
 
bool ShouldCapture ()
 

Static Public Member Functions

static void PrivateThread ()
 Mark the current thread as a private thread and pretend that everything on this thread is behind happening behind the API boundary. More...
 

Private Member Functions

unsigned GetSequenceNumber () const
 
void UpdateBoundary ()
 

Static Private Member Functions

static unsigned GetNextSequenceNumber ()
 

Private Attributes

Serializerm_serializer = nullptr
 
llvm::StringRef m_pretty_func
 Pretty function for logging. More...
 
std::string m_pretty_args
 
bool m_local_boundary = false
 Whether this function call was the one crossing the API boundary. More...
 
bool m_result_recorded = true
 Whether the return value was recorded explicitly. More...
 
unsigned m_sequence
 The sequence number for this pair of function and result. More...
 

Static Private Attributes

static std::mutex g_mutex
 Global mutex to protect concurrent access. More...
 
static std::atomic< unsigned > g_sequence
 Unique, monotonically increasing sequence number. More...
 

Friends

template<typename T >
struct replay
 

Detailed Description

RAII object that records function invocations and their return value.

API calls are only captured when the API boundary is crossed. Once we're in the API layer, and another API function is called, it doesn't need to be recorded.

When a call is recored, its result is always recorded as well, even if the function returns a void. For functions that return by value, RecordResult should be used. Otherwise a sentinel value (0) will be serialized.

Because of the functional overlap between logging and recording API calls, this class is also used for logging.

Definition at line 747 of file ReproducerInstrumentation.h.

Constructor & Destructor Documentation

◆ Recorder() [1/2]

Recorder::Recorder ( )

◆ Recorder() [2/2]

Recorder::Recorder ( llvm::StringRef  pretty_func,
std::string &&  pretty_args = {} 
)

◆ ~Recorder()

Recorder::~Recorder ( )

Definition at line 223 of file ReproducerInstrumentation.cpp.

References m_result_recorded, and UpdateBoundary().

Member Function Documentation

◆ GetNextSequenceNumber()

static unsigned lldb_private::repro::Recorder::GetNextSequenceNumber ( )
inlinestaticprivate

Definition at line 874 of file ReproducerInstrumentation.h.

References g_sequence.

Referenced by Recorder().

◆ GetSequenceNumber()

unsigned Recorder::GetSequenceNumber ( ) const
private

Definition at line 228 of file ReproducerInstrumentation.cpp.

References m_sequence.

Referenced by Record(), and RecordResult().

◆ PrivateThread()

void Recorder::PrivateThread ( )
static

Mark the current thread as a private thread and pretend that everything on this thread is behind happening behind the API boundary.

Definition at line 233 of file ReproducerInstrumentation.cpp.

References g_global_boundary.

◆ Record() [1/3]

template<typename Result >
void lldb_private::repro::Recorder::Record ( Serializer serializer,
Registry registry,
Result(*)()  f,
const EmptyArg arg 
)
inline

Specializations for the no-argument methods.

These are passed an empty dummy argument so the same variadic macro can be used. These methods strip the arguments before forwarding them.

Definition at line 813 of file ReproducerInstrumentation.h.

References Record().

◆ Record() [2/3]

template<typename Result , typename... FArgs, typename... RArgs>
void lldb_private::repro::Recorder::Record ( Serializer serializer,
Registry registry,
Result(*)(FArgs...)  f,
const RArgs &...  args 
)
inline

◆ Record() [3/3]

template<typename... Args>
void lldb_private::repro::Recorder::Record ( Serializer serializer,
Registry registry,
void(*)(Args...)  f,
const Args &...  args 
)
inline

◆ RecordResult()

template<typename Result >
Result lldb_private::repro::Recorder::RecordResult ( Result &&  r,
bool  update_boundary 
)
inline

◆ Replay() [1/2]

void lldb_private::repro::Recorder::Replay ( Deserializer deserializer,
Registry registry,
uintptr_t  addr 
)
inline

◆ Replay() [2/2]

template<typename Result , typename T >
Result lldb_private::repro::Recorder::Replay ( Deserializer deserializer,
Registry registry,
uintptr_t  addr,
bool  update_boundary 
)
inline

◆ ReplayResult()

template<typename Result >
Result lldb_private::repro::Recorder::ReplayResult ( Result &&  r,
bool  update_boundary 
)
inline

◆ ShouldCapture()

bool lldb_private::repro::Recorder::ShouldCapture ( )
inline

◆ UpdateBoundary()

void Recorder::UpdateBoundary ( )
private

Definition at line 235 of file ReproducerInstrumentation.cpp.

References g_global_boundary, and m_local_boundary.

Referenced by RecordResult(), ReplayResult(), and ~Recorder().

Friends And Related Function Documentation

◆ replay

template<typename T >
friend struct replay
friend

Definition at line 877 of file ReproducerInstrumentation.h.

Member Data Documentation

◆ g_mutex

std::mutex lldb_private::repro::Recorder::g_mutex
staticprivate

Global mutex to protect concurrent access.

Definition at line 903 of file ReproducerInstrumentation.h.

Referenced by Record(), and RecordResult().

◆ g_sequence

std::atomic< unsigned > lldb_private::repro::Recorder::g_sequence
staticprivate

Unique, monotonically increasing sequence number.

Definition at line 906 of file ReproducerInstrumentation.h.

Referenced by GetNextSequenceNumber().

◆ m_local_boundary

bool lldb_private::repro::Recorder::m_local_boundary = false
private

Whether this function call was the one crossing the API boundary.

Definition at line 894 of file ReproducerInstrumentation.h.

Referenced by Recorder(), ShouldCapture(), and UpdateBoundary().

◆ m_pretty_args

std::string lldb_private::repro::Recorder::m_pretty_args
private

Definition at line 891 of file ReproducerInstrumentation.h.

Referenced by Recorder().

◆ m_pretty_func

llvm::StringRef lldb_private::repro::Recorder::m_pretty_func
private

Pretty function for logging.

Definition at line 890 of file ReproducerInstrumentation.h.

Referenced by Recorder().

◆ m_result_recorded

bool lldb_private::repro::Recorder::m_result_recorded = true
private

Whether the return value was recorded explicitly.

Definition at line 897 of file ReproducerInstrumentation.h.

Referenced by Record(), RecordResult(), and ~Recorder().

◆ m_sequence

unsigned lldb_private::repro::Recorder::m_sequence
private

The sequence number for this pair of function and result.

Definition at line 900 of file ReproducerInstrumentation.h.

Referenced by GetSequenceNumber(), and Recorder().

◆ m_serializer

Serializer* lldb_private::repro::Recorder::m_serializer = nullptr
private

Definition at line 887 of file ReproducerInstrumentation.h.

Referenced by Record(), and RecordResult().


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