Debugging Tools

This is a list of UNIX tools that can be helpful in debugging. The list was taken from a never written FAQ item

top
Show resource (memory, CPU) usage of currently running application on your computer.

netstat
List open network sockets. To see a list of daemons:

netstat -a

lsof
List open files. Actually also lists open sockets.

gdb
GNU debugger. First start gdb, then start your application. If you now get a crash, you can do a backtrace (bt) or other useful things.

(gdb) run myapplication Starting program: /usr/local/bin/myapplication Reading symbols for shared libraries Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x0004000c 0x0044dbec in divide_by_zero (gdb) bt
 * 1) 0 0x0044dbec in divide_by_zero
 * 2) 1 0x004a3470 in execute
 * 3) 2 0x005132a4 in main

strace
Print system calls made by a program. This is useful to track which files are opened, since that happens using system calls.

The Mac OS X equivalent is ktrace.

ltrace
Print library calls made by a program

file
Determine the type of file.

ldd / otool
List linked libraries (Unix)

oTool (Mac)

strings
Extract readable strings from a binary file.

Other tools
lslk / fuser / stat / readlink ksymoops nm objdump strings / file od / hexdump time