From 23ee705ac99aade24cec0ebb8f6c4cfc76bcdb08 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Sun, 5 Mar 2023 19:26:29 -0800 Subject: [PATCH] Recommit [lldb] Test 'v' support for direct ivar access (NFC) Add basic tests for `frame variable`'s ability to direct access fields of `this` and ivars of `self`. This splits the tests, preventing ObjC tests from running on Linux. Differential Revision: https://reviews.llvm.org/D145348 --- .../API/commands/frame/var/direct-ivar/cpp/Makefile | 2 ++ .../var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py | 11 +++++++++++ .../API/commands/frame/var/direct-ivar/cpp/main.cpp | 12 ++++++++++++ .../API/commands/frame/var/direct-ivar/objc/Makefile | 2 ++ .../direct-ivar/objc/TestFrameVarDirectIvarObjC.py | 12 ++++++++++++ .../API/commands/frame/var/direct-ivar/objc/main.m | 19 +++++++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/cpp/Makefile create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/cpp/main.cpp create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/objc/Makefile create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/objc/TestFrameVarDirectIvarObjC.py create mode 100644 lldb/test/API/commands/frame/var/direct-ivar/objc/main.m diff --git a/lldb/test/API/commands/frame/var/direct-ivar/cpp/Makefile b/lldb/test/API/commands/frame/var/direct-ivar/cpp/Makefile new file mode 100644 index 0000000..3d0b98f --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/cpp/Makefile @@ -0,0 +1,2 @@ +CXX_SOURCES := main.cpp +include Makefile.rules diff --git a/lldb/test/API/commands/frame/var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py b/lldb/test/API/commands/frame/var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py new file mode 100644 index 0000000..f483899 --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py @@ -0,0 +1,11 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test import lldbutil + + +class TestCase(TestBase): + def test_cpp_this(self): + self.build() + lldbutil.run_to_source_breakpoint(self, "// check this", lldb.SBFileSpec("main.cpp")) + self.expect("frame variable m_field", startstr="(int) m_field = 30") diff --git a/lldb/test/API/commands/frame/var/direct-ivar/cpp/main.cpp b/lldb/test/API/commands/frame/var/direct-ivar/cpp/main.cpp new file mode 100644 index 0000000..eadb02b --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/cpp/main.cpp @@ -0,0 +1,12 @@ +struct Structure { + int m_field; + void fun() { + // check this + } +}; + +int main() { + Structure s; + s.m_field = 30; + s.fun(); +} diff --git a/lldb/test/API/commands/frame/var/direct-ivar/objc/Makefile b/lldb/test/API/commands/frame/var/direct-ivar/objc/Makefile new file mode 100644 index 0000000..d0aadc1 --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/objc/Makefile @@ -0,0 +1,2 @@ +OBJC_SOURCES := main.m +include Makefile.rules diff --git a/lldb/test/API/commands/frame/var/direct-ivar/objc/TestFrameVarDirectIvarObjC.py b/lldb/test/API/commands/frame/var/direct-ivar/objc/TestFrameVarDirectIvarObjC.py new file mode 100644 index 0000000..395e014 --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/objc/TestFrameVarDirectIvarObjC.py @@ -0,0 +1,12 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test import lldbutil + + +class TestCase(TestBase): + @skipUnlessDarwin + def test_objc_self(self): + self.build() + lldbutil.run_to_source_breakpoint(self, "// check self", lldb.SBFileSpec("main.m")) + self.expect("frame variable _ivar", startstr="(int) _ivar = 30") diff --git a/lldb/test/API/commands/frame/var/direct-ivar/objc/main.m b/lldb/test/API/commands/frame/var/direct-ivar/objc/main.m new file mode 100644 index 0000000..3d5ef38 --- /dev/null +++ b/lldb/test/API/commands/frame/var/direct-ivar/objc/main.m @@ -0,0 +1,19 @@ +#include + +@interface Classic : NSObject { +@public + int _ivar; +} +@end + +@implementation Classic +- (int)fun { + // check self +} +@end + +int main() { + Classic *c = [Classic new]; + c->_ivar = 30; + [c fun]; +} -- 2.7.4