[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
diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 2570be1..2de1d7f 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/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,14 +675,14 @@
}
/// Record the result of a function call.
- template <typename Result> Result RecordResult(const Result &r) {
+ template <typename Result> Result RecordResult(Result &&r) {
UpdateBoundary();
if (ShouldCapture()) {
assert(!m_result_recorded);
m_serializer.SerializeAll(r);
m_result_recorded = true;
}
- return r;
+ return std::forward<Result>(r);
}
private:
@@ -704,6 +692,7 @@
}
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 36a7323..981b911 100644
--- a/lldb/lit/tools/lldb-instr/Inputs/foo.cpp
+++ b/lldb/lit/tools/lldb-instr/Inputs/foo.cpp
@@ -16,3 +16,11 @@
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 9e2608e..fb76e04 100644
--- a/lldb/lit/tools/lldb-instr/Inputs/foo.h
+++ b/lldb/lit/tools/lldb-instr/Inputs/foo.h
@@ -14,4 +14,6 @@
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 cd294140..a75a3fc 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 0b15944..aa8af5b 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 cdd59fa..cb67690 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp
index 93291ad..838385c 100644
--- a/lldb/source/API/SBAttachInfo.cpp
+++ b/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() {
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index ae9bb0e..b8ca473 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/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; }
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 399c5d1..b97bb0f 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index c967426..f3ee820 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp
index b51b9d2..63439a1 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp
index 2777fe8..4119fb2 100644
--- a/lldb/source/API/SBBroadcaster.cpp
+++ b/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); }
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index 00409fc..e6d7ac6 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index e09f9be..94e8991 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp
index 9693dc9..b5bac6b 100644
--- a/lldb/source/API/SBCompileUnit.cpp
+++ b/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; }
diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp
index fb8c8a5..d9e54d5 100644
--- a/lldb/source/API/SBData.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index ad3dc54..c60774c 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/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;
}
diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp
index ae2d5c4..f14ca39 100644
--- a/lldb/source/API/SBDeclaration.cpp
+++ b/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(
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 2525044..c462789 100644
--- a/lldb/source/API/SBError.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index 12fefc9..b63108e 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBExecutionContext.cpp b/lldb/source/API/SBExecutionContext.cpp
index 4aa0ae2..1224c2a 100644
--- a/lldb/source/API/SBExecutionContext.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp
index 4b15b71..8c34194 100644
--- a/lldb/source/API/SBExpressionOptions.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index dd8ed1c..2f910b9 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp
index d55648f..3143964 100644
--- a/lldb/source/API/SBFileSpecList.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 8fcc69a..55d94a2 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 2e61453..35ddb1c 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/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; }
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index 2e6f23d..7113efa 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp
index cb8f5e6..390ad47 100644
--- a/lldb/source/API/SBInstructionList.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index 82f2615..b7aac0b 100644
--- a/lldb/source/API/SBLineEntry.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp
index 0caef04..5eb5abd8 100644
--- a/lldb/source/API/SBListener.cpp
+++ b/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)
diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp
index cc99d29..d25570f 100644
--- a/lldb/source/API/SBMemoryRegionInfo.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBMemoryRegionInfoList.cpp b/lldb/source/API/SBMemoryRegionInfoList.cpp
index 9801a90..32a3afb 100644
--- a/lldb/source/API/SBMemoryRegionInfoList.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index dfdfed3..a22d7ca 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp
index 3381182..a5e9ad2 100644
--- a/lldb/source/API/SBModuleSpec.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 975186a..0259d3d 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/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);
}
//----------------------------------------------------------------------
diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp
index 1886130..be242ec 100644
--- a/lldb/source/API/SBProcessInfo.cpp
+++ b/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() {
diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp
index bb04b72..465bbac 100644
--- a/lldb/source/API/SBQueue.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp
index 5fc999f..f47a799 100644
--- a/lldb/source/API/SBSection.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp
index 73a9c4a..785f309 100644
--- a/lldb/source/API/SBSourceManager.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp
index 9d351bc..b08f232 100644
--- a/lldb/source/API/SBStringList.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp
index 347dfae..6b973e8 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index 911d7b6..a3c5acf 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/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; }
diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp
index b00cd77..f8f446b 100644
--- a/lldb/source/API/SBSymbolContext.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp
index e85113c..7c9a9db 100644
--- a/lldb/source/API/SBSymbolContextList.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cb4bc18..e17355f 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/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);
}
//----------------------------------------------------------------------
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 0e6d510..978f2929 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBThreadCollection.cpp b/lldb/source/API/SBThreadCollection.cpp
index e52c3d7..766fe8f 100644
--- a/lldb/source/API/SBThreadCollection.cpp
+++ b/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)
diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp
index 05f813f..742a357 100644
--- a/lldb/source/API/SBThreadPlan.cpp
+++ b/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 {
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index b0b9299..e016ee4 100644
--- a/lldb/source/API/SBType.cpp
+++ b/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<SBTypeList &>(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 {
diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp
index 76b86b4..a41b02a 100644
--- a/lldb/source/API/SBTypeCategory.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp
index d04e91c..c0e1c79 100644
--- a/lldb/source/API/SBTypeEnumMember.cpp
+++ b/lldb/source/API/SBTypeEnumMember.cpp
@@ -40,12 +40,13 @@
}
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 @@
Append(
const_cast<SBTypeEnumMemberList &>(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 578f0d6..104ef95 100644
--- a/lldb/source/API/SBTypeFilter.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp
index cbea4d8..12729aa 100644
--- a/lldb/source/API/SBTypeFormat.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp
index aaacffa..cccd0ee 100644
--- a/lldb/source/API/SBTypeNameSpecifier.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp
index 70a9cf1..8ffb114 100644
--- a/lldb/source/API/SBTypeSummary.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp
index e497826..f1e1552 100644
--- a/lldb/source/API/SBTypeSynthetic.cpp
+++ b/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) {
diff --git a/lldb/source/API/SBUnixSignals.cpp b/lldb/source/API/SBUnixSignals.cpp
index b4122b2..277a92d 100644
--- a/lldb/source/API/SBUnixSignals.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 0f2700d..3db84fa 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/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() {}
diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp
index 8cdb364..2f74c99 100644
--- a/lldb/source/API/SBValueList.cpp
+++ b/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(); }
diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp
index d04a39e..bf0197c 100644
--- a/lldb/source/API/SBVariablesOptions.cpp
+++ b/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;
diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp
index de7ba95..0f35c3e 100644
--- a/lldb/source/API/SBWatchpoint.cpp
+++ b/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() {}
diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp
index dc42f6f..6702752 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/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;
diff --git a/lldb/tools/lldb-instr/Instrument.cpp b/lldb/tools/lldb-instr/Instrument.cpp
index c46afb4..f30707c 100644
--- a/lldb/tools/lldb-instr/Instrument.cpp
+++ b/lldb/tools/lldb-instr/Instrument.cpp
@@ -245,7 +245,9 @@
// 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 12a4c6d..b1690e5 100644
--- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ b/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,80 @@
{
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;