[lldb] Fix AppleObjCDeclVendor for classes which have no methods (#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.
This commit is contained in:
Dave Lee
2025-06-24 10:58:06 -07:00
committed by GitHub
parent 0b8f3cc6b7
commit 23b0564800
6 changed files with 36 additions and 3 deletions

View File

@@ -552,9 +552,8 @@ bool ClassDescriptorV2::Describe(
} else {
std::optional<method_list_t> base_method_list =
GetMethodList(process, class_ro->m_baseMethods_ptr);
if (!base_method_list)
return false;
if (!ProcessMethodList(instance_method_func, *base_method_list))
if (base_method_list &&
!ProcessMethodList(instance_method_func, *base_method_list))
return false;
}
}

View File

@@ -0,0 +1,5 @@
OBJC_SOURCES := Point.m main.m
include Makefile.rules
# Only objc metadata, no debug info, for Point.m
Point.o: CFLAGS_EXTRAS += -g0

View File

@@ -0,0 +1,4 @@
#import <objc/NSObject.h>
@interface Point : NSObject
@end

View File

@@ -0,0 +1,7 @@
#import "Point.h"
@implementation Point {
float _x;
float _y;
}
@end

View File

@@ -0,0 +1,11 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCase(TestBase):
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.m"))
self.expect("frame var -P1 p", substrs=["_x = 0", "_y = 0"])

View File

@@ -0,0 +1,7 @@
#import "Point.h"
int main() {
Point *p = [Point new];
// break here
return 0;
}