⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perldb.pl

📁 早期freebsd实现
💻 PL
📖 第 1 页 / 共 2 页
字号:
			}		    }		    next CMD; };		$cmd =~ /^L$/ && do {		    for ($i = 1; $i <= $max; $i++) {			if (defined $dbline{$i}) {			    print OUT "$i:\t", $dbline[$i];			    ($stop,$action) = split(/\0/, $dbline{$i});			    print OUT "  break if (", $stop, ")\n" 				if $stop;			    print OUT "  action:  ", $action, "\n" 				if $action;			    last if $signal;			}		    }		    next CMD; };		$cmd =~ /^b\b\s*(['A-Za-z_]['\w]*)\s*(.*)/ && do {		    $subname = $1;		    $cond = $2 || '1';		    $subname = "$package'" . $subname unless $subname =~ /'/;		    $subname = "main" . $subname if substr($subname,0,1) eq "'";		    ($filename,$i) = split(/:/, $sub{$subname});		    $i += 0;		    if ($i) {			*dbline = "_<$filename";			++$i while $dbline[$i] == 0 && $i < $#dbline;			$dbline{$i} =~ s/^[^\0]*/$cond/;		    } else {			print OUT "Subroutine $subname not found.\n";		    }		    next CMD; };		$cmd =~ /^b\b\s*(\d*)\s*(.*)/ && do {		    $i = ($1?$1:$line);		    $cond = $2 || '1';		    if ($dbline[$i] == 0) {			print OUT "Line $i not breakable.\n";		    } else {			$dbline{$i} =~ s/^[^\0]*/$cond/;		    }		    next CMD; };		$cmd =~ /^d\b\s*(\d+)?/ && do {		    $i = ($1?$1:$line);		    $dbline{$i} =~ s/^[^\0]*//;		    delete $dbline{$i} if $dbline{$i} eq '';		    next CMD; };		$cmd =~ /^A$/ && do {		    for ($i = 1; $i <= $max ; $i++) {			if (defined $dbline{$i}) {			    $dbline{$i} =~ s/\0[^\0]*//;			    delete $dbline{$i} if $dbline{$i} eq '';			}		    }		    next CMD; };		$cmd =~ /^<\s*(.*)/ && do {		    $pre = do action($1);		    next CMD; };		$cmd =~ /^>\s*(.*)/ && do {		    $post = do action($1);		    next CMD; };		$cmd =~ /^a\b\s*(\d+)(\s+(.*))?/ && do {		    $i = $1;		    if ($dbline[$i] == 0) {			print OUT "Line $i may not have an action.\n";		    } else {			$dbline{$i} =~ s/\0[^\0]*//;			$dbline{$i} .= "\0" . do action($3);		    }		    next CMD; };		$cmd =~ /^n$/ && do {		    $single = 2;		    $laststep = $cmd;		    last CMD; };		$cmd =~ /^s$/ && do {		    $single = 1;		    $laststep = $cmd;		    last CMD; };		$cmd =~ /^c\b\s*(\d*)\s*$/ && do {		    $i = $1;		    if ($i) {			if ($dbline[$i] == 0) {			    print OUT "Line $i not breakable.\n";			    next CMD;			}			$dbline{$i} =~ s/(\0|$)/;9$1/;	# add one-time-only b.p.		    }		    for ($i=0; $i <= $#stack; ) {			$stack[$i++] &= ~1;		    }		    last CMD; };		$cmd =~ /^r$/ && do {		    $stack[$#stack] |= 2;		    last CMD; };		$cmd =~ /^T$/ && do {		    local($p,$f,$l,$s,$h,$a,@a,@sub);		    for ($i = 1; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {			@a = @args;			for (@a) {			    if (/^StB\000/ && length($_) == length($_main{'_main'})) {				$_ = sprintf("%s",$_);			    }			    else {				s/'/\\'/g;				s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;				s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;				s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;			    }			}			$w = $w ? '@ = ' : '$ = ';			$a = $h ? '(' . join(', ', @a) . ')' : '';			push(@sub, "$w&$s$a from file $f line $l\n");			last if $signal;		    }		    for ($i=0; $i <= $#sub; $i++) {			last if $signal;			print OUT $sub[$i];		    }		    next CMD; };		$cmd =~ /^\/(.*)$/ && do {		    $inpat = $1;		    $inpat =~ s:([^\\])/$:$1:;		    if ($inpat ne "") {			eval '$inpat =~ m'."\n$inpat\n";				if ($@ ne "") {			    print OUT "$@";			    next CMD;			}			$pat = $inpat;		    }		    $end = $start;		    eval '		    for (;;) {			++$start;			$start = 1 if ($start > $max);			last if ($start == $end);			if ($dbline[$start] =~ m'."\n$pat\n".'i) {			    if ($emacs) {				print OUT "\032\032$filename:$start:0\n";			    } else {				print OUT "$start:\t", $dbline[$start], "\n";			    }			    last;			}		    } ';		    print OUT "/$pat/: not found\n" if ($start == $end);		    next CMD; };		$cmd =~ /^\?(.*)$/ && do {		    $inpat = $1;		    $inpat =~ s:([^\\])\?$:$1:;		    if ($inpat ne "") {			eval '$inpat =~ m'."\n$inpat\n";				if ($@ ne "") {			    print OUT "$@";			    next CMD;			}			$pat = $inpat;		    }		    $end = $start;		    eval '		    for (;;) {			--$start;			$start = $max if ($start <= 0);			last if ($start == $end);			if ($dbline[$start] =~ m'."\n$pat\n".'i) {			    if ($emacs) {				print OUT "\032\032$filename:$start:0\n";			    } else {				print OUT "$start:\t", $dbline[$start], "\n";			    }			    last;			}		    } ';		    print OUT "?$pat?: not found\n" if ($start == $end);		    next CMD; };		$cmd =~ /^!+\s*(-)?(\d+)?$/ && do {		    pop(@hist) if length($cmd) > 1;		    $i = ($1?($#hist-($2?$2:1)):($2?$2:$#hist));		    $cmd = $hist[$i] . "\n";		    print OUT $cmd;		    redo CMD; };		$cmd =~ /^!(.+)$/ && do {		    $pat = "^$1";		    pop(@hist) if length($cmd) > 1;		    for ($i = $#hist; $i; --$i) {			last if $hist[$i] =~ $pat;		    }		    if (!$i) {			print OUT "No such command!\n\n";			next CMD;		    }		    $cmd = $hist[$i] . "\n";		    print OUT $cmd;		    redo CMD; };		$cmd =~ /^H\b\s*(-(\d+))?/ && do {		    $end = $2?($#hist-$2):0;		    $hist = 0 if $hist < 0;		    for ($i=$#hist; $i>$end; $i--) {			print OUT "$i: ",$hist[$i],"\n"			    unless $hist[$i] =~ /^.?$/;		    };		    next CMD; };		$cmd =~ s/^p( .*)?$/print DB'OUT$1/;		$cmd =~ /^=/ && do {		    if (local($k,$v) = ($cmd =~ /^=\s*(\S+)\s+(.*)/)) {			$alias{$k}="s~$k~$v~";			print OUT "$k = $v\n";		    } elsif ($cmd =~ /^=\s*$/) {			foreach $k (sort keys(%alias)) {			    if (($v = $alias{$k}) =~ s~^s\~$k\~(.*)\~$~$1~) {				print OUT "$k = $v\n";			    } else {				print OUT "$k\t$alias{$k}\n";			    };			};		    };		    next CMD; };	    }	    $evalarg = $cmd; &eval;	    print OUT "\n";	}	if ($post) {	    $evalarg = $post; &eval;	}    }    ($@, $!, $[, $,, $/, $\) = @saved;}sub save {    @saved = ($@, $!, $[, $,, $/, $\);    $[ = 0; $, = ""; $/ = "\n"; $\ = "";}# The following takes its argument via $evalarg to preserve current @_sub eval {    eval "$usercontext $evalarg; &DB'save";    print OUT $@;}sub action {    local($action) = @_;    while ($action =~ s/\\$//) {	print OUT "+ ";	$action .= &gets;    }    $action;}sub gets {    local($.);    <IN>;}sub catch {    $signal = 1;}sub sub {    push(@stack, $single);    $single &= 1;    $single |= 4 if $#stack == $deep;    if (wantarray) {	@i = &$sub;	$single |= pop(@stack);	@i;    }    else {	$i = &$sub;	$single |= pop(@stack);	$i;    }}$single = 1;			# so it stops on first executable statement@hist = ('?');$SIG{'INT'} = "DB'catch";$deep = 100;		# warning if stack gets this deep$window = 10;$preview = 3;@stack = (0);@ARGS = @ARGV;for (@args) {    s/'/\\'/g;    s/(.*)/'$1'/ unless /^-?[\d.]+$/;}if (-f $rcfile) {    do "./$rcfile";}elsif (-f "$ENV{'LOGDIR'}/$rcfile") {    do "$ENV{'LOGDIR'}/$rcfile";}elsif (-f "$ENV{'HOME'}/$rcfile") {    do "$ENV{'HOME'}/$rcfile";}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -