[Reproducers] Capture return values of functions returning by ptr/ref

For some reason I had convinced myself that functions returning by
pointer or reference do not require recording their result. However,
after further considering I don't see how that could work, at least not
with the current implementation. Interestingly enough, the reproducer
instrumentation already (mostly) accounts for this, though the
lldb-instr tool did not.

This patch adds the missing macros and updates the lldb-instr tool.

Differential revision: https://reviews.llvm.org/D60178

llvm-svn: 357639
This commit is contained in:
Jonas Devlieghere 2019-04-03 21:31:22 +00:00
parent 7c711ccf36
commit 306809f292
64 changed files with 203 additions and 93 deletions

View File

@ -185,7 +185,7 @@ template <typename... Ts> inline std::string log_args(const Ts &... ts) {
} }
#define LLDB_RECORD_RESULT(Result) \ #define LLDB_RECORD_RESULT(Result) \
sb_recorder ? sb_recorder->RecordResult(Result) : Result; sb_recorder ? sb_recorder->RecordResult(Result) : (Result);
/// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record /// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record
/// anything. It's used to track API boundaries when we cannot record for /// anything. It's used to track API boundaries when we cannot record for
@ -643,13 +643,7 @@ public:
return; return;
unsigned id = m_registry.GetID(uintptr_t(f)); unsigned id = m_registry.GetID(uintptr_t(f));
Log(id);
#ifndef LLDB_REPRO_INSTR_TRACE
LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "Recording {0}: {1}",
id, m_pretty_func);
#else
llvm::errs() << "Recording " << id << ": " << m_pretty_func << "\n";
#endif
m_serializer.SerializeAll(id); m_serializer.SerializeAll(id);
m_serializer.SerializeAll(args...); m_serializer.SerializeAll(args...);
@ -670,13 +664,7 @@ public:
return; return;
unsigned id = m_registry.GetID(uintptr_t(f)); unsigned id = m_registry.GetID(uintptr_t(f));
Log(id);
#ifndef LLDB_REPRO_INSTR_TRACE
LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "Recording {0}: {1}",
id, m_pretty_func);
#else
llvm::errs() << "Recording " << id << ": " << m_pretty_func << "\n";
#endif
m_serializer.SerializeAll(id); m_serializer.SerializeAll(id);
m_serializer.SerializeAll(args...); m_serializer.SerializeAll(args...);
@ -687,14 +675,14 @@ public:
} }
/// Record the result of a function call. /// Record the result of a function call.
template <typename Result> Result RecordResult(const Result &r) { template <typename Result> Result RecordResult(Result &&r) {
UpdateBoundary(); UpdateBoundary();
if (ShouldCapture()) { if (ShouldCapture()) {
assert(!m_result_recorded); assert(!m_result_recorded);
m_serializer.SerializeAll(r); m_serializer.SerializeAll(r);
m_result_recorded = true; m_result_recorded = true;
} }
return r; return std::forward<Result>(r);
} }
private: private:
@ -704,6 +692,7 @@ private:
} }
bool ShouldCapture() { return m_local_boundary; } bool ShouldCapture() { return m_local_boundary; }
void Log(unsigned id);
Serializer &m_serializer; Serializer &m_serializer;
Registry &m_registry; Registry &m_registry;

View File

@ -16,3 +16,11 @@ Foo Foo::H() { return Foo(); }
void Foo::I() const { MACRO_FOO; } void Foo::I() const { MACRO_FOO; }
Bar Foo::J() const { return MACRO_BAR(Bar()); } Bar Foo::J() const { return MACRO_BAR(Bar()); }
Bar Foo::K(void *v) const { return Bar(); } Bar Foo::K(void *v) const { return Bar(); }
Bar &Foo::L() const {
Bar *b = new Bar();
return *b;
};
Bar *Foo::M() const {
Bar *b = new Bar();
return b;
};

View File

@ -14,4 +14,6 @@ struct Foo {
void I() const; void I() const;
Bar J() const; Bar J() const;
Bar K(void *v) const; Bar K(void *v) const;
Bar &L() const;
Bar *M() const;
}; };

View File

@ -20,3 +20,5 @@
# CHECK-NOT: LLDB_RECORD_RESULT(Bar()); # CHECK-NOT: LLDB_RECORD_RESULT(Bar());
# CHECK: LLDB_RECORD_DUMMY(Bar, Foo, K, (void *), v); # CHECK: LLDB_RECORD_DUMMY(Bar, Foo, K, (void *), v);
# CHECK-NOT: LLDB_RECORD_RESULT(Bar()); # CHECK-NOT: LLDB_RECORD_RESULT(Bar());
# CHECK: LLDB_RECORD_RESULT(*b)
# CHECK: LLDB_RECORD_RESULT(b)

View File

@ -11,6 +11,9 @@
# CHECK: LLDB_REGISTER_METHOD_CONST(int, Foo, D, (bool)); # CHECK: LLDB_REGISTER_METHOD_CONST(int, Foo, D, (bool));
# CHECK: LLDB_REGISTER_STATIC_METHOD(void, Foo, E, ()); # CHECK: LLDB_REGISTER_STATIC_METHOD(void, Foo, E, ());
# CHECK: LLDB_REGISTER_STATIC_METHOD(int, Foo, F, (int)); # CHECK: LLDB_REGISTER_STATIC_METHOD(int, Foo, F, (int));
# CHECK: LLDB_REGISTER_METHOD_CONST(Bar, Foo, J, ());
# CHECK: LLDB_REGISTER_METHOD_CONST(Bar &, Foo, L, ());
# CHECK: LLDB_REGISTER_METHOD_CONST(Bar *, Foo, M, ());
# CHECK-NOT: LLDB_REGISTER_STATIC_METHOD(void, Foo, G # CHECK-NOT: LLDB_REGISTER_STATIC_METHOD(void, Foo, G
# CHECK-NOT: LLDB_REGISTER_METHOD_CONST(void, Foo, I, ()); # CHECK-NOT: LLDB_REGISTER_METHOD_CONST(void, Foo, I, ());
# CHECK-NOT: LLDB_REGISTER_METHOD_CONST(Bar, Foo, K, (void*)); # CHECK-NOT: LLDB_REGISTER_METHOD_CONST(Bar, Foo, K, (void*));

View File

@ -60,7 +60,7 @@ const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {

View File

@ -64,7 +64,7 @@ SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = clone(rhs.m_opaque_sp); m_opaque_sp = clone(rhs.m_opaque_sp);
return *this; return LLDB_RECORD_RESULT(*this);
} }
lldb::pid_t SBAttachInfo::GetProcessID() { lldb::pid_t SBAttachInfo::GetProcessID() {

View File

@ -41,7 +41,7 @@ const SBBlock &SBBlock::operator=(const SBBlock &rhs) {
SBBlock, operator=,(const lldb::SBBlock &), rhs); SBBlock, operator=,(const lldb::SBBlock &), rhs);
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBBlock::~SBBlock() { m_opaque_ptr = NULL; } SBBlock::~SBBlock() { m_opaque_ptr = NULL; }

View File

@ -62,7 +62,7 @@ const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs); SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs);
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) { bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {

View File

@ -54,7 +54,7 @@ operator=(const SBBreakpointLocation &rhs) {
rhs); rhs);
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBBreakpointLocation::~SBBreakpointLocation() {} SBBreakpointLocation::~SBBreakpointLocation() {}

View File

@ -166,12 +166,12 @@ operator=(const SBBreakpointName &rhs) {
if (!rhs.m_impl_up) { if (!rhs.m_impl_up) {
m_impl_up.reset(); m_impl_up.reset();
return *this; return LLDB_RECORD_RESULT(*this);
} }
m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
rhs.m_impl_up->GetName())); rhs.m_impl_up->GetName()));
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) {

View File

@ -45,7 +45,7 @@ const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBBroadcaster::~SBBroadcaster() { reset(NULL, false); } SBBroadcaster::~SBBroadcaster() { reset(NULL, false); }

View File

@ -196,7 +196,7 @@ operator=(const SBCommandInterpreter &rhs) {
rhs); rhs);
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBCommandInterpreter::IsValid() const { bool SBCommandInterpreter::IsValid() const {

View File

@ -43,7 +43,7 @@ CommandReturnObject *SBCommandReturnObject::Release() {
LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *, LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *,
SBCommandReturnObject, Release); SBCommandReturnObject, Release);
return m_opaque_up.release(); return LLDB_RECORD_RESULT(m_opaque_up.release());
} }
const SBCommandReturnObject &SBCommandReturnObject:: const SBCommandReturnObject &SBCommandReturnObject::
@ -55,7 +55,7 @@ operator=(const SBCommandReturnObject &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBCommandReturnObject::IsValid() const { bool SBCommandReturnObject::IsValid() const {

View File

@ -38,7 +38,7 @@ const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) {
rhs); rhs);
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; } SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; }

View File

@ -38,7 +38,7 @@ const SBData &SBData::operator=(const SBData &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBData::~SBData() {} SBData::~SBData() {}

View File

@ -182,7 +182,7 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBDebugger::Initialize() { void SBDebugger::Initialize() {
@ -373,7 +373,7 @@ FILE *SBDebugger::GetInputFileHandle() {
if (m_opaque_sp) { if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile()); StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile());
if (stream_file_sp) if (stream_file_sp)
return stream_file_sp->GetFile().GetStream(); return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
} }
return nullptr; return nullptr;
} }
@ -384,7 +384,7 @@ FILE *SBDebugger::GetOutputFileHandle() {
if (m_opaque_sp) { if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile()); StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile());
if (stream_file_sp) if (stream_file_sp)
return stream_file_sp->GetFile().GetStream(); return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
} }
return nullptr; return nullptr;
} }
@ -395,7 +395,7 @@ FILE *SBDebugger::GetErrorFileHandle() {
if (m_opaque_sp) { if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile());
if (stream_file_sp) if (stream_file_sp)
return stream_file_sp->GetFile().GetStream(); return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
} }
return nullptr; return nullptr;
} }

View File

@ -42,7 +42,7 @@ const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBDeclaration::SetDeclaration( void SBDeclaration::SetDeclaration(

View File

@ -33,7 +33,7 @@ const SBError &SBError::operator=(const SBError &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
const char *SBError::GetCString() const { const char *SBError::GetCString() const {

View File

@ -55,7 +55,7 @@ const SBEvent &SBEvent::operator=(const SBEvent &rhs) {
m_event_sp = rhs.m_event_sp; m_event_sp = rhs.m_event_sp;
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBEvent::~SBEvent() {} SBEvent::~SBEvent() {}

View File

@ -75,7 +75,7 @@ operator=(const lldb::SBExecutionContext &rhs) {
SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs); SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs);
m_exe_ctx_sp = rhs.m_exe_ctx_sp; m_exe_ctx_sp = rhs.m_exe_ctx_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
ExecutionContextRef *SBExecutionContext::get() const { ExecutionContextRef *SBExecutionContext::get() const {

View File

@ -37,7 +37,7 @@ operator=(const SBExpressionOptions &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBExpressionOptions::~SBExpressionOptions() {} SBExpressionOptions::~SBExpressionOptions() {}

View File

@ -59,7 +59,7 @@ const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBFileSpec::operator==(const SBFileSpec &rhs) const { bool SBFileSpec::operator==(const SBFileSpec &rhs) const {

View File

@ -41,7 +41,7 @@ const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
uint32_t SBFileSpecList::GetSize() const { uint32_t SBFileSpecList::GetSize() const {

View File

@ -78,7 +78,7 @@ const SBFrame &SBFrame::operator=(const SBFrame &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = clone(rhs.m_opaque_sp); m_opaque_sp = clone(rhs.m_opaque_sp);
return *this; return LLDB_RECORD_RESULT(*this);
} }
StackFrameSP SBFrame::GetFrameSP() const { StackFrameSP SBFrame::GetFrameSP() const {

View File

@ -39,7 +39,7 @@ const SBFunction &SBFunction::operator=(const SBFunction &rhs) {
SBFunction, operator=,(const lldb::SBFunction &), rhs); SBFunction, operator=,(const lldb::SBFunction &), rhs);
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBFunction::~SBFunction() { m_opaque_ptr = NULL; } SBFunction::~SBFunction() { m_opaque_ptr = NULL; }

View File

@ -87,7 +87,7 @@ const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBInstruction::~SBInstruction() {} SBInstruction::~SBInstruction() {}

View File

@ -37,7 +37,7 @@ operator=(const SBInstructionList &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBInstructionList::~SBInstructionList() {} SBInstructionList::~SBInstructionList() {}

View File

@ -41,7 +41,7 @@ const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) {

View File

@ -42,7 +42,7 @@ const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
m_unused_ptr = nullptr; m_unused_ptr = nullptr;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBListener::SBListener(const lldb::ListenerSP &listener_sp) SBListener::SBListener(const lldb::ListenerSP &listener_sp)

View File

@ -43,7 +43,7 @@ operator=(const SBMemoryRegionInfo &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBMemoryRegionInfo::~SBMemoryRegionInfo() {} SBMemoryRegionInfo::~SBMemoryRegionInfo() {}

View File

@ -94,7 +94,7 @@ operator=(const SBMemoryRegionInfoList &rhs) {
if (this != &rhs) { if (this != &rhs) {
*m_opaque_up = *rhs.m_opaque_up; *m_opaque_up = *rhs.m_opaque_up;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
uint32_t SBMemoryRegionInfoList::GetSize() const { uint32_t SBMemoryRegionInfoList::GetSize() const {

View File

@ -73,7 +73,7 @@ const SBModule &SBModule::operator=(const SBModule &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBModule::~SBModule() {} SBModule::~SBModule() {}

View File

@ -35,7 +35,7 @@ const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBModuleSpec::~SBModuleSpec() {} SBModuleSpec::~SBModuleSpec() {}
@ -166,7 +166,7 @@ SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
if (this != &rhs) if (this != &rhs)
*m_opaque_up = *rhs.m_opaque_up; *m_opaque_up = *rhs.m_opaque_up;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBModuleSpecList::~SBModuleSpecList() {} SBModuleSpecList::~SBModuleSpecList() {}

View File

@ -72,7 +72,7 @@ const SBProcess &SBProcess::operator=(const SBProcess &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -34,7 +34,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
ProcessInstanceInfo &SBProcessInfo::ref() { ProcessInstanceInfo &SBProcessInfo::ref() {

View File

@ -240,7 +240,7 @@ const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) {
SBQueue, operator=,(const lldb::SBQueue &), rhs); SBQueue, operator=,(const lldb::SBQueue &), rhs);
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBQueue::~SBQueue() {} SBQueue::~SBQueue() {}

View File

@ -41,7 +41,7 @@ const SBSection &SBSection::operator=(const SBSection &rhs) {
SBSection, operator=,(const lldb::SBSection &), rhs); SBSection, operator=,(const lldb::SBSection &), rhs);
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBSection::~SBSection() {} SBSection::~SBSection() {}

View File

@ -101,7 +101,7 @@ operator=(const lldb::SBSourceManager &rhs) {
rhs); rhs);
m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBSourceManager::~SBSourceManager() {} SBSourceManager::~SBSourceManager() {}

View File

@ -36,7 +36,7 @@ const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBStringList::~SBStringList() {} SBStringList::~SBStringList() {}

View File

@ -54,7 +54,7 @@ operator=(const lldb::SBStructuredData &rhs) {
SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs); SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs);
*m_impl_up = *rhs.m_impl_up; *m_impl_up = *rhs.m_impl_up;
return *this; return LLDB_RECORD_RESULT(*this);
} }
lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) {

View File

@ -34,7 +34,7 @@ const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) {
SBSymbol, operator=,(const lldb::SBSymbol &), rhs); SBSymbol, operator=,(const lldb::SBSymbol &), rhs);
m_opaque_ptr = rhs.m_opaque_ptr; m_opaque_ptr = rhs.m_opaque_ptr;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; } SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; }

View File

@ -46,7 +46,7 @@ const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) { void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) {

View File

@ -38,7 +38,7 @@ operator=(const SBSymbolContextList &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up); m_opaque_up = clone(rhs.m_opaque_up);
return *this; return LLDB_RECORD_RESULT(*this);
} }
uint32_t SBSymbolContextList::GetSize() const { uint32_t SBSymbolContextList::GetSize() const {

View File

@ -118,7 +118,7 @@ const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -84,7 +84,7 @@ const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = clone(rhs.m_opaque_sp); m_opaque_sp = clone(rhs.m_opaque_sp);
return *this; return LLDB_RECORD_RESULT(*this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1402,9 +1402,8 @@ lldb_private::Thread *SBThread::operator->() {
ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp) if (thread_sp)
return thread_sp.get(); return LLDB_RECORD_RESULT(thread_sp.get());
else return nullptr;
return NULL;
} }
lldb_private::Thread *SBThread::get() { lldb_private::Thread *SBThread::get() {
@ -1412,9 +1411,8 @@ lldb_private::Thread *SBThread::get() {
ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp) if (thread_sp)
return thread_sp.get(); return LLDB_RECORD_RESULT(thread_sp.get());
else return nullptr;
return NULL;
} }
namespace lldb_private { namespace lldb_private {

View File

@ -32,7 +32,7 @@ operator=(const SBThreadCollection &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)

View File

@ -82,7 +82,7 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Destructor // Destructor
@ -92,7 +92,7 @@ SBThreadPlan::~SBThreadPlan() {}
lldb_private::ThreadPlan *SBThreadPlan::get() { lldb_private::ThreadPlan *SBThreadPlan::get() {
LLDB_RECORD_METHOD_NO_ARGS(lldb_private::ThreadPlan *, SBThreadPlan, get); LLDB_RECORD_METHOD_NO_ARGS(lldb_private::ThreadPlan *, SBThreadPlan, get);
return m_opaque_sp.get(); return LLDB_RECORD_RESULT(m_opaque_sp.get());
} }
bool SBThreadPlan::IsValid() const { bool SBThreadPlan::IsValid() const {

View File

@ -86,7 +86,7 @@ SBType &SBType::operator=(const SBType &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBType::~SBType() {} SBType::~SBType() {}
@ -592,7 +592,7 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) {
i < rhs_size; i++) i < rhs_size; i++)
Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBTypeList::Append(SBType type) { void SBTypeList::Append(SBType type) {
@ -642,7 +642,7 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) {
if (rhs.IsValid()) if (rhs.IsValid())
m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeMember::IsValid() const { bool SBTypeMember::IsValid() const {
@ -771,7 +771,7 @@ operator=(const lldb::SBTypeMemberFunction &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeMemberFunction::IsValid() const { bool SBTypeMemberFunction::IsValid() const {

View File

@ -616,7 +616,7 @@ operator=(const lldb::SBTypeCategory &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) {

View File

@ -40,12 +40,13 @@ SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs)
} }
SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) { SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) {
LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &), LLDB_RECORD_METHOD(
rhs); SBTypeEnumMember &,
SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs);
if (this != &rhs) if (this != &rhs)
m_opaque_sp = clone(rhs.m_opaque_sp); m_opaque_sp = clone(rhs.m_opaque_sp);
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeEnumMember::IsValid() const { bool SBTypeEnumMember::IsValid() const {
@ -147,7 +148,7 @@ operator=(const SBTypeEnumMemberList &rhs) {
Append( Append(
const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i)); const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) {

View File

@ -126,7 +126,7 @@ lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) {

View File

@ -121,7 +121,7 @@ lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) {

View File

@ -108,7 +108,7 @@ operator=(const lldb::SBTypeNameSpecifier &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) {

View File

@ -345,7 +345,7 @@ lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) {

View File

@ -143,7 +143,7 @@ operator=(const lldb::SBTypeSynthetic &rhs) {
if (this != &rhs) { if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp; m_opaque_sp = rhs.m_opaque_sp;
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) {

View File

@ -40,7 +40,7 @@ const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
if (this != &rhs) if (this != &rhs)
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBUnixSignals::~SBUnixSignals() {} SBUnixSignals::~SBUnixSignals() {}

View File

@ -236,7 +236,7 @@ SBValue &SBValue::operator=(const SBValue &rhs) {
if (this != &rhs) { if (this != &rhs) {
SetSP(rhs.m_opaque_sp); SetSP(rhs.m_opaque_sp);
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBValue::~SBValue() {} SBValue::~SBValue() {}

View File

@ -111,7 +111,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
else else
m_opaque_up.reset(); m_opaque_up.reset();
} }
return *this; return LLDB_RECORD_RESULT(*this);
} }
ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); } ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); }

View File

@ -99,7 +99,7 @@ operator=(const SBVariablesOptions &options) {
options); options);
m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); m_opaque_up.reset(new VariablesOptionsImpl(options.ref()));
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBVariablesOptions::~SBVariablesOptions() = default; SBVariablesOptions::~SBVariablesOptions() = default;

View File

@ -43,7 +43,7 @@ const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs); SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs);
m_opaque_wp = rhs.m_opaque_wp; m_opaque_wp = rhs.m_opaque_wp;
return *this; return LLDB_RECORD_RESULT(*this);
} }
SBWatchpoint::~SBWatchpoint() {} SBWatchpoint::~SBWatchpoint() {}

View File

@ -117,4 +117,13 @@ Recorder::~Recorder() {
UpdateBoundary(); UpdateBoundary();
} }
void Recorder::Log(unsigned id) {
#ifndef LLDB_REPRO_INSTR_TRACE
LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "Recording {0}: {1}", id,
m_pretty_func);
#else
llvm::errs() << "Recording " << id << ": " << m_pretty_func << "\n";
#endif
}
bool lldb_private::repro::Recorder::g_global_boundary; bool lldb_private::repro::Recorder::g_global_boundary;

View File

@ -245,7 +245,9 @@ public:
// If the function returns a class or struct, we need to wrap its return // If the function returns a class or struct, we need to wrap its return
// statement(s). // statement(s).
if (!ShouldInsertDummy && ReturnType->isStructureOrClassType()) { bool ShouldRecordResult = ReturnType->isStructureOrClassType() ||
ReturnType->getPointeeCXXRecordDecl();
if (!ShouldInsertDummy && ShouldRecordResult) {
SBReturnVisitor Visitor(MyRewriter); SBReturnVisitor Visitor(MyRewriter);
Visitor.TraverseDecl(Decl); Visitor.TraverseDecl(Decl);
} }

View File

@ -89,6 +89,8 @@ public:
/// { /// {
InstrumentedBar(); InstrumentedBar();
InstrumentedFoo GetInstrumentedFoo(); InstrumentedFoo GetInstrumentedFoo();
InstrumentedFoo &GetInstrumentedFooRef();
InstrumentedFoo *GetInstrumentedFooPtr();
void SetInstrumentedFoo(InstrumentedFoo *foo); void SetInstrumentedFoo(InstrumentedFoo *foo);
void SetInstrumentedFoo(InstrumentedFoo &foo); void SetInstrumentedFoo(InstrumentedFoo &foo);
void Validate(); void Validate();
@ -201,6 +203,22 @@ InstrumentedFoo InstrumentedBar::GetInstrumentedFoo() {
return LLDB_RECORD_RESULT(InstrumentedFoo(0)); return LLDB_RECORD_RESULT(InstrumentedFoo(0));
} }
InstrumentedFoo &InstrumentedBar::GetInstrumentedFooRef() {
LLDB_RECORD_METHOD_NO_ARGS(InstrumentedFoo &, InstrumentedBar,
GetInstrumentedFooRef);
InstrumentedFoo *foo = new InstrumentedFoo(0);
m_get_instrumend_foo_called = true;
return LLDB_RECORD_RESULT(*foo);
}
InstrumentedFoo *InstrumentedBar::GetInstrumentedFooPtr() {
LLDB_RECORD_METHOD_NO_ARGS(InstrumentedFoo *, InstrumentedBar,
GetInstrumentedFooPtr);
InstrumentedFoo *foo = new InstrumentedFoo(0);
m_get_instrumend_foo_called = true;
return LLDB_RECORD_RESULT(foo);
}
void InstrumentedBar::SetInstrumentedFoo(InstrumentedFoo *foo) { void InstrumentedBar::SetInstrumentedFoo(InstrumentedFoo *foo) {
LLDB_RECORD_METHOD(void, InstrumentedBar, SetInstrumentedFoo, LLDB_RECORD_METHOD(void, InstrumentedBar, SetInstrumentedFoo,
(InstrumentedFoo *), foo); (InstrumentedFoo *), foo);
@ -239,6 +257,10 @@ TestingRegistry::TestingRegistry() {
LLDB_REGISTER_CONSTRUCTOR(InstrumentedBar, ()); LLDB_REGISTER_CONSTRUCTOR(InstrumentedBar, ());
LLDB_REGISTER_METHOD(InstrumentedFoo, InstrumentedBar, GetInstrumentedFoo, LLDB_REGISTER_METHOD(InstrumentedFoo, InstrumentedBar, GetInstrumentedFoo,
()); ());
LLDB_REGISTER_METHOD(InstrumentedFoo &, InstrumentedBar,
GetInstrumentedFooRef, ());
LLDB_REGISTER_METHOD(InstrumentedFoo *, InstrumentedBar,
GetInstrumentedFooPtr, ());
LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo, LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo,
(InstrumentedFoo *)); (InstrumentedFoo *));
LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo, LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo,
@ -487,6 +509,80 @@ TEST(RecordReplayTest, InstrumentedBar) {
{ {
InstrumentedBar bar; InstrumentedBar bar;
InstrumentedFoo foo = bar.GetInstrumentedFoo(); InstrumentedFoo foo = bar.GetInstrumentedFoo();
#if 0
InstrumentedFoo& foo_ref = bar.GetInstrumentedFooRef();
InstrumentedFoo* foo_ptr = bar.GetInstrumentedFooPtr();
#endif
int b = 200;
float c = 300.3;
double e = 400.4;
foo.A(100);
foo.B(b);
foo.C(&c);
foo.D("bar");
InstrumentedFoo::E(e);
InstrumentedFoo::F();
foo.Validate();
bar.SetInstrumentedFoo(foo);
bar.SetInstrumentedFoo(&foo);
bar.Validate();
}
ClearObjects();
TestingRegistry registry;
registry.Replay(os.str());
ValidateObjects(1, 1);
}
TEST(RecordReplayTest, InstrumentedBarRef) {
std::string str;
llvm::raw_string_ostream os(str);
g_registry.emplace();
g_serializer.emplace(os);
{
InstrumentedBar bar;
InstrumentedFoo &foo = bar.GetInstrumentedFooRef();
int b = 200;
float c = 300.3;
double e = 400.4;
foo.A(100);
foo.B(b);
foo.C(&c);
foo.D("bar");
InstrumentedFoo::E(e);
InstrumentedFoo::F();
foo.Validate();
bar.SetInstrumentedFoo(foo);
bar.SetInstrumentedFoo(&foo);
bar.Validate();
}
ClearObjects();
TestingRegistry registry;
registry.Replay(os.str());
ValidateObjects(1, 1);
}
TEST(RecordReplayTest, InstrumentedBarPtr) {
std::string str;
llvm::raw_string_ostream os(str);
g_registry.emplace();
g_serializer.emplace(os);
{
InstrumentedBar bar;
InstrumentedFoo &foo = *(bar.GetInstrumentedFooPtr());
int b = 200; int b = 200;
float c = 300.3; float c = 300.3;