From 306809f292c9dd26e1a901b139f65976cdd5a4b2 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Apr 2019 21:31:22 +0000 Subject: [PATCH] [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 --- .../lldb/Utility/ReproducerInstrumentation.h | 23 ++--- lldb/lit/tools/lldb-instr/Inputs/foo.cpp | 8 ++ lldb/lit/tools/lldb-instr/Inputs/foo.h | 2 + .../lldb-instr/TestInstrumentationRecord.test | 2 + .../TestInstrumentationRegister.test | 3 + lldb/source/API/SBAddress.cpp | 2 +- lldb/source/API/SBAttachInfo.cpp | 2 +- lldb/source/API/SBBlock.cpp | 2 +- lldb/source/API/SBBreakpoint.cpp | 2 +- lldb/source/API/SBBreakpointLocation.cpp | 2 +- lldb/source/API/SBBreakpointName.cpp | 4 +- lldb/source/API/SBBroadcaster.cpp | 2 +- lldb/source/API/SBCommandInterpreter.cpp | 2 +- lldb/source/API/SBCommandReturnObject.cpp | 4 +- lldb/source/API/SBCompileUnit.cpp | 2 +- lldb/source/API/SBData.cpp | 2 +- lldb/source/API/SBDebugger.cpp | 8 +- lldb/source/API/SBDeclaration.cpp | 2 +- lldb/source/API/SBError.cpp | 2 +- lldb/source/API/SBEvent.cpp | 2 +- lldb/source/API/SBExecutionContext.cpp | 2 +- lldb/source/API/SBExpressionOptions.cpp | 2 +- lldb/source/API/SBFileSpec.cpp | 2 +- lldb/source/API/SBFileSpecList.cpp | 2 +- lldb/source/API/SBFrame.cpp | 2 +- lldb/source/API/SBFunction.cpp | 2 +- lldb/source/API/SBInstruction.cpp | 2 +- lldb/source/API/SBInstructionList.cpp | 2 +- lldb/source/API/SBLineEntry.cpp | 2 +- lldb/source/API/SBListener.cpp | 2 +- lldb/source/API/SBMemoryRegionInfo.cpp | 2 +- lldb/source/API/SBMemoryRegionInfoList.cpp | 2 +- lldb/source/API/SBModule.cpp | 2 +- lldb/source/API/SBModuleSpec.cpp | 4 +- lldb/source/API/SBProcess.cpp | 2 +- lldb/source/API/SBProcessInfo.cpp | 2 +- lldb/source/API/SBQueue.cpp | 2 +- lldb/source/API/SBSection.cpp | 2 +- lldb/source/API/SBSourceManager.cpp | 2 +- lldb/source/API/SBStringList.cpp | 2 +- lldb/source/API/SBStructuredData.cpp | 2 +- lldb/source/API/SBSymbol.cpp | 2 +- lldb/source/API/SBSymbolContext.cpp | 2 +- lldb/source/API/SBSymbolContextList.cpp | 2 +- lldb/source/API/SBTarget.cpp | 2 +- lldb/source/API/SBThread.cpp | 12 +-- lldb/source/API/SBThreadCollection.cpp | 2 +- lldb/source/API/SBThreadPlan.cpp | 4 +- lldb/source/API/SBType.cpp | 8 +- lldb/source/API/SBTypeCategory.cpp | 2 +- lldb/source/API/SBTypeEnumMember.cpp | 9 +- lldb/source/API/SBTypeFilter.cpp | 2 +- lldb/source/API/SBTypeFormat.cpp | 2 +- lldb/source/API/SBTypeNameSpecifier.cpp | 2 +- lldb/source/API/SBTypeSummary.cpp | 2 +- lldb/source/API/SBTypeSynthetic.cpp | 2 +- lldb/source/API/SBUnixSignals.cpp | 2 +- lldb/source/API/SBValue.cpp | 2 +- lldb/source/API/SBValueList.cpp | 2 +- lldb/source/API/SBVariablesOptions.cpp | 2 +- lldb/source/API/SBWatchpoint.cpp | 2 +- .../Utility/ReproducerInstrumentation.cpp | 9 ++ lldb/tools/lldb-instr/Instrument.cpp | 4 +- .../Utility/ReproducerInstrumentationTest.cpp | 96 +++++++++++++++++++ 64 files changed, 203 insertions(+), 93 deletions(-) diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h index 2570be13c7f4..2de1d7f97ae3 100644 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -185,7 +185,7 @@ template inline std::string log_args(const Ts &... ts) { } #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 @@ public: 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 @@ public: 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,14 +675,14 @@ public: } /// Record the result of a function call. - template Result RecordResult(const Result &r) { + template Result RecordResult(Result &&r) { UpdateBoundary(); if (ShouldCapture()) { assert(!m_result_recorded); m_serializer.SerializeAll(r); m_result_recorded = true; } - return r; + return std::forward(r); } private: @@ -704,6 +692,7 @@ private: } bool ShouldCapture() { return m_local_boundary; } + void Log(unsigned id); Serializer &m_serializer; Registry &m_registry; diff --git a/lldb/lit/tools/lldb-instr/Inputs/foo.cpp b/lldb/lit/tools/lldb-instr/Inputs/foo.cpp index 36a73236a425..981b911eee26 100644 --- a/lldb/lit/tools/lldb-instr/Inputs/foo.cpp +++ b/lldb/lit/tools/lldb-instr/Inputs/foo.cpp @@ -16,3 +16,11 @@ Foo Foo::H() { return Foo(); } void Foo::I() const { MACRO_FOO; } Bar Foo::J() const { return MACRO_BAR(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; +}; diff --git a/lldb/lit/tools/lldb-instr/Inputs/foo.h b/lldb/lit/tools/lldb-instr/Inputs/foo.h index 9e2608e2b9ea..fb76e046e024 100644 --- a/lldb/lit/tools/lldb-instr/Inputs/foo.h +++ b/lldb/lit/tools/lldb-instr/Inputs/foo.h @@ -14,4 +14,6 @@ struct Foo { void I() const; Bar J() const; Bar K(void *v) const; + Bar &L() const; + Bar *M() const; }; diff --git a/lldb/lit/tools/lldb-instr/TestInstrumentationRecord.test b/lldb/lit/tools/lldb-instr/TestInstrumentationRecord.test index cd2941401729..a75a3fcecff1 100644 --- a/lldb/lit/tools/lldb-instr/TestInstrumentationRecord.test +++ b/lldb/lit/tools/lldb-instr/TestInstrumentationRecord.test @@ -20,3 +20,5 @@ # CHECK-NOT: LLDB_RECORD_RESULT(Bar()); # CHECK: LLDB_RECORD_DUMMY(Bar, Foo, K, (void *), v); # CHECK-NOT: LLDB_RECORD_RESULT(Bar()); +# CHECK: LLDB_RECORD_RESULT(*b) +# CHECK: LLDB_RECORD_RESULT(b) diff --git a/lldb/lit/tools/lldb-instr/TestInstrumentationRegister.test b/lldb/lit/tools/lldb-instr/TestInstrumentationRegister.test index 0b15944a9a7b..aa8af5b8fe27 100644 --- a/lldb/lit/tools/lldb-instr/TestInstrumentationRegister.test +++ b/lldb/lit/tools/lldb-instr/TestInstrumentationRegister.test @@ -11,6 +11,9 @@ # CHECK: LLDB_REGISTER_METHOD_CONST(int, Foo, D, (bool)); # CHECK: LLDB_REGISTER_STATIC_METHOD(void, Foo, E, ()); # 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_METHOD_CONST(void, Foo, I, ()); # CHECK-NOT: LLDB_REGISTER_METHOD_CONST(Bar, Foo, K, (void*)); diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index cdd59fa1feb8..cb67690544b2 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -60,7 +60,7 @@ const SBAddress &SBAddress::operator=(const SBAddress &rhs) { 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) { diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp index 93291ad7bf87..838385c104ae 100644 --- a/lldb/source/API/SBAttachInfo.cpp +++ b/lldb/source/API/SBAttachInfo.cpp @@ -64,7 +64,7 @@ SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) { if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } lldb::pid_t SBAttachInfo::GetProcessID() { diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp index ae9bb0e867a2..b8ca473894fc 100644 --- a/lldb/source/API/SBBlock.cpp +++ b/lldb/source/API/SBBlock.cpp @@ -41,7 +41,7 @@ const SBBlock &SBBlock::operator=(const SBBlock &rhs) { 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; } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 399c5d146f1e..b97bb0f84b28 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -62,7 +62,7 @@ const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) { 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) { diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index c9674260cb92..f3ee8201afd1 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -54,7 +54,7 @@ operator=(const SBBreakpointLocation &rhs) { rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBBreakpointLocation::~SBBreakpointLocation() {} diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index b51b9d2d46a5..63439a1f8909 100644 --- a/lldb/source/API/SBBreakpointName.cpp +++ b/lldb/source/API/SBBreakpointName.cpp @@ -166,12 +166,12 @@ operator=(const SBBreakpointName &rhs) { 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) { diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index 2777fe8e3f65..4119fb2c134c 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -45,7 +45,7 @@ const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) { 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); } diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 00409fc208b6..e6d7ac61817b 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -196,7 +196,7 @@ operator=(const SBCommandInterpreter &rhs) { rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBCommandInterpreter::IsValid() const { diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index e09f9be3aa59..94e89916f7f6 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -43,7 +43,7 @@ CommandReturnObject *SBCommandReturnObject::Release() { 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 @@ operator=(const SBCommandReturnObject &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBCommandReturnObject::IsValid() const { diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index 9693dc9a687c..b5bac6bf7d1a 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -38,7 +38,7 @@ const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) { rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; } diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp index fb8c8a50e825..d9e54d54a180 100644 --- a/lldb/source/API/SBData.cpp +++ b/lldb/source/API/SBData.cpp @@ -38,7 +38,7 @@ const SBData &SBData::operator=(const SBData &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBData::~SBData() {} diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index ad3dc5412c86..c60774c9fa70 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -182,7 +182,7 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBDebugger::Initialize() { @@ -373,7 +373,7 @@ FILE *SBDebugger::GetInputFileHandle() { 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 @@ FILE *SBDebugger::GetOutputFileHandle() { 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 @@ FILE *SBDebugger::GetErrorFileHandle() { 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; } diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index ae2d5c41e916..f14ca3993f41 100644 --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -42,7 +42,7 @@ const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } void SBDeclaration::SetDeclaration( diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 252504435521..c4627898282e 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -33,7 +33,7 @@ const SBError &SBError::operator=(const SBError &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } const char *SBError::GetCString() const { diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index 12fefc9e9836..b63108ec1fc9 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -55,7 +55,7 @@ const SBEvent &SBEvent::operator=(const SBEvent &rhs) { m_event_sp = rhs.m_event_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBEvent::~SBEvent() {} diff --git a/lldb/source/API/SBExecutionContext.cpp b/lldb/source/API/SBExecutionContext.cpp index 4aa0ae2283b1..1224c2abe989 100644 --- a/lldb/source/API/SBExecutionContext.cpp +++ b/lldb/source/API/SBExecutionContext.cpp @@ -75,7 +75,7 @@ operator=(const lldb::SBExecutionContext &rhs) { 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 { diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index 4b15b71bec1f..8c34194abf1e 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -37,7 +37,7 @@ operator=(const SBExpressionOptions &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBExpressionOptions::~SBExpressionOptions() {} diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index dd8ed1cc53e6..2f910b9ba294 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -59,7 +59,7 @@ const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) { 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 { diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index d55648f156ac..3143964b38cb 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -41,7 +41,7 @@ const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBFileSpecList::GetSize() const { diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 8fcc69ac88d1..55d94a2db006 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -78,7 +78,7 @@ const SBFrame &SBFrame::operator=(const SBFrame &rhs) { if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return *this; + return LLDB_RECORD_RESULT(*this); } StackFrameSP SBFrame::GetFrameSP() const { diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 2e61453f1a59..35ddb1c7cd6b 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -39,7 +39,7 @@ const SBFunction &SBFunction::operator=(const SBFunction &rhs) { 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; } diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 2e6f23da1c63..7113efa2a4e1 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -87,7 +87,7 @@ const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstruction::~SBInstruction() {} diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp index cb8f5e6a5f6c..390ad4750613 100644 --- a/lldb/source/API/SBInstructionList.cpp +++ b/lldb/source/API/SBInstructionList.cpp @@ -37,7 +37,7 @@ operator=(const SBInstructionList &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstructionList::~SBInstructionList() {} diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 82f26153e50a..b7aac0be9356 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -41,7 +41,7 @@ const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) { 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) { diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index 0caef04a3627..5eb5abd80280 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -42,7 +42,7 @@ const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) { 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) diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index cc99d292e6dc..d25570f51ce5 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -43,7 +43,7 @@ operator=(const SBMemoryRegionInfo &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBMemoryRegionInfo::~SBMemoryRegionInfo() {} diff --git a/lldb/source/API/SBMemoryRegionInfoList.cpp b/lldb/source/API/SBMemoryRegionInfoList.cpp index 9801a9006dbb..32a3afb84af0 100644 --- a/lldb/source/API/SBMemoryRegionInfoList.cpp +++ b/lldb/source/API/SBMemoryRegionInfoList.cpp @@ -94,7 +94,7 @@ operator=(const SBMemoryRegionInfoList &rhs) { if (this != &rhs) { *m_opaque_up = *rhs.m_opaque_up; } - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBMemoryRegionInfoList::GetSize() const { diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index dfdfed32e121..a22d7ca29890 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -73,7 +73,7 @@ const SBModule &SBModule::operator=(const SBModule &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBModule::~SBModule() {} diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp index 338118278b27..a5e9ad26fac1 100644 --- a/lldb/source/API/SBModuleSpec.cpp +++ b/lldb/source/API/SBModuleSpec.cpp @@ -35,7 +35,7 @@ const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBModuleSpec::~SBModuleSpec() {} @@ -166,7 +166,7 @@ SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { if (this != &rhs) *m_opaque_up = *rhs.m_opaque_up; - return *this; + return LLDB_RECORD_RESULT(*this); } SBModuleSpecList::~SBModuleSpecList() {} diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 975186a03cde..0259d3d63db1 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -72,7 +72,7 @@ const SBProcess &SBProcess::operator=(const SBProcess &rhs) { if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index 188613045fd1..be242ec5872d 100644 --- a/lldb/source/API/SBProcessInfo.cpp +++ b/lldb/source/API/SBProcessInfo.cpp @@ -34,7 +34,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } ProcessInstanceInfo &SBProcessInfo::ref() { diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index bb04b7283b34..465bbac93872 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -240,7 +240,7 @@ const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) { SBQueue, operator=,(const lldb::SBQueue &), rhs); m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBQueue::~SBQueue() {} diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index 5fc999f6a8d0..f47a799697dc 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -41,7 +41,7 @@ const SBSection &SBSection::operator=(const SBSection &rhs) { SBSection, operator=,(const lldb::SBSection &), rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBSection::~SBSection() {} diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index 73a9c4a0904c..785f3090777c 100644 --- a/lldb/source/API/SBSourceManager.cpp +++ b/lldb/source/API/SBSourceManager.cpp @@ -101,7 +101,7 @@ operator=(const lldb::SBSourceManager &rhs) { rhs); m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); - return *this; + return LLDB_RECORD_RESULT(*this); } SBSourceManager::~SBSourceManager() {} diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index 9d351bcbab46..b08f232389cf 100644 --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -36,7 +36,7 @@ const SBStringList &SBStringList::operator=(const SBStringList &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } SBStringList::~SBStringList() {} diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp index 347dfaed34aa..6b973e82c858 100644 --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -54,7 +54,7 @@ operator=(const lldb::SBStructuredData &rhs) { 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) { diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 911d7b6f68f4..a3c5acf3941c 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -34,7 +34,7 @@ const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) { 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; } diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index b00cd77b7b94..f8f446ba5745 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -46,7 +46,7 @@ const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { 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) { diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp index e85113cca2ac..7c9a9dbb871b 100644 --- a/lldb/source/API/SBSymbolContextList.cpp +++ b/lldb/source/API/SBSymbolContextList.cpp @@ -38,7 +38,7 @@ operator=(const SBSymbolContextList &rhs) { if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBSymbolContextList::GetSize() const { diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index cb4bc18c7bfd..e17355f0de39 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -118,7 +118,7 @@ const SBTarget &SBTarget::operator=(const SBTarget &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 0e6d510fcbde..978f2929f174 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -84,7 +84,7 @@ const lldb::SBThread &SBThread::operator=(const SBThread &rhs) { if (this != &rhs) 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()); 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 @@ lldb_private::Thread *SBThread::get() { 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 { diff --git a/lldb/source/API/SBThreadCollection.cpp b/lldb/source/API/SBThreadCollection.cpp index e52c3d7f0bae..766fe8f5516d 100644 --- a/lldb/source/API/SBThreadCollection.cpp +++ b/lldb/source/API/SBThreadCollection.cpp @@ -32,7 +32,7 @@ operator=(const SBThreadCollection &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp index 05f813f57817..742a3570f404 100644 --- a/lldb/source/API/SBThreadPlan.cpp +++ b/lldb/source/API/SBThreadPlan.cpp @@ -82,7 +82,7 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } //---------------------------------------------------------------------- // Destructor @@ -92,7 +92,7 @@ SBThreadPlan::~SBThreadPlan() {} 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 { diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index b0b92992e793..e016ee46f235 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -86,7 +86,7 @@ SBType &SBType::operator=(const SBType &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBType::~SBType() {} @@ -592,7 +592,7 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { 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 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { 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 @@ operator=(const lldb::SBTypeMemberFunction &rhs) { if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeMemberFunction::IsValid() const { diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index 76b86b45bd1e..a41b02acf681 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -616,7 +616,7 @@ operator=(const lldb::SBTypeCategory &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp index d04e91c7fe61..c0e1c7942db9 100644 --- a/lldb/source/API/SBTypeEnumMember.cpp +++ b/lldb/source/API/SBTypeEnumMember.cpp @@ -40,12 +40,13 @@ SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs) } SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &), - rhs); + 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 +148,7 @@ operator=(const SBTypeEnumMemberList &rhs) { Append( const_cast(rhs).GetTypeEnumMemberAtIndex(i)); } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp index 578f0d638bd1..104ef95650fa 100644 --- a/lldb/source/API/SBTypeFilter.cpp +++ b/lldb/source/API/SBTypeFilter.cpp @@ -126,7 +126,7 @@ lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp index cbea4d8d1421..12729aaf9827 100644 --- a/lldb/source/API/SBTypeFormat.cpp +++ b/lldb/source/API/SBTypeFormat.cpp @@ -121,7 +121,7 @@ lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp index aaacffa68df7..cccd0ee449e0 100644 --- a/lldb/source/API/SBTypeNameSpecifier.cpp +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -108,7 +108,7 @@ operator=(const lldb::SBTypeNameSpecifier &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp index 70a9cf13c1f4..8ffb114470b0 100644 --- a/lldb/source/API/SBTypeSummary.cpp +++ b/lldb/source/API/SBTypeSummary.cpp @@ -345,7 +345,7 @@ lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp index e497826c79bf..f1e15525a08d 100644 --- a/lldb/source/API/SBTypeSynthetic.cpp +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -143,7 +143,7 @@ operator=(const lldb::SBTypeSynthetic &rhs) { if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { diff --git a/lldb/source/API/SBUnixSignals.cpp b/lldb/source/API/SBUnixSignals.cpp index b4122b22fd67..277a92d21ae9 100644 --- a/lldb/source/API/SBUnixSignals.cpp +++ b/lldb/source/API/SBUnixSignals.cpp @@ -40,7 +40,7 @@ const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) { if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBUnixSignals::~SBUnixSignals() {} diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 0f2700d1e192..3db84fa29804 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -236,7 +236,7 @@ SBValue &SBValue::operator=(const SBValue &rhs) { if (this != &rhs) { SetSP(rhs.m_opaque_sp); } - return *this; + return LLDB_RECORD_RESULT(*this); } SBValue::~SBValue() {} diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index 8cdb3647851c..2f74c9922526 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -111,7 +111,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) { else m_opaque_up.reset(); } - return *this; + return LLDB_RECORD_RESULT(*this); } ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); } diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index d04a39e08ac4..bf0197cd960b 100644 --- a/lldb/source/API/SBVariablesOptions.cpp +++ b/lldb/source/API/SBVariablesOptions.cpp @@ -99,7 +99,7 @@ operator=(const SBVariablesOptions &options) { options); m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); - return *this; + return LLDB_RECORD_RESULT(*this); } SBVariablesOptions::~SBVariablesOptions() = default; diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp index de7ba95b1b9f..0f35c3eda872 100644 --- a/lldb/source/API/SBWatchpoint.cpp +++ b/lldb/source/API/SBWatchpoint.cpp @@ -43,7 +43,7 @@ const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) { SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs); m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBWatchpoint::~SBWatchpoint() {} diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp index dc42f6ffa0b1..6702752fe486 100644 --- a/lldb/source/Utility/ReproducerInstrumentation.cpp +++ b/lldb/source/Utility/ReproducerInstrumentation.cpp @@ -117,4 +117,13 @@ Recorder::~Recorder() { 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; diff --git a/lldb/tools/lldb-instr/Instrument.cpp b/lldb/tools/lldb-instr/Instrument.cpp index c46afb456730..f30707c22b04 100644 --- a/lldb/tools/lldb-instr/Instrument.cpp +++ b/lldb/tools/lldb-instr/Instrument.cpp @@ -245,7 +245,9 @@ public: // If the function returns a class or struct, we need to wrap its return // statement(s). - if (!ShouldInsertDummy && ReturnType->isStructureOrClassType()) { + bool ShouldRecordResult = ReturnType->isStructureOrClassType() || + ReturnType->getPointeeCXXRecordDecl(); + if (!ShouldInsertDummy && ShouldRecordResult) { SBReturnVisitor Visitor(MyRewriter); Visitor.TraverseDecl(Decl); } diff --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp index 12a4c6d7a2c6..b1690e5e662e 100644 --- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp +++ b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp @@ -89,6 +89,8 @@ public: /// { InstrumentedBar(); InstrumentedFoo GetInstrumentedFoo(); + InstrumentedFoo &GetInstrumentedFooRef(); + InstrumentedFoo *GetInstrumentedFooPtr(); void SetInstrumentedFoo(InstrumentedFoo *foo); void SetInstrumentedFoo(InstrumentedFoo &foo); void Validate(); @@ -201,6 +203,22 @@ InstrumentedFoo InstrumentedBar::GetInstrumentedFoo() { 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 @@ TestingRegistry::TestingRegistry() { 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,80 @@ TEST(RecordReplayTest, InstrumentedBar) { { 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(); + + 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;