0%

Linux Debugging Tools

Linux 调试工具

printf

#ifdef UNIT_TESTING
#define TRACE(flag, format) if(global_debug & flag) printf format
#else
#define TRACE(flag, format)
#endif

需要重新编译以及影响执行时间

strace

Monitor User Application and Kernel.

$ strace -c find /etc -name xorg.conf

Performance Analysis

gprof

  • compile option -gp
  • make
    $(CC) $(LDFLAGS) -pg -o $@ $(OBJS)
  • Profile
    gprof <options> <exec file> gmon.out

GDB - GNU DeBugger

Ref

  1. Section 9: Linux Debugging Tools