seitfa wrote on Sat Jul 8 15:27:01 MEST 2006:
Hi, I watched perl5db.pl in EPIC and found some Bugs (I think). Of cause this is very strange code => it's a debugger. 1. sub sub { } * This is not recogniced as a sub. 2. sub print_trace { local $\ = ''; my $fh = shift; # If this is going to a slave editor, but we're not the primary # debugger, reset it first. resetterm(1) if $fh eq $LINEINFO # slave editor and $LINEINFO eq $OUT # normal output and $term_pid != $$; # not the primary # Collect the actual trace information to be formatted. # This is an array of hashes of subroutine call info. my @sub = dump_trace( $_[0] + 1, $_[1] ); # Grab the "short report" flag from @_. my $short = $_[2]; # Print short report, next one for sub name # Run through the traceback info, format it, and print it. my $s; for ( $i = 0 ; $i <= $#sub ; $i++ ) { # Drop out if the user has lost interest and hit control-C. last if $signal; # Set the separator so arrys print nice. local $" = ', '; # Grab and stringify the arguments if they are there. my $args = defined $sub[$i]{args} ? "(@{ $sub[$i]{args} })" : ''; # Shorten them up if $maxtrace says they're too long. $args = ( substr $args, 0, $maxtrace - 3 ) . '...' if length $args > $maxtrace; # Get the file name. my $file = $sub[$i]{file}; # Put in a filename header if short is off. $file = $file eq '-e' ? $file : "file `$file'" unless $short; # Get the actual sub's name, and shorten to $maxtrace's requirement. $s = $sub[$i]{sub}; $s = ( substr $s, 0, $maxtrace - 3 ) . '...' if length $s > $maxtrace; # Short report uses trimmed file and sub names. if ($short) { my $sub = @_ >= 4 ? $_[3] : $s; print $fh "$sub[$i]{context}=$sub$args from $file:$sub[$i]{line}\n"; } ## end if ($short) # Non-short report includes full names. else { print $fh "$sub[$i]{context} = $s$args" . " called from $file" . " line $sub[$i]{line}\n"; } } ## end for ($i = 0 ; $i <= $#sub... } ## end sub print_trace * Brackets are matched wronge * "$s = $sub[$i]{sub}; $s = ( substr $s, 0, $maxtrace - 3 )" is not the beginning of a sub, or is it? * "if ($short)" is displayed as a sting, is it? 3. file perl5db.pl * Package main is displayed many times * Package DB is displayed many times > I don't know if this is wanted I hope I don't bother you to much. :-) I am not a perl-guru excuse me if I made a mistake. Thanks
jploski wrote on Sat Jul 8 16:15:47 MEST 2006:
This illustrates the known fact that only Perl can parse Perl (this translates into - no good tools for Perl; EPIC's functionality is a joke compared to JDT, for example). Regarding your observations: 1. sub sub - using keywords as procedure names... no comments. 2. Here the {sub} is wrongly taken a keyword. {'sub'} would be fine. Perl has a way of distinguishing literals from keywords based on context, but EPIC at present does not. 3. The multiple appearance of 'main' is a direct consequence of the above problem. Note that generally, it is okay for a package to appear multiple times in the Outline - one time per package keyword occurrence in the source file.
seitfa wrote on Mon Jul 17 22:34:33 MEST 2006:
Isn't there a way to "ask" perl what a piece of code is? (I hope you know what I mean)
Note: The above is an archived snapshot of a forum thread. Use the original thread at sf.net to post comments.