2014-06-07 1 views
3

처음에 나는 Devel::ebug이라는 전체 개념을 오해하고 그것을 어떻게 사용해야하는지 사과하고 싶습니다. 그래서 Devel :: ebug perl 모듈에 대한 실험을하고 싶습니다. 여기에 나는 몇 가지 예를 발견했다 : What is the perl equivalent of a bash -xv 그래서 나는 다음의 코드를 가져다가 조금 수정했다. 공식 문서 Devel::ebug CPAN에 따르면 프로그램 방법은로드 할 프로그램을 선택하므로 변경된 사항 만 있습니다. 나는 또한 파일을 한 같은 디렉토리에 stacktrace.pl : perl 's Devel :: ebug how to

#!/usr/bin/perl 

use strict; 
use warnings; 
use Devel::ebug; 
use Data::Dumper; 

my $ebug = Devel::ebug->new; 
# $ebug->program(shift); # OLD VALUE: 
$ebug->program($ARGV[0]); # NEW VALUE: 

$ebug->load; 

until ($ebug->finished) { 
    print "+++ file:", $ebug->filename, " line: ", $ebug->line, "\n"; 
    my $pad = $ebug->pad; 
    for my $var (sort keys %$pad) { 
     if (ref $pad->{$var}) { 
      for my $line (split /\n/, Data::Dumper->Dump([$pad->{$var}], [$var])) { 
       print "++ $line\n"; 
      } 
     } else { 
      print "++ $var = $pad->{$var}\n"; 
     } 
    } 
    for my $line ($ebug->codelines($ebug->line-3 .. $ebug->line-1)) { 
     next unless defined $line; 
     print "+ $line\n"; 
    } 
    print "+> ", $ebug->codeline, "\n"; 
    for my $line ($ebug->codelines($ebug->line+1 .. $ebug->line+3)) { 
     next unless defined $line; 
     print "+ $line\n"; 
    } 
    $ebug->step; 
} 

는 그럼으로이 파일을 저장 debugme.pl을 What is the perl equivalent of a bash -xv 페이지에서. 하지만 그 대신 What is the perl equivalent of a bash -xv 페이지에서 언급 한 출력의 난이 얻을 :

> ./stacktrace.pl debugme.pl 
./stacktrace.pl: exec failed: No such file or directory 
at /home/wakatana/perl5/lib/perl5/Devel/ebug.pm line 41 
Could not connect: Connection refused at /home/wakatana/perl5/lib/perl5/Devel/ebug.pm line 71. 

일부 추가 디버깅이 나를 지적 :

Proc::Background::Unix::_new(/home/wakatana/perl5/lib/perl5/Proc/Background/Unix.pm:47): 
47:   if ($pid = fork()) { 
    DB<7> s 
Proc::Background::Unix::_new(/home/wakatana/perl5/lib/perl5/Proc/Background/Unix.pm:49): 
49:   $self->{_os_obj} = $pid; 
######### 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. 

Proc::Background::Unix::_new(/home/wakatana/perl5/lib/perl5/Proc/Background/Unix.pm:54): 
54:   exec @_ or croak "$0: exec failed: $!\n"; 

첫째는 내가 어떻게 든 GNU 화면에서이 작업을 실행하고 있기 때문에 그것이 가정 새 TTY를 만들 수 없습니다. 그러나 그것은 문제가 아닙니다. 여기서 내가 무엇을 놓치고 있니?

PS는 : @Chankey Pathak를 주석에 대하여 :

b Proc::Background::Unix::_new 
c 

EDIT : PROC :: 배경 작업 할 때 문제가 발생 :: 유닉스 모듈의 출력을 상기 I는 다음 디버거 명령을 사용하여 얻을 수 있도록 보인다. 나는 터미네이터 아래에서이 명령을 내렸다.

> echo $$ 
18548 
> ps -elf | grep 18548 
0 S wakatana 18548 18546 0 80 0 - 6296 -  16:09 pts/5 00:00:00 bash 
0 R wakatana 18990 18548 0 80 0 - 4209 -  16:10 pts/5 00:00:00 ps -elf 
0 R wakatana 18991 18548 0 80 0 - 1958 -  16:10 pts/5 00:00:00 grep 18548 
> ps -elf | grep 18546 
0 S wakatana 18546 18254 0 80 0 - 17220 -  16:09 pts/3 00:00:00 xterm 
0 S wakatana 18548 18546 0 80 0 - 6296 -  16:09 pts/5 00:00:00 bash 
0 R wakatana 19004 18548 0 80 0 - 1959 -  16:10 pts/5 00:00:00 grep 18546 

> perl stacktrace.pl debugme.pl 
stacktrace.pl: exec failed: No such file or directory 
at /home/wakatana/perl5/lib/perl5/Devel/ebug.pm line 41 
Could not connect: Connection refused at /home/wakatana/perl5/lib/perl5/Devel/ebug.pm line 71. 

EDIT2 : 나는이 같은 perlmonks

+0

xterm 창에서 디버거를 실행한다. 도움이되는지 확인하십시오. –

답변

0

(STABLE), 좋아 :: ebug 작품에이 또한 크로스 게시 한 : 소켓에서 수신 대기 지배 공정있다 (xterm에 따라 상황은 동일합니다 그것은 위에 붙여 넣은 스크립트입니다) 디버거의 "사용자 인터페이스"비트를 수행합니다. 디버깅하려고하는 스크립트가 있습니다. 제어 프로세스가 시작되어 Devel :: ebug 디버거를로드하라는 메시지가 표시됩니다. 스크립트가 실행되면 소켓을 통해 제어 스크립트와 대화하여 디버깅 중 무엇을 할 수 있는지 알아 봅니다.

제어 Deve :: ebug가 프로그램 디버깅 문제를 가지고 있기 때문에 문제라고 생각합니다. (STABLE)의 라인 (41)의 주위에 보면 :: ebug 우리는 다음을 참조하십시오

my $backend = $self->backend || "$Bin/ebug_backend_perl"; 
my $command = "$backend $program";; 
my $proc = Proc::Background->new(
    {'die_upon_destroy' => 1}, 
    $command 
); 

그것은이의를 시작하기 위해 적절한 명령 줄 플래그 스크립트를 실행할 수 있습니다 무언가에 대한 경로를 포함해야 ->backend처럼 보인다 소켓에 위에서 포함 된 제어 프로그램과 대화하도록 구성된 프로세스 디버거.

이 작업을 처리하는 모듈과 함께 설치된 ebug_backend_perl이 있습니다. 나는 당신이 이 있어야한다고 생각한다. (정확히 추측한다면 시스템에 /home/wakatana/perl5/bin/ebug_backend_perl이있다) $ebug->load