Debugging and performance analysis tools (LINUX). PROGRAM DEBUGGING AND PERFORMANCE TOOLS ======================================= gdb to attach to a running program: $ gdb progname pid ddd graphical debugger totalview graphical debugger gprof where a program spends its time strace watch all syscalls a program makes if you didn't write the program, this is probably your best bet time summarize system resource usage (time,mem,I/O) /usr/bin/time gcov profiling tool .. frequency of lines executed coverage testing - prove that every line is executed, branch probabilities, function summaries (example: 1. gcc -fprofile-arcs -ftest-coverage x.c 2. a.out 3. gcov x.c 4. cat x.c.gcov) memprof memory profiling (gui) valgrind memory debugger ccmalloc memory profiling Electric Fence (compile with -lefence) - use for memory overruns leak-analyze & LeakCheck - memory usage debugger mpatrol & mptrace - debugging for dynamically allocated memory purify commercial package from Rational SYSTEM PERFORMANCE ANALYSIS TOOLS ================================= vmstat virtual memory statistics free display free and used memory top display top cpu processes files in /proc files used as interface to kernel data structures examples: cpuinfo,stat procinfo display system status - gathered from /proc ps report process status ksysguard Task Manager and Performance Monitor like windows performance monitor (process table and histogram of system load, memory) sysstat sar system activity information Statistics include I/O transfer rates, paging activity, interrupts, network activity, memory and swap space utilization, CPU utilization, kernel activities and TTY statistics iostat CPU and I/O stats mpstat Processor related stats (works on SMP machines) NETWORK ======= ping send echo request to network host netstat print net connections, routing tables, etc. traceroute print the route to a network host dig (nslookup) whois FILE COMMANDS ============= ldd print shared library dependencies