You are not logged in.

#1 2009-11-09 18:40:49

ezacaria
Member
Registered: 2007-12-10
Posts: 113

Debugging perl with ddd [SOLVED]

Hello,

I'm trying to debug a perl script with ddd, using an up to date Arch.

If I debug the script on text mode, everything  works fine:

perl -d script.pl argument1 ...

The problems begin when I use ddd:

ddd --perl -w script.pl

(one can specify the arguments before running the script)

It seems like ddd opens an interactive perl -d, but when it executes the script, I get

Daughter DB session started...
######### 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, OS/2
  consoles, and Mac OS X Terminal.app 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 get confused, because I'm not forking anything in the script, nor I'm opening any pipe or making a system call. I took it to the extreme, and erased everything in the script, except for couple of variable declarations - same result.
I assume that the fork is done when the first debugger session executes the script.

After googling around, I tried to include the following line in my script:

sub DB::get_fork_TTY { $ENV{fork_TTY} }

but it does not make a difference - well, I didn't quite understand the root of the problem so far, so this was out of desperation sad

The script can be debugged with ptkdb, but I would like to use ddd.

I thought I would ask here in case anyone has found this problem, before going to ddd's mail list.

Thanks!

Best regards,

Eduardo

Last edited by ezacaria (2009-11-12 07:46:27)

Offline

#2 2009-11-11 20:33:18

juster
Forum Fellow
Registered: 2008-10-07
Posts: 195

Re: Debugging perl with ddd [SOLVED]

It definitely looks as if ddd is forking itself!  When that happens both the child/parent debuggers have the same copy of the TTY and are fighting over it?  Don't know for sure, never used ddd, but I found this link sort of on accident that might explain it better: http://www.perlmonks.org/?node_id=128283

The author above mentions that you can create a new tty in an xterm with the following code:

sub DB::get_fork_TTY {
    open XT, q[3>&1 xterm -title 'Forked Perl debugger' -e sh -c 'tty 
+1>&3;\ sleep 10000000' |];
    $DB::fork_TTY = <XT>;
    chomp $DB::fork_TTY;
}

I think this way the forked child uses the xterm instead of fighting for the parent's terminal.

Offline

#3 2009-11-12 07:44:58

ezacaria
Member
Registered: 2007-12-10
Posts: 113

Re: Debugging perl with ddd [SOLVED]

Hello, juster

and thank you very much for the quick solution!

One small detail is the extraneous "+" marked in red. So the code should be:

sub DB::get_fork_TTY {
    open XT, q[3>&1 xterm -title 'Forked Perl debugger' -e sh -c 'tty 1>&3; sleep 10000000' |];
    $DB::fork_TTY = <XT>;
    chomp $DB::fork_TTY;
}

I tried it on VirtualBox+Arch, and it worked. I will probably try it also in my "real" Arch. The xterm pops up, but it seems that one can close it without interfering the debugging.
As a side note, this does not work in cygwin with the older ddd 3.3.9 (current version in Arch is 3.3.12)
I don't know if it's easy to build it manually in cygwin, but this is not critical at the moment, so I will mark this closed smile

Thanks again!

Best regards,

Eduardo

Offline

Board footer

Powered by FluxBB