Linux Debug tools

1. gdb -- The GNU Debugger

gdb attach [pid] -- debug a running process


2. valgrind -- a suite of tools for debugging and profiling programs

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


3. strace - trace system calls and signals

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


4. pstack - print a stack trace of a running process

It's often used to check the stack of hung process.


5. mtrace, muntrace - malloc debugging

The  function  mtrace()  installs  handlers for malloc(), realloc() and free().  The function muntrace() disables these handlers.
The environment variable MALLOC_TRACE defines a file where mtrace() writes its output.  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.


6. dmesg - print or control the kernel ring buffer

Check the error message of all kind of program, especail for third-party program.


7. binutils -- a tools set

* ld - the GNU linker.

* as - the GNU assembler.

* addr2line - Converts addresses into filenames and line numbers.

* ar - A utility for creating, modifying and extracting from archives.

* c+filt - Filter to demangle encoded C+ symbols.

* gprof - Displays profiling information.

* nlmconv - Converts object code into an NLM.

* nm - Lists symbols from object files.

* objcopy - Copys and translates object files.

* objdump - Displays information from object files.

* ranlib - Generates an index to the contents of an archive.

* readelf - Displays information from any ELF format object file.

* size - Lists the section sizes of an object or archive file.

* strings - Lists printable strings from files.

* strip - Discards symbols.

* windres - A compiler for Windows resource files.


8. ldd - print shared library dependencies


9. ld.so, ld-linux.so * - dynamic linker/loader


---------------------------------------------------


10.lsof - list open files

Very useful to check if fd leak.


11. netstat  -  Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships


12. iostat  -  Report  Central  Processing Unit (CPU) statistics and input/output statistics for devices and partitions.


13. vmstat - Report virtual memory statistics

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值