objective c - Xcode/LLDB: How to get information about an exception that was just thrown? -
ok, imagine breakpoint in objc_exception_throw
has triggered. i'm sitting @ debugger prompt, , want more information exception object. find it?
the exception object passed in first argument objc_exception_throw
. lldb provides $arg1
..$argn
variables refer arguments in correct calling convention, making simple print exception details:
(lldb) po $arg1 (lldb) po [$arg1 name] (lldb) po [$arg1 reason]
make sure select objc_exception_throw
frame in call stack before executing these commands. see "advanced debugging , address sanitizer" in wwdc15 session videos see performed on stage.
outdated information
if you're on gdb, syntax refer first argument depends on calling conventions of architecture you're running on. if you're debugging on actual ios device, pointer object in register r0
. print or send messages it, use following simple syntax:
(gdb) po $r0 (gdb) po [$r0 name] (gdb) po [$r0 reason]
on iphone simulator, function arguments passed on stack, syntax considerably more horrible. shortest expression construct gets *(id *)($ebp + 8)
. make things less painful, suggest using convenience variable:
(gdb) set $exception = *(id *)($ebp + 8) (gdb) po $exception (gdb) po [$exception name] (gdb) po [$exception reason]
you can set $exception
automatically whenever breakpoint triggered adding command list objc_exception_throw
breakpoint.
(note in cases tested, exception object present in eax
, edx
registers @ time breakpoint hit. i'm not sure that'll case, though.)
added comment below:
in lldb, select stack frame objc_exception_throw
, enter command:
(lldb) po *(id *)($esp + 4)
Comments
Post a Comment