-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Fix AppleObjCDeclVendor for classes which have no methods #145452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kastiglione
merged 3 commits into
llvm:main
from
kastiglione:lldb-Fix-AppleObjCDeclVendor-for-classes-which-have-no-methods
Jun 24, 2025
Merged
[lldb] Fix AppleObjCDeclVendor for classes which have no methods #145452
kastiglione
merged 3 commits into
llvm:main
from
kastiglione:lldb-Fix-AppleObjCDeclVendor-for-classes-which-have-no-methods
Jun 24, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
@llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) ChangesFix the rare case where an ObjC class has ivars but no methods. The fix is to not early Full diff: https://github.com/llvm/llvm-project/pull/145452.diff 6 Files Affected:
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index dac93931bab1b..1c120fcf2c356 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -552,10 +552,9 @@ 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))
- return false;
+ if (base_method_list)
+ if (!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..85c0cd6c895b3
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/Point.h
@@ -0,0 +1,8 @@
+#import <objc/NSObject.h>
+
+@interface Point : NSObject {
+@public
+ float _x;
+ float _y;
+}
+@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..eb5888e5b599f
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/Point.m
@@ -0,0 +1,4 @@
+#import "Point.h"
+
+@implementation Point
+@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..587f22dedadf7
--- /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 = 11", "_y = 22"])
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..f3241f46bbe5f
--- /dev/null
+++ b/lldb/test/API/lang/objc/class-without-methods/main.m
@@ -0,0 +1,9 @@
+#import "Point.h"
+
+int main() {
+ Point *p = [Point new];
+ p->_x = 11;
+ p->_y = 22;
+ // break here
+ return 0;
+}
|
bulbazord
approved these changes
Jun 24, 2025
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
Outdated
Show resolved
Hide resolved
This ensures the debug info in main.o does not contain the ivars for Point.
JDevlieghere
approved these changes
Jun 24, 2025
DrSergei
pushed a commit
to DrSergei/llvm-project
that referenced
this pull request
Jun 24, 2025
…m#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.
anthonyhatran
pushed a commit
to anthonyhatran/llvm-project
that referenced
this pull request
Jun 26, 2025
…m#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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.