처음에 나는 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
xterm 창에서 디버거를 실행한다. 도움이되는지 확인하십시오. –