Reputation: 556
In Xcode, you can set breakpoints with conditions that evaluate the description of the thrown exception to determine whether or not to stop on that breakpoint. This is particularly helpful when working with Core Data, since Core Data throws exceptions internally as a control flow mechanism, and you want to stop on your exceptions, but not Core Data's. (Note: if you're wondering how to filter exceptions as described, it's answered on the SO question Ignore certain exceptions when using Xcode's All Exceptions breakpoint).
However, these filters often rely on the contents of a register, since the address of the exception is stored there. In the simulator (running on Intel architecture), the register is $eax
, but on the device (ARM architecture) it's $r0
.
Is it possible to craft an expression that differentiates between the two architectures so that one expression uses the correct register regardless of architecture currently in use?
Upvotes: 3
Views: 740
Reputation: 15375
lldb provides convenience register names for architectures that pass values in registers -- arg0
for the first argument, for instance. However, the standard i386 ABI does not pass arguments in registers, they are passed on the stack (given the small number of general purpose registers available, this is not surprising).
The fact that eax
(a volatile/non-callee-saved reg in the i386 ABI) has a value of relevance on entry to objc_exception_throw
shows that the Objective-C runtime (libobjc
) is doing some non-standard function calls between its internal routines, likely for efficiency. You couldn't call a routine using a non-standard ABI like this from another module.
If you were talking about two ABIs that do pass arguments in registers, say x86_64 and arm, then you'd be fine with lldb's arg0
convenience variable.
If you were using lldb on the command line you could write a python function that gets r0
or eax
, depending on the architecture, and gets the exception name to decide whether the breakpoint should continue or not. But I don't think Xcode (today) gives you a way to put a python command on a breakpoint and control whether the process resumes or not.
Upvotes: 1