tags:

views:

96

answers:

2

I'm trying to put the equivalent of asm{int 3} (or similar) into my iPhone program. My goal is to have Xcode stop exactly on the offending line, without having to fiddle with the call stack (so _Debugger doesn't sound like it would do, not that I could find which framework it's in anyway...), and leave me able to resume execution (which is why I'm not happy with assert).

(I'm used to both these behaviours on other systems, and I'd like to reproduce them on iOS.)

My best attempt so far has been this:

asm volatile("bkpt 1");

This stops Xcode on the line in question, but when I try to continue with Cmd+Alt+P, Xcode appears to run the BKPT again. And if I use Shift+Cmd+O, I just get this:

Watchdog has expired.  Remote device was disconnected?  Debugging session terminated.

(Needless to say, the remote device IS still connected.)

I don't have a huge amount of experience with iOS, Mac, ARM, gdb, or gcc's asm stuff. So I'm stumped already. Is there some way of getting iOS and Xcode to do what I want?

(I don't know if it makes a difference but judging by the instruction size my program is ARM code.)

[This question appeared originally under another title. I've edited it, hopefully to make things clearer.]

+1  A: 

raise(SIGTRAP) is a relatively portable way to have an "in code" breakpoint.

Logan Capaldo
A: 

Me too. I have put up some code that does what we want + an explanation of what we want at http://iphone.m20.nl/wp/ - it's the frist post so you won't have to look too hard.

Steven Kramer