We wrote about strace in this article to find the files a program opened. The manpage for strace is here. Strace can be used to debug code as well. We have an application we are writing in REALbasic. In case you haven’t heard of this before, it is a cross platform compiler that is a lot like Microsoft Visual Basic. We are able to develop on Mac OS X, but choose Windows and GNU/Linux platforms as targets. GNU/Linux is particularly difficult to target usually. For a simple application that isn’t a Web app, REALbasic is a nice tool. Further, REALbasic comes completely free for GNU/Linux, at least for the standard edition. REALbasic does this by using the GUI language of the target machine, on GNU/Linux this is GTK 2.0. For a screen shot of the app we are writing, running on XP, Mac OS X, and Centos 4, all at the same time, see this. This app will be available for free at the obvious .com in the future sometime. One problem, though, with all cross-platform coding is that there will be some issues with functions that don’t translate for some reason or another. After a couple hours of struggling with an app that would run just fine on Mac OS X, but not on GNU/Linux, we resorted to strace:
[usr-1@srv-1 mcj]$ /usr/bin/strace ./mcjl execve("./mcjl", ["./mcjl"], [/* 22 vars */]) = 0 uname({sys="Linux", node="srv-1.example.com", ...}) = 0 brk(0) = 0x823f000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 . . . gettimeofday({1143236282, 103693}, NULL) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 4390 detached [usr-1@srv-1 mcj]$ |
Hrmphh. Gettimeofday seems to be the culprit. One of our fields pulled the current date on load:
datefield.text = date.sqldatetime |
Changing this to:
datefield.text = "enter date and time" |
Works fabulously. There is probably another function that will port better; however, the app works fine now.