Linux Debug tools

来源:互联网 发布:js api 编辑:程序博客网 时间:2024/06/05 06:08

valgrind– a suite of tools for debugging and profiling programs

Very powerful tool to debug linux program,just for x86 platform

strace -trace system calls and signals

In the simplest case strace runs thespecified command until it exits. It intercepts and records the system calls which are called by a process and the signalswhich are received by a process. The name of each system call, itsarguments and its return value are printed on standard error or to the file specifiedwith the -o option.

pstack -print a stack trace of a running process

It’s often used to check the stack of hungprocess.

mtrace, muntrace - malloc debugging

The function mtrace() installs handlers for malloc(), realloc() and free(). The functionmuntrace() disables these handlers.
The environment variable MALLOC_TRACE defines a file where mtrace() writes itsoutput. This file must be writable to the user or mtrace()will do nothing. If the file is not empty it will be truncated.

Usage: call the two function before and after the code you want to pay attention on.