[Lldb-commits] [lldb] 23b0564 - [lldb] Fix AppleObjCDeclVendor for classes which have no methods (#145452)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 24 10:58:09 PDT 2025
Author: Dave Lee
Date: 2025-06-24T10:58:06-07:00
New Revision: 23b0564800f6308ae4b54f0fbf60759ab8f7eb80
URL: https://github.com/llvm/llvm-project/commit/23b0564800f6308ae4b54f0fbf60759ab8f7eb80
DIFF: https://github.com/llvm/llvm-project/commit/23b0564800f6308ae4b54f0fbf60759ab8f7eb80.diff
LOG: [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.
Added:
lldb/test/API/lang/objc/class-without-methods/Makefile
lldb/test/API/lang/objc/class-without-methods/Point.h
lldb/test/API/lang/objc/class-without-methods/Point.m
lldb/test/API/lang/objc/class-without-methods/TestObjCClassWithoutMethods.py
lldb/test/API/lang/objc/class-without-methods/main.m
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index dac93931bab1b..cc0c9e728964e 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -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;
}
}
diff --git a/lldb/test/API/lang/objc/class-without-methods/Makefile b/lldb/test/API/lang/objc/class-without-methods/Makefile
new file mode 100644
index 0000000000000..f6f336c01bbc5
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/Makefile
@@ -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
diff --git a/lldb/test/API/lang/objc/class-without-methods/Point.h b/lldb/test/API/lang/objc/class-without-methods/Point.h
new file mode 100644
index 0000000000000..a352259954eff
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/Point.h
@@ -0,0 +1,4 @@
+#import <objc/NSObject.h>
+
+ at interface Point : NSObject
+ at end
diff --git a/lldb/test/API/lang/objc/class-without-methods/Point.m b/lldb/test/API/lang/objc/class-without-methods/Point.m
new file mode 100644
index 0000000000000..770a857c80dc7
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/Point.m
@@ -0,0 +1,7 @@
+#import "Point.h"
+
+ at implementation Point {
+ float _x;
+ float _y;
+}
+ at end
diff --git a/lldb/test/API/lang/objc/class-without-methods/TestObjCClassWithoutMethods.py b/lldb/test/API/lang/objc/class-without-methods/TestObjCClassWithoutMethods.py
new file mode 100644
index 0000000000000..f83b0352bf1a9
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/TestObjCClassWithoutMethods.py
@@ -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"])
diff --git a/lldb/test/API/lang/objc/class-without-methods/main.m b/lldb/test/API/lang/objc/class-without-methods/main.m
new file mode 100644
index 0000000000000..0b6e14371bc59
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/main.m
@@ -0,0 +1,7 @@
+#import "Point.h"
+
+int main() {
+ Point *p = [Point new];
+ // break here
+ return 0;
+}
More information about the lldb-commits
mailing list