Re: why are conditional breakpoints SO SLOW?
Re: why are conditional breakpoints SO SLOW?
- Subject: Re: why are conditional breakpoints SO SLOW?
- From: Jens Alfke <email@hidden>
- Date: Tue, 18 Mar 2014 14:52:39 -0700
On Mar 18, 2014, at 11:04 AM, Jonas Maebe <email@hidden> wrote:
>> then surely the debugger is capable of inserting such an if-test in the code itself, isn’t it?
>
> There are research papers about doing exactly that and it does improve performance a lot. It's far from trivial though, and at least on x86 it's not even always (safely) possible.
Yeah. Remember that the debugger is patching your executable at runtime. It's easy to replace one instruction with a break/trap instruction at the location of the breakpoint. It would be a lot harder to insert an entire arbitrary-size block of code representing the condition. There usually wouldn't be room to replace that many instructions without overwriting the next basic block in the code, and there might not even be enough room to insert a subroutine call to some external location where that code would be written. Not to mention the necessity of preserving all the CPU state around the test — basically you're talking about modifying the structure of a function after it's already been compiled and optimized.
It's asking to much to make the debugger jump through these sorts of crazy hoops just so you can avoid having to insert an if() statement in your loop :)
(Actually it just occurred to me that this would be a lot more feasible in a JIT environment, where the compiler is generating and modifying code at runtime anyway. JIT compilers will already replace functions with customized or better-optimized versions; such a compiler could also insert a test-and-break expression into the middle of a function and recompile it that way. But that's not much use to you since this isn't Java or C#.)
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden