步骤一:查找需要attach的进程
# ps aux|grep prm
步骤二:使用gdb attach到进程
# gdb attach 8930
步骤三:重新定向输出日志
(gdb) call close(1)
$1 = 0
(gdb) call close(2)
$2 = 0
(gdb) shell tty
/dev/pts/0
(gdb) call open("/dev/pts/0",2)
$3 = 1
(gdb) call open("/dev/pts/0",2)
步骤四:立即输出打印消息设置
(gdb) call setbuf(stdout, 0)
$5 = -1237187808
(gdb) call printf("testetete\r\n")
testetete
$6 = 11