我有一個正在運行的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
,你的進程將跳入調試器。