linux strace调试用法

1.查看函数系统调用
例子:test.c
#include 

int main(){
  printf("Test strace!!!\n");

}

# gcc test.c -o test
# strace ./test
//打印
execve("./test.c", ["./test.c"], 0x7ffffc5f4820 /* 19 vars */) = -1 EACCES (Permission denied)
fstat(2, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 3), ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(2, "strace: exec: Permission denied\n", 32strace: exec: Permission denied
) = 32
getpid()                                = 23900
exit_group(1)                           = ?
+++ exited with 1 +++

2.查看某个进程系统做了什么
# strace -p 20920

3.查看为什么连接不到服务器
# strace -e poll,select,connect,recvfrom,sendto nc www.bing.com 80  

 

你可能感兴趣的:(linux,基础知识)