Skip to content

Commit 5ff1e2f

Browse files
committed
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 (cherry picked from commit 23ee705)
1 parent 0fd328d commit 5ff1e2f

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CXX_SOURCES := main.cpp
2+
include Makefile.rules
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
from lldbsuite.test import lldbutil
5+
6+
7+
class TestCase(TestBase):
8+
def test_cpp_this(self):
9+
self.build()
10+
lldbutil.run_to_source_breakpoint(self, "// check this", lldb.SBFileSpec("main.cpp"))
11+
self.expect("frame variable m_field", startstr="(int) m_field = 30")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
struct Structure {
2+
int m_field;
3+
void fun() {
4+
// check this
5+
}
6+
};
7+
8+
int main() {
9+
Structure s;
10+
s.m_field = 30;
11+
s.fun();
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OBJC_SOURCES := main.m
2+
include Makefile.rules
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
from lldbsuite.test import lldbutil
5+
6+
7+
class TestCase(TestBase):
8+
@skipUnlessDarwin
9+
def test_objc_self(self):
10+
self.build()
11+
lldbutil.run_to_source_breakpoint(self, "// check self", lldb.SBFileSpec("main.m"))
12+
self.expect("frame variable _ivar", startstr="(int) _ivar = 30")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <objc/NSObject.h>
2+
3+
@interface Classic : NSObject {
4+
@public
5+
int _ivar;
6+
}
7+
@end
8+
9+
@implementation Classic
10+
- (int)fun {
11+
// check self
12+
}
13+
@end
14+
15+
int main() {
16+
Classic *c = [Classic new];
17+
c->_ivar = 30;
18+
[c fun];
19+
}

0 commit comments

Comments
 (0)