Skip to content

Instantly share code, notes, and snippets.

@jschwinger233
Last active February 29, 2020 04:58
Show Gist options
  • Select an option

  • Save jschwinger233/f9b3a9eb2a2f59fb691ea3df09b0d170 to your computer and use it in GitHub Desktop.

Select an option

Save jschwinger233/f9b3a9eb2a2f59fb691ea3df09b0d170 to your computer and use it in GitHub Desktop.
strace -p$PID -fT -etrace=$SYSCAL -eread=$FD

今天查 bug, 查到最后败在了不会熟练使用 strace, 最后重启大法毁尸灭迹, 菜到口交.

总之 -p$PID attach 进程, -f trace 所有线程和子进程, -T 打印 syscal 的调用时间, -etrace=$SYSCAL 只追踪自己感兴趣的 syscall, -eread=$FD 只关注自己感兴趣的 fd 并且把所有 ascii 字符串打印出来, 如果我在三小时前能够熟练使用… 也没卵用, 反正接下去还是肯定查不出来, 太难了这次的 bug.

@LiBo 明查秋毫, 当我告诉他 strace etcdctl watch 的输出里连 read 都没有这种可怕的事情之后, 他只花了我吃一根冰淇淋的功夫就反应过来是只 trace 了主线程, tql, 而我就只会问人, 太菜了, API 程序员…

不过 -eread=$FD 的输出会把字符串折行, 方便人类阅读但是反而不好 grep 了, 所以还是直接用 -etrace=read 然后 -s1024 (--string-limit), 就方便 grep 了.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment