Skip to content

Commit 6d008c9

Browse files
kastiglionerlavaee
authored andcommitted
[lldb] Fix AppleObjCDeclVendor for classes which have no methods (llvm#145452)
Fix the rare case where an ObjC class has ivars but no methods. The fix is to not early return when a class has no method list.
1 parent 5a6bcdb commit 6d008c9

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,8 @@ bool ClassDescriptorV2::Describe(
552552
} else {
553553
std::optional<method_list_t> base_method_list =
554554
GetMethodList(process, class_ro->m_baseMethods_ptr);
555-
if (!base_method_list)
556-
return false;
557-
if (!ProcessMethodList(instance_method_func, *base_method_list))
555+
if (base_method_list &&
556+
!ProcessMethodList(instance_method_func, *base_method_list))
558557
return false;
559558
}
560559
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OBJC_SOURCES := Point.m main.m
2+
include Makefile.rules
3+
4+
# Only objc metadata, no debug info, for Point.m
5+
Point.o: CFLAGS_EXTRAS += -g0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import <objc/NSObject.h>
2+
3+
@interface Point : NSObject
4+
@end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import "Point.h"
2+
3+
@implementation Point {
4+
float _x;
5+
float _y;
6+
}
7+
@end
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.decorators import *
3+
from lldbsuite.test.lldbtest import *
4+
from lldbsuite.test import lldbutil
5+
6+
7+
class TestCase(TestBase):
8+
def test(self):
9+
self.build()
10+
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.m"))
11+
self.expect("frame var -P1 p", substrs=["_x = 0", "_y = 0"])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import "Point.h"
2+
3+
int main() {
4+
Point *p = [Point new];
5+
// break here
6+
return 0;
7+
}

0 commit comments

Comments
 (0)