zou*_*oul 33 debugging perl gdb
我有一个运行的Perl进程被卡住,我想用调试器戳到里面看看有什么问题.我无法重启这个过程.我可以将调试器附加到正在运行的进程吗?我知道我能做到gdb -p,但gdb对我没有帮助.我试过Enbugger,但失败了:
$ 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)
Run Code Online (Sandbox Code Playgroud)
我做错了吗?还有其他选择吗?
PS如果您认为自己可以从连接到正在运行的进程的调试器中受益,则可以插入由SIGUSR1触发的调试器后门:
use Enbugger::OnError 'USR1';
Run Code Online (Sandbox Code Playgroud)
然后你就可以简单地kill -USR1 pid将你的进程跳转到调试器中.
rur*_*ban 11
首先,如果你想用gdb检查它,请使用DEBUGGING perl.
请定义"卡住".忙碌或非忙碌等待(CPU高或低),是否吃东西?在1时它正忙着等待.从5.15开始,我经常在Perl_hfree_next_entry()中的HV损坏等待(无休止的循环).非忙等待通常等待阻塞IO读取.
我明白了:
`0x00007fba15ab35c1 in Perl_runops_debug () at dump.c:2266`
`2266 } while ((PL_op = PL_op->op_ppaddr(aTHX)));`
Run Code Online (Sandbox Code Playgroud)
并且可以检查所有内容,而不仅仅是使用简单的perl调试器.使用非线程perl,您必须输入更少.
`(gdb) p Perl_op_dump(PL_op)`
Run Code Online (Sandbox Code Playgroud)
等等.
如果你必须使用perl:在pp_stub函数中输入Enbugger runloop不是一个好主意,你应该在dump.c中的主runloop中.将断点设置为显示的行.
eval声音中的"对象0x3的错误"就像上下文中的内部损坏一样,所以你应该看一下cx和堆栈指针.可能是因为你在糟糕的环境中开始了它.
我从来没有使用过gdb,但也许你可以从strace中得到一些有用的东西?
strace -f -s512 -p <PID>
Run Code Online (Sandbox Code Playgroud)
http://metacpan.org/pod/App::Stacktrace"perl-stacktrace 为给定的Perl进程打印Perl线程的Perl堆栈跟踪.对于每个Perl帧,将打印完整的文件名和行号."
| 归档时间: |
|
| 查看次数: |
6648 次 |
| 最近记录: |