Skip to content

Instantly share code, notes, and snippets.

@prepor
Created December 4, 2009 08:52
Show Gist options
  • Save prepor/248914 to your computer and use it in GitHub Desktop.
Save prepor/248914 to your computer and use it in GitHub Desktop.
From http://www.scribd.com/doc/23548865/Debugging-Ruby
lsof
list open files
lsof -nPp <pid>
-n
Inhibits the conversion of network numbers to host names for
network files.
-P
Inhibits the conversion of port numbers to port names for network
files
strace
trace system calls and signals
strace -cp <pid>
-c
Count time, calls, and errors for each system call and report a summary on program exit.
-p pid
Attach to the process with the process ID pid and begin tracing.
strace -ttTp <pid> -o <file>
-t
Prefix each line of the trace with the time of day.
-tt
If given twice, the time printed will include the microseconds.
-T
Show the time spent in system calls. This records the time difference between the beginning and the end of each system call.
-o filename
Write the trace output to the file filename rather than to stderr.
tcpdump
dump traffic on a network
tcpdump -i eth1 -s 1500 -nqA tcp dst port 80
tcpdump -i eth0 -s 1500 -nqA tcp dst port 3306
tcpdump -i eth1 -s 1500 -w <file> tcp dst port 80
-i <eth>
Network interface.
-s <len>
Snarf len bytes of data from each packet.
-n
Don't convert addresses (host addresses, port numbers) to names.
-q
Quiet output. Print less protocol information.
-A
Print each packet (minus its link level header) in ASCII.
-w <file>
Write the raw packets to file rather than printing them out.
<expr>
libpcap expression, for example:
tcp src port 80
tcp dst port 3306
google-perftools
Google’s CPU profiler
pprof ./myapp /tmp/myprof
ltrace
trace library calls
ltrace -cp <pid> ltrace -ttTp <pid> -o <file>
ltrace/libdl (http://github.com/ice799/ltrace/tree/libdl)
trace dlopen’d library calls
ltrace -F <conf> -bg -x <symbol> -p <pid>
-b
Ignore signals.
-g
Ignore libraries linked at compile time.
-F <conf>
Read prototypes from config file.
-x <sym>
Trace calls to the function sym.
-s <num>
Show first num bytes of string args.
gdb
the GNU debugger
gdb <program> gdb <program> <pid>
perftools.rb (http://github.com/tmm1/perftools.rb)
google-perftools for ruby
gdb.rb (http://github.com/tmm1/gdb.rb)
gdb with MRI hooks
gdb.rb <pid>
bleak_house (http://github.com/fauna/bleak_house)
ruby memory leak detector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment