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
This commit is contained in:
Dave Lee
2023-03-05 19:26:29 -08:00
parent 38774c4f39
commit 23ee705ac9
6 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
CXX_SOURCES := main.cpp
include Makefile.rules

View File

@@ -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")

View File

@@ -0,0 +1,12 @@
struct Structure {
int m_field;
void fun() {
// check this
}
};
int main() {
Structure s;
s.m_field = 30;
s.fun();
}

View File

@@ -0,0 +1,2 @@
OBJC_SOURCES := main.m
include Makefile.rules

View File

@@ -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")

View File

@@ -0,0 +1,19 @@
#include <objc/NSObject.h>
@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];
}