重现步骤:
1.安装nginx
2.启动nginx进程
3.卸载nginx,删除磁盘上的文件
4.安装nginx
5.导致无法gdb attach pid
1.查询进程启动时间
[[email protected]_JS_011_174 home]# ps -p 181300 -o lstart
STARTED
Wed Dec 10 12:42:52 2014
2.查询文件时间
[[email protected]_JS_011_174 home]# stat /usr/sbin/nginx
File: `/usr/sbin/nginx‘
Size: 1713256 Blocks: 3360 IO Block: 4096 regular file
Device: 802h/2050d Inode: 27265 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-01-27 16:42:42.000000000 +0800
Modify: 2014-12-09 13:26:43.000000000 +0800
Change: 2014-12-11 03:46:11.000000000 +0800
3.虽然是相同版本的nginx,进程启动后却覆盖了原先的文件,进程启动时间比磁盘文件最后修改时间早,导致进程/pro/pid/exe的软连接和磁盘文件已经对不上号了,无法直接gdb attach该进程
[[email protected]_JS_011_174 home]# gdb -p 181300
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-64.el6_5.2)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Attaching to process 181300
/usr/sbin/nginx (deleted): No such file or directory.
(gdb) bt
#0 0x0050e7ea in ?? ()
Cannot access memory at address 0x8a70ff24
4.安装相应版本的debuginfo
5.用gdb /proc/181300/exe 181300可成功attach进程