NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Using Strace to Debug Code
Topic: GNU/Linux   Posted:2006-03-24
Printer Friendly: Print

spacerspacer
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.networking7by24.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.




Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS