[Lldb-commits] [lldb] 23ee705 - Recommit [lldb] Test 'v' support for direct ivar access (NFC)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 6 11:52:52 PST 2023


Author: Dave Lee
Date: 2023-03-06T11:52:41-08:00
New Revision: 23ee705ac99aade24cec0ebb8f6c4cfc76bcdb08

URL: https://github.com/llvm/llvm-project/commit/23ee705ac99aade24cec0ebb8f6c4cfc76bcdb08
DIFF: https://github.com/llvm/llvm-project/commit/23ee705ac99aade24cec0ebb8f6c4cfc76bcdb08.diff

LOG: 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

Added: 
    lldb/test/API/commands/frame/var/direct-ivar/cpp/Makefile
    lldb/test/API/commands/frame/var/direct-ivar/cpp/TestFrameVarDirectIvarCpp.py
    lldb/test/API/commands/frame/var/direct-ivar/cpp/main.cpp
    lldb/test/API/commands/frame/var/direct-ivar/objc/Makefile
    lldb/test/API/commands/frame/var/direct-ivar/objc/TestFrameVarDirectIvarObjC.py
    lldb/test/API/commands/frame/var/direct-ivar/objc/main.m

Modified: 
    

Removed: 
    


################################################################################
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 0000000000000..3d0b98f13f3d7
--- /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 0000000000000..f483899a75509
--- /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 0000000000000..eadb02be38368
--- /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 0000000000000..d0aadc1af9e58
--- /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 0000000000000..395e014b2d88f
--- /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 0000000000000..3d5ef38dd3187
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/direct-ivar/objc/main.m
@@ -0,0 +1,19 @@
+#include <objc/NSObject.h>
+
+ at interface Classic : NSObject {
+ at public
+  int _ivar;
+}
+ at end
+
+ at implementation Classic
+- (int)fun {
+  // check self
+}
+ at end
+
+int main() {
+  Classic *c = [Classic new];
+  c->_ivar = 30;
+  [c fun];
+}


        


More information about the lldb-commits mailing list