如何调试perl脚本的fork [英] How to debug perl scripts that fork

查看:482
本文介绍了如何调试perl脚本的fork的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在emacs中使用perldb来调试Perl脚本(在Linux上)。工作很好,直到我调试一个脚本的叉子。如果我的脚本执行fork,我得到这个:

  #########叉,但做不知道如何创建一个新的TTY。 ######### 
由于两个调试器对同一TTY进行了争用,输入严重纠缠。

我知道如何将输出切换到xterms
和OS / 2控制台中的其他窗口。对于手动切换,将创建的TTY
的名称放在$ DB :: fork_TTY中,或者定义返回此函数的函数DB :: get_fork_TTY()。

在类UNIX系统中,可以通过键入tty来获取给定窗口
的TTY名称,并通过sleep 1000000将该TTY从shell断开。

我真的希望能够选择一个进程(无论是父或子),并继续调试该进程,同时允许另外继续畅通无阻。扩展目标将是明确地继续调试BOTH进程的一种方式,也许在emacs中打开控制和代码窗口的其他框架。但是能够干净地继续调试其中一个将是一个大胜利。



有没有办法在perldb中执行此操作?我试图跟随这个消息中的建议,但没有任何地方。



还是需要一些其他的Perl调试工具?如果后者,Perl调试器为多进程调试提供最佳支持?

解决方案

由于很可能你在xterm或类似的情况下运行,您可能被Perl调试器对xterm的相当狭窄的看法所困扰。



为字符串xterm。它想在 TERM 环境变量中看到 xterm 。不是 gnome-terminal 。不是 xterm-256color 。只需 xterm



运行方式:

  TERM = xterm perl -d ... 

确保它得到照片。我只想到在Perl调试器上十分钟的时间之后,一个人出来。



似乎很高兴产生大量的xterm窗口,似乎不是很好的清洁顺便说一下,当它们退出时,他们出来。


I use perldb in emacs for debugging Perl scripts (on Linux). Works great, until I'm debugging a script that forks. If my script executes a "fork", I get this:

######### Forked, but do not know how to create a new TTY. #########
  Since two debuggers fight for the same TTY, input is severely entangled.

  I know how to switch the output to a different window in xterms
  and OS/2 consoles only.  For a manual switch, put the name of the created TTY
  in $DB::fork_TTY, or define a function DB::get_fork_TTY() returning this.

  On UNIX-like systems one can get the name of a TTY for the given window
  by typing tty, and disconnect the shell from TTY by sleep 1000000.

I would really like to be able to choose one process (either the parent or the child) and continue debugging that process, while allowing the other to continue unimpeded. A stretch goal would be a way to unambiguously continue debugging BOTH processes, perhaps opening additional frames in emacs for control and code windows. But being able to cleanly continue debugging one of them would be a big win.

Is there a way to do this in perldb? I tried to follow the suggestion in this message, but got nowhere with it.

Or do I need some other Perl debugging tool? If the latter, which Perl debugger provides best support for multi-process debugging?

解决方案

Since it's quite likely that you are running under an xterm or similar, you might be being bitten by the Perl debugger's rather narrow view of what an "xterm" is.

It's specifically looking for the string "xterm". It wants to see xterm in the TERM environment variable. Not gnome-terminal. Not xterm-256color. Just xterm.

Run with:

TERM=xterm perl -d ...

to make sure it gets the picture. I only figured that one out after ten minutes of grumping at the Perl debugger.

It seems very happy to spawn tons of xterm windows and doesn't seem very good at cleaning them up when it exits, by the way.

这篇关于如何调试perl脚本的fork的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆