[lldb-dev] sniffing the exception in objc_exception_throw
mayoff at dqd.com
Sun Jun 16 23:03:03 PDT 2013
When I don't put a breakpoint on objc_exception_throw, I get the
exception description in my console, along with addresses of the
return pointers in the call stack. These addresses aren't
particularly useful for debugging (for me, anyway).
When I put a breakpoint on objc_exception_throw to debug Objective-C
exceptions, I can inspect the call stack properly, but I don't get the
exception description in the console.
Setting a breakpoint command is no good because I need different
commands for each of the arm, i386, and x86_64 architectures. I want
to set up the breakpoint once as an Xcode user breakpoint.
Enrico Granata and Sean Callanan helped me implement a new command in
Python that works across all three architectures (thanks again!), and
asked that I send it to this mailing list.
command script import ~/Library/lldb/sniff_objc_exception_throw.py
def GetFirstArgumentAsValue(target, frame):
# Note: I assume the PC is at the first instruction of the
function, before the stack and registers have been modified.
espValue = frame.regs.GetChildMemberWithName("esp")
address = espValue.GetValueAsUnsigned() + target.addr_size
return espValue.CreateValueFromAddress('arg0', address,
def command(debugger, user_input, result, unused):
target = debugger.GetSelectedTarget()
frame = target.GetProcess().GetSelectedThread().GetFrameAtIndex(0)
description = GetFirstArgumentAsValue(target, frame).GetObjectDescription()
if description is None:
output = "I couldn't get the description of the exception being thrown."
output = "Description of exception being thrown: " + repr(description)
def __lldb_init_module(debugger, unused):
debugger.HandleCommand('command script add --function
More information about the lldb-dev