Index: lldb/include/lldb/Utility/ReproducerInstrumentation.h =================================================================== --- lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -185,7 +185,7 @@ } #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 /// anything. It's used to track API boundaries when we cannot record for @@ -643,13 +643,7 @@ return; unsigned id = m_registry.GetID(uintptr_t(f)); - -#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 + Log(id); m_serializer.SerializeAll(id); m_serializer.SerializeAll(args...); @@ -670,13 +664,7 @@ return; unsigned id = m_registry.GetID(uintptr_t(f)); - -#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 + Log(id); m_serializer.SerializeAll(id); m_serializer.SerializeAll(args...); @@ -687,7 +675,37 @@ } /// Record the result of a function call. - template Result RecordResult(const Result &r) { + template const Result &RecordResult(const Result &r) { + UpdateBoundary(); + if (ShouldCapture()) { + assert(!m_result_recorded); + m_serializer.SerializeAll(r); + m_result_recorded = true; + } + return r; + } + + template Result &RecordResult(Result &r) { + UpdateBoundary(); + if (ShouldCapture()) { + assert(!m_result_recorded); + m_serializer.SerializeAll(r); + m_result_recorded = true; + } + return r; + } + + template const Result *RecordResult(const Result *r) { + UpdateBoundary(); + if (ShouldCapture()) { + assert(!m_result_recorded); + m_serializer.SerializeAll(r); + m_result_recorded = true; + } + return r; + } + + template Result *RecordResult(Result *r) { UpdateBoundary(); if (ShouldCapture()) { assert(!m_result_recorded); @@ -704,6 +722,7 @@ } bool ShouldCapture() { return m_local_boundary; } + void Log(unsigned id); Serializer &m_serializer; Registry &m_registry; Index: lldb/source/API/SBAddress.cpp =================================================================== --- lldb/source/API/SBAddress.cpp +++ lldb/source/API/SBAddress.cpp @@ -60,7 +60,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { Index: lldb/source/API/SBAttachInfo.cpp =================================================================== --- lldb/source/API/SBAttachInfo.cpp +++ lldb/source/API/SBAttachInfo.cpp @@ -64,7 +64,7 @@ if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } lldb::pid_t SBAttachInfo::GetProcessID() { Index: lldb/source/API/SBBlock.cpp =================================================================== --- lldb/source/API/SBBlock.cpp +++ lldb/source/API/SBBlock.cpp @@ -41,7 +41,7 @@ SBBlock, operator=,(const lldb::SBBlock &), rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } SBBlock::~SBBlock() { m_opaque_ptr = NULL; } Index: lldb/source/API/SBBreakpoint.cpp =================================================================== --- lldb/source/API/SBBreakpoint.cpp +++ lldb/source/API/SBBreakpoint.cpp @@ -62,7 +62,7 @@ SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) { Index: lldb/source/API/SBBreakpointLocation.cpp =================================================================== --- lldb/source/API/SBBreakpointLocation.cpp +++ lldb/source/API/SBBreakpointLocation.cpp @@ -54,7 +54,7 @@ rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBBreakpointLocation::~SBBreakpointLocation() {} Index: lldb/source/API/SBBreakpointName.cpp =================================================================== --- lldb/source/API/SBBreakpointName.cpp +++ lldb/source/API/SBBreakpointName.cpp @@ -166,12 +166,12 @@ if (!rhs.m_impl_up) { m_impl_up.reset(); - return *this; + return LLDB_RECORD_RESULT(*this); } m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName())); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { Index: lldb/source/API/SBBroadcaster.cpp =================================================================== --- lldb/source/API/SBBroadcaster.cpp +++ lldb/source/API/SBBroadcaster.cpp @@ -45,7 +45,7 @@ m_opaque_sp = rhs.m_opaque_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBBroadcaster::~SBBroadcaster() { reset(NULL, false); } Index: lldb/source/API/SBCommandInterpreter.cpp =================================================================== --- lldb/source/API/SBCommandInterpreter.cpp +++ lldb/source/API/SBCommandInterpreter.cpp @@ -196,7 +196,7 @@ rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBCommandInterpreter::IsValid() const { Index: lldb/source/API/SBCommandReturnObject.cpp =================================================================== --- lldb/source/API/SBCommandReturnObject.cpp +++ lldb/source/API/SBCommandReturnObject.cpp @@ -43,7 +43,7 @@ LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *, SBCommandReturnObject, Release); - return m_opaque_up.release(); + return LLDB_RECORD_RESULT(m_opaque_up.release()); } const SBCommandReturnObject &SBCommandReturnObject:: @@ -55,7 +55,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBCommandReturnObject::IsValid() const { Index: lldb/source/API/SBCompileUnit.cpp =================================================================== --- lldb/source/API/SBCompileUnit.cpp +++ lldb/source/API/SBCompileUnit.cpp @@ -38,7 +38,7 @@ rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; } Index: lldb/source/API/SBData.cpp =================================================================== --- lldb/source/API/SBData.cpp +++ lldb/source/API/SBData.cpp @@ -38,7 +38,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBData::~SBData() {} Index: lldb/source/API/SBDebugger.cpp =================================================================== --- lldb/source/API/SBDebugger.cpp +++ lldb/source/API/SBDebugger.cpp @@ -182,7 +182,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBDebugger::Initialize() { @@ -373,7 +373,7 @@ if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } @@ -384,7 +384,7 @@ if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } @@ -395,7 +395,7 @@ if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } Index: lldb/source/API/SBDeclaration.cpp =================================================================== --- lldb/source/API/SBDeclaration.cpp +++ lldb/source/API/SBDeclaration.cpp @@ -42,7 +42,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } void SBDeclaration::SetDeclaration( Index: lldb/source/API/SBError.cpp =================================================================== --- lldb/source/API/SBError.cpp +++ lldb/source/API/SBError.cpp @@ -33,7 +33,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } const char *SBError::GetCString() const { Index: lldb/source/API/SBEvent.cpp =================================================================== --- lldb/source/API/SBEvent.cpp +++ lldb/source/API/SBEvent.cpp @@ -55,7 +55,7 @@ m_event_sp = rhs.m_event_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBEvent::~SBEvent() {} Index: lldb/source/API/SBExecutionContext.cpp =================================================================== --- lldb/source/API/SBExecutionContext.cpp +++ lldb/source/API/SBExecutionContext.cpp @@ -75,7 +75,7 @@ SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs); m_exe_ctx_sp = rhs.m_exe_ctx_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } ExecutionContextRef *SBExecutionContext::get() const { Index: lldb/source/API/SBExpressionOptions.cpp =================================================================== --- lldb/source/API/SBExpressionOptions.cpp +++ lldb/source/API/SBExpressionOptions.cpp @@ -37,7 +37,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBExpressionOptions::~SBExpressionOptions() {} Index: lldb/source/API/SBFileSpec.cpp =================================================================== --- lldb/source/API/SBFileSpec.cpp +++ lldb/source/API/SBFileSpec.cpp @@ -59,7 +59,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBFileSpec::operator==(const SBFileSpec &rhs) const { Index: lldb/source/API/SBFileSpecList.cpp =================================================================== --- lldb/source/API/SBFileSpecList.cpp +++ lldb/source/API/SBFileSpecList.cpp @@ -41,7 +41,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBFileSpecList::GetSize() const { Index: lldb/source/API/SBFrame.cpp =================================================================== --- lldb/source/API/SBFrame.cpp +++ lldb/source/API/SBFrame.cpp @@ -78,7 +78,7 @@ if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } StackFrameSP SBFrame::GetFrameSP() const { Index: lldb/source/API/SBFunction.cpp =================================================================== --- lldb/source/API/SBFunction.cpp +++ lldb/source/API/SBFunction.cpp @@ -39,7 +39,7 @@ SBFunction, operator=,(const lldb::SBFunction &), rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } SBFunction::~SBFunction() { m_opaque_ptr = NULL; } Index: lldb/source/API/SBInstruction.cpp =================================================================== --- lldb/source/API/SBInstruction.cpp +++ lldb/source/API/SBInstruction.cpp @@ -87,7 +87,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstruction::~SBInstruction() {} Index: lldb/source/API/SBInstructionList.cpp =================================================================== --- lldb/source/API/SBInstructionList.cpp +++ lldb/source/API/SBInstructionList.cpp @@ -37,7 +37,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstructionList::~SBInstructionList() {} Index: lldb/source/API/SBLineEntry.cpp =================================================================== --- lldb/source/API/SBLineEntry.cpp +++ lldb/source/API/SBLineEntry.cpp @@ -41,7 +41,7 @@ if (this != &rhs) 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) { Index: lldb/source/API/SBListener.cpp =================================================================== --- lldb/source/API/SBListener.cpp +++ lldb/source/API/SBListener.cpp @@ -42,7 +42,7 @@ m_opaque_sp = rhs.m_opaque_sp; m_unused_ptr = nullptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBListener::SBListener(const lldb::ListenerSP &listener_sp) Index: lldb/source/API/SBMemoryRegionInfo.cpp =================================================================== --- lldb/source/API/SBMemoryRegionInfo.cpp +++ lldb/source/API/SBMemoryRegionInfo.cpp @@ -43,7 +43,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBMemoryRegionInfo::~SBMemoryRegionInfo() {} Index: lldb/source/API/SBMemoryRegionInfoList.cpp =================================================================== --- lldb/source/API/SBMemoryRegionInfoList.cpp +++ lldb/source/API/SBMemoryRegionInfoList.cpp @@ -94,7 +94,7 @@ if (this != &rhs) { *m_opaque_up = *rhs.m_opaque_up; } - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBMemoryRegionInfoList::GetSize() const { Index: lldb/source/API/SBModule.cpp =================================================================== --- lldb/source/API/SBModule.cpp +++ lldb/source/API/SBModule.cpp @@ -73,7 +73,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBModule::~SBModule() {} Index: lldb/source/API/SBModuleSpec.cpp =================================================================== --- lldb/source/API/SBModuleSpec.cpp +++ lldb/source/API/SBModuleSpec.cpp @@ -35,7 +35,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBModuleSpec::~SBModuleSpec() {} @@ -166,7 +166,7 @@ if (this != &rhs) *m_opaque_up = *rhs.m_opaque_up; - return *this; + return LLDB_RECORD_RESULT(*this); } SBModuleSpecList::~SBModuleSpecList() {} Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -72,7 +72,7 @@ if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- Index: lldb/source/API/SBProcessInfo.cpp =================================================================== --- lldb/source/API/SBProcessInfo.cpp +++ lldb/source/API/SBProcessInfo.cpp @@ -34,7 +34,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } ProcessInstanceInfo &SBProcessInfo::ref() { Index: lldb/source/API/SBQueue.cpp =================================================================== --- lldb/source/API/SBQueue.cpp +++ lldb/source/API/SBQueue.cpp @@ -240,7 +240,7 @@ SBQueue, operator=,(const lldb::SBQueue &), rhs); m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBQueue::~SBQueue() {} Index: lldb/source/API/SBSection.cpp =================================================================== --- lldb/source/API/SBSection.cpp +++ lldb/source/API/SBSection.cpp @@ -41,7 +41,7 @@ SBSection, operator=,(const lldb::SBSection &), rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBSection::~SBSection() {} Index: lldb/source/API/SBSourceManager.cpp =================================================================== --- lldb/source/API/SBSourceManager.cpp +++ lldb/source/API/SBSourceManager.cpp @@ -101,7 +101,7 @@ rhs); m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); - return *this; + return LLDB_RECORD_RESULT(*this); } SBSourceManager::~SBSourceManager() {} Index: lldb/source/API/SBStringList.cpp =================================================================== --- lldb/source/API/SBStringList.cpp +++ lldb/source/API/SBStringList.cpp @@ -36,7 +36,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBStringList::~SBStringList() {} Index: lldb/source/API/SBStructuredData.cpp =================================================================== --- lldb/source/API/SBStructuredData.cpp +++ lldb/source/API/SBStructuredData.cpp @@ -54,7 +54,7 @@ SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs); *m_impl_up = *rhs.m_impl_up; - return *this; + return LLDB_RECORD_RESULT(*this); } lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { Index: lldb/source/API/SBSymbol.cpp =================================================================== --- lldb/source/API/SBSymbol.cpp +++ lldb/source/API/SBSymbol.cpp @@ -34,7 +34,7 @@ SBSymbol, operator=,(const lldb::SBSymbol &), rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; } Index: lldb/source/API/SBSymbolContext.cpp =================================================================== --- lldb/source/API/SBSymbolContext.cpp +++ lldb/source/API/SBSymbolContext.cpp @@ -46,7 +46,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) { Index: lldb/source/API/SBSymbolContextList.cpp =================================================================== --- lldb/source/API/SBSymbolContextList.cpp +++ lldb/source/API/SBSymbolContextList.cpp @@ -38,7 +38,7 @@ if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBSymbolContextList::GetSize() const { Index: lldb/source/API/SBTarget.cpp =================================================================== --- lldb/source/API/SBTarget.cpp +++ lldb/source/API/SBTarget.cpp @@ -118,7 +118,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- Index: lldb/source/API/SBThread.cpp =================================================================== --- lldb/source/API/SBThread.cpp +++ lldb/source/API/SBThread.cpp @@ -84,7 +84,7 @@ if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- @@ -1402,9 +1402,8 @@ ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) - return thread_sp.get(); - else - return NULL; + return LLDB_RECORD_RESULT(thread_sp.get()); + return nullptr; } lldb_private::Thread *SBThread::get() { @@ -1412,9 +1411,8 @@ ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) - return thread_sp.get(); - else - return NULL; + return LLDB_RECORD_RESULT(thread_sp.get()); + return nullptr; } namespace lldb_private { Index: lldb/source/API/SBThreadCollection.cpp =================================================================== --- lldb/source/API/SBThreadCollection.cpp +++ lldb/source/API/SBThreadCollection.cpp @@ -32,7 +32,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) Index: lldb/source/API/SBThreadPlan.cpp =================================================================== --- lldb/source/API/SBThreadPlan.cpp +++ lldb/source/API/SBThreadPlan.cpp @@ -82,7 +82,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- // Destructor @@ -92,7 +92,7 @@ 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 { Index: lldb/source/API/SBType.cpp =================================================================== --- lldb/source/API/SBType.cpp +++ lldb/source/API/SBType.cpp @@ -86,7 +86,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBType::~SBType() {} @@ -592,7 +592,7 @@ i < rhs_size; i++) Append(const_cast(rhs).GetTypeAtIndex(i)); } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBTypeList::Append(SBType type) { @@ -642,7 +642,7 @@ if (rhs.IsValid()) m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeMember::IsValid() const { @@ -771,7 +771,7 @@ if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeMemberFunction::IsValid() const { Index: lldb/source/API/SBTypeCategory.cpp =================================================================== --- lldb/source/API/SBTypeCategory.cpp +++ lldb/source/API/SBTypeCategory.cpp @@ -616,7 +616,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { Index: lldb/source/API/SBTypeEnumMember.cpp =================================================================== --- lldb/source/API/SBTypeEnumMember.cpp +++ lldb/source/API/SBTypeEnumMember.cpp @@ -40,12 +40,12 @@ } SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &), + LLDB_RECORD_METHOD(SBTypeEnumMember &,SBTypeEnumMember,operator=, (const lldb::SBTypeEnumMember &), rhs); if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeEnumMember::IsValid() const { @@ -147,7 +147,7 @@ Append( const_cast(rhs).GetTypeEnumMemberAtIndex(i)); } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { Index: lldb/source/API/SBTypeFilter.cpp =================================================================== --- lldb/source/API/SBTypeFilter.cpp +++ lldb/source/API/SBTypeFilter.cpp @@ -126,7 +126,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { Index: lldb/source/API/SBTypeFormat.cpp =================================================================== --- lldb/source/API/SBTypeFormat.cpp +++ lldb/source/API/SBTypeFormat.cpp @@ -121,7 +121,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { Index: lldb/source/API/SBTypeNameSpecifier.cpp =================================================================== --- lldb/source/API/SBTypeNameSpecifier.cpp +++ lldb/source/API/SBTypeNameSpecifier.cpp @@ -108,7 +108,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { Index: lldb/source/API/SBTypeSummary.cpp =================================================================== --- lldb/source/API/SBTypeSummary.cpp +++ lldb/source/API/SBTypeSummary.cpp @@ -345,7 +345,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { Index: lldb/source/API/SBTypeSynthetic.cpp =================================================================== --- lldb/source/API/SBTypeSynthetic.cpp +++ lldb/source/API/SBTypeSynthetic.cpp @@ -143,7 +143,7 @@ if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { Index: lldb/source/API/SBUnixSignals.cpp =================================================================== --- lldb/source/API/SBUnixSignals.cpp +++ lldb/source/API/SBUnixSignals.cpp @@ -40,7 +40,7 @@ if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBUnixSignals::~SBUnixSignals() {} Index: lldb/source/API/SBValue.cpp =================================================================== --- lldb/source/API/SBValue.cpp +++ lldb/source/API/SBValue.cpp @@ -236,7 +236,7 @@ if (this != &rhs) { SetSP(rhs.m_opaque_sp); } - return *this; + return LLDB_RECORD_RESULT(*this); } SBValue::~SBValue() {} Index: lldb/source/API/SBValueList.cpp =================================================================== --- lldb/source/API/SBValueList.cpp +++ lldb/source/API/SBValueList.cpp @@ -111,7 +111,7 @@ else m_opaque_up.reset(); } - return *this; + return LLDB_RECORD_RESULT(*this); } ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); } Index: lldb/source/API/SBVariablesOptions.cpp =================================================================== --- lldb/source/API/SBVariablesOptions.cpp +++ lldb/source/API/SBVariablesOptions.cpp @@ -99,7 +99,7 @@ options); m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); - return *this; + return LLDB_RECORD_RESULT(*this); } SBVariablesOptions::~SBVariablesOptions() = default; Index: lldb/source/API/SBWatchpoint.cpp =================================================================== --- lldb/source/API/SBWatchpoint.cpp +++ lldb/source/API/SBWatchpoint.cpp @@ -43,7 +43,7 @@ SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBWatchpoint::~SBWatchpoint() {} Index: lldb/source/Utility/ReproducerInstrumentation.cpp =================================================================== --- lldb/source/Utility/ReproducerInstrumentation.cpp +++ lldb/source/Utility/ReproducerInstrumentation.cpp @@ -117,4 +117,13 @@ 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; Index: lldb/tools/lldb-instr/Instrument.cpp =================================================================== --- lldb/tools/lldb-instr/Instrument.cpp +++ lldb/tools/lldb-instr/Instrument.cpp @@ -245,7 +245,7 @@ // If the function returns a class or struct, we need to wrap its return // statement(s). - if (!ShouldInsertDummy && ReturnType->isStructureOrClassType()) { + if (!ShouldInsertDummy && ReturnType->getPointeeCXXRecordDecl()) { SBReturnVisitor Visitor(MyRewriter); Visitor.TraverseDecl(Decl); } Index: lldb/unittests/Utility/ReproducerInstrumentationTest.cpp =================================================================== --- lldb/unittests/Utility/ReproducerInstrumentationTest.cpp +++ lldb/unittests/Utility/ReproducerInstrumentationTest.cpp @@ -89,6 +89,8 @@ /// { InstrumentedBar(); InstrumentedFoo GetInstrumentedFoo(); + InstrumentedFoo& GetInstrumentedFooRef(); + InstrumentedFoo* GetInstrumentedFooPtr(); void SetInstrumentedFoo(InstrumentedFoo *foo); void SetInstrumentedFoo(InstrumentedFoo &foo); void Validate(); @@ -201,6 +203,22 @@ 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) { LLDB_RECORD_METHOD(void, InstrumentedBar, SetInstrumentedFoo, (InstrumentedFoo *), foo); @@ -239,6 +257,10 @@ LLDB_REGISTER_CONSTRUCTOR(InstrumentedBar, ()); LLDB_REGISTER_METHOD(InstrumentedFoo, InstrumentedBar, GetInstrumentedFoo, ()); + LLDB_REGISTER_METHOD(InstrumentedFoo&, InstrumentedBar, GetInstrumentedFooRef, + ()); + LLDB_REGISTER_METHOD(InstrumentedFoo*, InstrumentedBar, GetInstrumentedFooPtr, + ()); LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo, (InstrumentedFoo *)); LLDB_REGISTER_METHOD(void, InstrumentedBar, SetInstrumentedFoo, @@ -487,6 +509,83 @@ { InstrumentedBar bar; 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(); +#if 0 + 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, 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; float c = 300.3;