Photoluna, for iPhone and iPod Touch, is on sale right now for 50% off (on top of the every-day 20% discount from its release price). This sale will only last a few days, so act quickly!
You are currently browsing Dan’s articles.
Photoluna, for iPhone and iPod Touch, is on sale right now for 60% off. This sale will only last a few days, so act quickly!
From time to time, it’s useful to break into the debugger programmatically. The simplest way to accomplish this on Mac OS X and iPhone OS is with raise(SIGINT), to wit:
#define DebugBreak() raise(SIGINT)
There is one problem with this technique, however: the debugger (gdb) will break well inside the raise call (actually inside __kill called by kill called by raise), and more often then not will be unable to display the contents of local variables in the function that called raise(SIGINT).
The secret, of course, is to define an entirely inline version of raise(SIGINT). The implementation for raise is simple enough; kill is an even simpler wrapper around __kill.
int raise(int signo)
{
return kill(getpid(), signo);
}
int kill(pid_t pid, int signo)
{
return __kill(pid, signo, 1);
}
The final pieces, getpid and __kill, simply call system routines through the syscall mechanism.
So now we can update Matt Gallagher’s article by adding support for ARM (iPhone and iPod Touch) like so:
#if __ppc64__ || __ppc__
#define BSDebugBreak() \
do { \
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
: : : "memory","r0","r3","r4" ); \
} while (0)
#elif __i386__ || __x86_64__
#define BSDebugBreak() \
do {__asm__{"int $3\n" : : );} while (0)
#elif __arm__
#define BSDebugBreak() \
do { \
__asm__("mov r0, #20\nmov ip, r0\nsvc 128\nmov r1, #37\nmov ip, r1\nmov r1, #2\nmov r2, #1\n svc 128\n" \
: : : "memory","ip","r0","r1","r2"); \
} while (0)
#else // unknown architecture
#define BSDebugBreak() raise(SIGINT)
#endif
I have omitted Matt’s references to if(AmIBeingDebugged()) as I prefer to make that test optional and explicit in the client code rather than include it in the BSDebugBreak macro. I’ve also added a clause for unknown, future architectures (it is usually wise to assume another architecture is just over the horizon). My personal version of this macro definition has an #error directive in place of the raise(SIGINT) version.
In late June, we released Photoluna 1.0.1 to the iTunes App Store. Since then, we have been working hard on the next version (“1.1”). This upcoming release will likely require OS 3.0. The reason is fairly simple: We no longer have any devices available for testing that are running earlier versions, and it is not possible to “downgrade” an iPhone or iPod Touch once it has been upgrade to 3.0.
Stay tuned for more information about version 1.1 in the coming weeks, or follow us on Twitter!
It’s that time of year again, when all the faithful Mac OS X and iPhone developers make their way to San Francisco for Apple’s annual Worldwide Developer’s Conference. With the decline of MacWorld Boston/New York a few years ago, the WWDC has become one of Apple’s most public opportunities to announce new products. These are usually not the consumer products such as iMacs, iPods, or iWork software, but rather the cutting edge technology – especially new system software, and, since 2007, new iPhone models. This year will be focused on final preparations for the arrival of the next generation of Mac OS X system software, OS X 10.6 “Snow Leopard,” due later this year, and the next generation of iPhones and iPhone OS 3.0, most likely arriving in July – only a month away. The iPhone OS 3.0 application software developer kit (SDK) has been available to developers in a prerelease form since March, however it is certain that Apple has not yet revealed all its cards. The next iPhone is widely rumored to feature new, faster hardware (which will allow for more sophisticated applications), a magnetometer, and an upgraded camera that can take video as well as still photographs. Personally, the magnetometer (an electronic compass) is most compelling, and I have ideas I’m ready to implement for Photoluna just as soon as I have access to magnetometer APIs.
One thing that will be very different from WWDCs of recent years: No Steve Jobs keynote. Expect the same features and surprises of the past, but with less initial buzz.
The keynote is public, and I will be there and tweeting about the keynote for those who wish to follow along. The remainder of the conference, however, is confidential, so if my tweets become rather cryptic — well, now you know why.
For fellow developers going to WWDC – I look forward to seeing you there!
