[Lldb-commits] [PATCH] D43884: [lldb] Extract more fields from NSException values

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 1 10:41:19 PST 2018


jingham added inline comments.


================
Comment at: source/Plugins/Language/ObjC/NSException.cpp:57-64
+  auto name = process_sp->ReadPointerFromMemory(ptr + 1 * ptr_size, error);
+  if (error.Fail() || name == LLDB_INVALID_ADDRESS) return false;
+  auto reason = process_sp->ReadPointerFromMemory(ptr + 2 * ptr_size, error);
+  if (error.Fail() || reason == LLDB_INVALID_ADDRESS) return false;
+  auto userinfo = process_sp->ReadPointerFromMemory(ptr + 3 * ptr_size, error);
+  if (error.Fail() || reason == LLDB_INVALID_ADDRESS) return false;
+  auto reserved = process_sp->ReadPointerFromMemory(ptr + 4 * ptr_size, error);
----------------
kubamracek wrote:
> jingham wrote:
> > davide wrote:
> > > kubamracek wrote:
> > > > davide wrote:
> > > > > The fact we have to calculate this by hand is slightly annoying, but I guess that's a bug to fix another day.
> > > > I'll be happy to send follow-up patches. Do you have suggestions how to avoid these manual pointer calculations?
> > > The way we do that in swift (or well, we're trying to do) is that of using remote mirrors. I'm not really aware of an equivalent mechanism in Obj-C, FWIW, but we should definitely think about it and have a chat (if you want, I don't think you should be signed up for cleaning up this).
> > It looks like we generally have a type for NSException - it's an ObjC class so we'll read it out of the runtime if we can't get it from debug information.  You should be able to get the offsets from that rather than having to hand code them here.
> Does reading the offsets need to run the target or is it just inspecting memory?
Reading the whole runtime was too slow if done from lldb, since we're chasing pointers around, so we do this with some injected code.  So if you happen to be the first guy to ever ask about an ObjC type and its offsets, you might trigger this code.  If you aren't the first guy, then it's just inspecting memory.


https://reviews.llvm.org/D43884





More information about the lldb-commits mailing list