[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

David Chisnall via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 16 02:20:05 PDT 2023


theraven added inline comments.


================
Comment at: lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp:131
+                                        ExecutionContext &exe_ctx) {
+  // TODO: This function is supposed to check whether an ObjC selector is
+  // present for an object. Might be implemented similar as in the Apple V2
----------------
sgraenitz wrote:
> theraven wrote:
> > I'm not sure how this is meant to work.  I'd expect this to call one of the runtime's introspection functions.  I believe the Apple version has variants of these that run without acquiring locks, which can be used in the debugger.  We can add these quite easily if necessary.
> The Apple V2 runtime has two ways to do it: https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp#L1179 I experimented with the one that doesn't require `void *gdb_class_getClass(void*)` from the runtime library, but the JIT kept on crashing. So, for this first version I opted for a minimal implementation that doesn't do any selector checks. Let's look at it in another review.
Can you open bugs against the runtime for the gdb_* symbols that we need?  I will add them.

The other method will crash on small objects because they don't have an isa pointer, their isa is in the low 1-3 bits of the object pointer, indexing into a table in the runtime.


================
Comment at: lldb/test/Shell/Expr/objc-gnustep-print.m:68
+//
+// MEMBERS_OUTSIDE: (lldb) p t->_int
+// MEMBERS_OUTSIDE: (int) $0 = 0
----------------
sgraenitz wrote:
> theraven wrote:
> > It's not clear from this test if it's correctly computing the offsets.  I suspect that it isn't, since I don't see any reference to the ivar offset variables.
> What exactly would you expect to see in the output?
If the offsets are all wrong, this will still work if it happens to land within zeroed memory, which is quite likely.  It would be good to have a method that set all of the ivars to something and then check for those values explicitly.  Or check for `(char*)t->{ivar} - (char*)t` and make sure that this is the right value (this will change between 32/64/128-bit platforms).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146154/new/

https://reviews.llvm.org/D146154



More information about the lldb-commits mailing list