[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:24:05 PST 2018


jingham added a comment.

For tests that run processes I don't think lit has any advantages over the dotest tests.  For tests of a facility that's explicitly going to provide SB API's, testing them with dotest.py which is set up to be convenient to do SB API testing seems the correct thing to do.  I think this test is fine as it, except for the inline comment about using run_to_source_breakpoint.

This seems like it is two patches, one fixing the NSCallStackArray data formatter, and one extracting fields from NSException.  Is that right.  I'm more asking to make sure I'm not missing something about this patch.

This looks fine to me, you might explore getting the offsets from the NSException type - that should be generally available since we can read it from the ObjC runtime even if we don't get it from debug info.



================
Comment at: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py:29-38
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+        lldbutil.run_break_set_by_file_and_line(
+            self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
----------------
All this (and the self.line calculation) can be replaced by:

lldbutils.run_to_source_breakpoint("// Set break point at this line.", lldb.SBFileSpec("main.m"))


================
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);
----------------
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.


https://reviews.llvm.org/D43884





More information about the lldb-commits mailing list