我有一个正在运行的Perl进程被卡住了,我想用调试器在里面戳,看看有什么问题。我无法重新启动该过程。我可以将调试器连接到正在运行的进程吗?我知道我可以做gdb -p
,但gdb
不帮助我。我试过Enbugger,但没有成功如何将调试器附加到正在运行的Perl进程?
$ perl -e 'while (1) {}'&
[1] 86836
$ gdb -p 86836
…
Attaching to process 86836.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ............................. done
Reading symbols for shared libraries + done
0x000000010c1694c6 in Perl_pp_stub()
(gdb) call (void*)Perl_eval_pv("require Enbugger;Enbugger->stop;",0)
perl(86836) malloc: *** error for object 0x3: pointer being realloc'd was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff8269d82a in __kill()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (Perl_eval_pv) will be abandoned.
(gdb)
上午我做错了?还有其他选择吗?
P.S.如果你认为你可以从连接到正在运行的进程自己一个调试器中获益,您可以通过插入触发SIGUSR1调试后门:
use Enbugger::OnError 'USR1';
然后,你可以简单地kill -USR1 pid
,你的进程将跳入调试器。