summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-04-03 21:31:22 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-04-03 21:31:22 +0000
commit306809f292c9dd26e1a901b139f65976cdd5a4b2 (patch)
treeb22cc9af74e85c1ab680b7ad5a8ac035fda72f5e /lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
parent7c711ccf36e0a818f76d711715956ffe831f53b6 (diff)
downloadbcm5719-llvm-306809f292c9dd26e1a901b139f65976cdd5a4b2.tar.gz
bcm5719-llvm-306809f292c9dd26e1a901b139f65976cdd5a4b2.zip
[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
Diffstat (limited to 'lldb/unittests/Utility/ReproducerInstrumentationTest.cpp')
-rw-r--r--lldb/unittests/Utility/ReproducerInstrumentationTest.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
index 12a4c6d7a2c..b1690e5e662 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;
OpenPOWER on IntegriCloud