Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 1.83 KB

20170703.md

File metadata and controls

75 lines (51 loc) · 1.83 KB

strace

# run strace attached to pid with filter rules
strace -p <PID> -e trace=recvmsg,poll

Links:

valgrind

You must build the binary with the debug flag -g, I personally use -Og -g3 for debug optmization and to maximize the details;

# valgrind report
valgrind --leak-check=full --show-leak-kinds=all --show-reachable=yes \
    --track-origins=yes binary

# run helgrind tool
valgrind --tool=helgrind bin

Links:

GDB

# execute binary with arguments in gdb
gdb --args binary arg1 arg2 arg3
  • If segfault are driving you nuts, you can set a GDB environment variable called MALLOC_CHECK_, you get the following behaviors:
    • if set to 0: any detected heap corruption is silently ignored;
    • if set to 1: a diagnostic is printed on stderr;
    • if set to 2, abort is called immediately;
# in gdb console
set environment MALLOC_CHECK_ 2

Links:

addr2line

This program translate addresses into filename and linenumbers.

# example of usage
gcc teste -g -o app

objdump -d app

addr2line -f -e app 4004d8
# main
# /tmp/hello.c:3

Make