一、lsof 查找系统打开的文件
经典用法。查看进程打开的文件句柄。
案例:我的一个服务进程,运行一段时间后,在64位机器上运行正常,在32位机器上运行不正常。用lsof一看。有打开的文件未关闭,因64位机器默认进程打开文件数是100万,因而没有出现问题。
其他用法。
1、查看某个文件被哪个进程打开。
2、查看某个文件系统被哪个进程使用。
二、strace ltraceftrace
经典用法。进程无法启动,软件运行速度突然变慢,程序的"SegmentFault"的检查。
三、GDB
这个大家经常用,只讲高级用法。
调试多进程程序,
调试多线程
GDB对信号的处理
Electric-Fence 是一组用于在基于 gdb的环境中检测缓冲区上溢出或下溢出的库。在发生错误的内存访问时,这个工具(与 gdb 结合)会准确地指出源代码中导致问题的指令。
四、Valgrind
很好的工具,发现一切与内存有关的问题。
小提示:–db-attach=yes 在首次遇到内存问题时,将调用gdb进行调试。
五、 binutil
binutil是一系列的工具,你可能根本不知道它们的存在,但是没有它们你却寸步难行。Binutil包括下列工具:
ld - the GNU linker.
as - the GNU assembler.
addr2line - Converts addresses into filenames and linenumbers.
ar - A utility for creating, modifying and extracting fromarchives.
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 objectfile.
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.