Commits

Anonymous committed 8b9715b

Importing the 0.1.5 files into trunk/module

Comments (0)

Files changed (14)

+This is the MIT/X11 license:
+
+--------------
+Copyright 2003 Shlomi Fish.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+At the command-line, type:
+
+perl Makefile.PL
+make
+
+To prepare the package for installation and then:
+
+make install
+
+to install it.
+
+MANIFEST
+COPYING
+INSTALL
+README
+Makefile.PL
+lib/Devel/LineTrace.pm
+META.yml                                Module meta-data (added by MakeMaker)
+t/01twotraces.t
+t/00onetrace.t
+t/02cancelled.t
+t/input/cancelled_trace.txt
+t/input/onetrace.txt
+t/input/twotraces.txt
+t/scripts/script1.pl
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Devel-LineTrace
+version:      0.1.5
+version_from: lib/Devel/LineTrace.pm
+installdirs:  site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.10_08

module/Makefile.PL

+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    'NAME' => 'Devel::LineTrace',
+    'DISTNAME' => 'Devel-LineTrace',
+    'VERSION_FROM' => 'lib/Devel/LineTrace.pm',
+    );
+This is Devel::LineTrace, a perl debugging module that enables
+assigning callbacks to line numbers in the source code.
+
+Read the INSTALL file for installation instructions.
+

module/lib/Devel/LineTrace.pm

+package Devel::LineTrace;
+
+$VERSION = '0.1.5';
+
+=head1 NAME
+
+Devel::LineTrace - Apply traces to individual lines.
+
+=head1 SYNPOSIS
+
+    perl -d:LineTrace myscript.pl [args ...]
+
+=head1 DESCRIPTION
+
+This is a class that enables assigning Perl code callbacks to certain
+lines in the original code B<without modifying it>. 
+
+To do so prepare a file with the following syntax:
+
+    [source_filename]:[line]
+        [CODE]
+        [CODE]
+        [CODE]
+    [source_filename]:[line]
+        [CODE]
+        [CODE]
+        [CODE]
+
+Which will assign the [CODE] blocks to the filename and line combinations.
+The [CODE] sections are indented from the main blocks. To temporarily cancel
+a callback put a pound-sign (#) right at the start of the line (without 
+whitespace beforehand).
+
+The location of the file should be specified by the PERL5DB_LT environment 
+variable (or else it defaults to C<perl-line-traces.txt>.)
+
+Then invoke the perl interpreter like this:
+   
+    perl -d:LineTrace myprogram.pl
+
+=head1 SEE ALSO
+
+L<Devel::Trace>, L<Debug::Trace>
+
+=head1 AUTHORS
+
+Shlomi Fish E<lt>shlomif@vipe.technion.ac.ilE<gt>
+
+=cut
+
+package DB;
+
+my (%files);
+sub BEGIN
+{
+    local (*I);
+    my $filename = $ENV{'PERL5DB_LT'} || "perl-line-traces.txt";
+    open I, "<$filename";
+    my $line;
+    $line = <I>;
+    while($line)
+    {
+        chomp $line;
+        if (($line =~ /^\s+/) || ($line =~ /^#/))
+        {
+            $line = <I>;
+            next;
+        }
+        $line =~ /^(.+):(\d+)$/;
+        my $filename = $1;
+        my $line_num = $2;
+        my $callback = "";
+        while ($line = <I>)
+        {
+            if ($line =~ /^\s/)
+            {
+                $callback .= $line;
+            }
+            else
+            {
+                last;
+            }
+        }
+        $files{$filename}{$line_num} = $callback;
+    }
+    close(I);
+}
+
+sub DB
+{
+    local @saved = ($@, $!, $^E, $,, $/, $\, $^W);
+    local($package, $filename, $line) = caller;
+    local $usercontext = '($@, $!, $^E, $,, $/, $\, $^W) = @saved;' .
+      "package $package;";	# this won't let them modify, alas
+    if (exists($files{$filename}{$line}))
+    {
+        eval $usercontext . " " . $files{$filename}{$line};
+    }
+}
+
+1;
+

module/t/00onetrace.t

+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More tests => 1;
+
+$ENV{'PERL5DB_LT'} = "t/input/onetrace.txt";
+
+my $output = `perl -d:LineTrace t/scripts/script1.pl`;
+
+ok($output eq "\$i=5\n");
+

module/t/01twotraces.t

+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More tests => 1;
+
+$ENV{'PERL5DB_LT'} = "t/input/twotraces.txt";
+
+my $output = `perl -d:LineTrace t/scripts/script1.pl`;
+
+ok($output eq "\$i=5\n\$j=150\n");
+

module/t/02cancelled.t

+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More tests => 1;
+
+$ENV{'PERL5DB_LT'} = "t/input/cancelled_trace.txt";
+
+my $output = `perl -d:LineTrace t/scripts/script1.pl`;
+
+ok($output eq "\$i=5\n\$j=150\n");
+

module/t/input/cancelled_trace.txt

+t/scripts/script1.pl:8
+    print "\$i=$i\n";
+# t/scripts/script1.pl:10
+    print "Hello there!\n";
+t/scripts/script1.pl:12
+    print "\$j=$j\n";

module/t/input/onetrace.txt

+t/scripts/script1.pl:8
+    print "\$i=$i\n";

module/t/input/twotraces.txt

+t/scripts/script1.pl:8
+    print "\$i=$i\n";
+t/scripts/script1.pl:12
+    print "\$j=$j\n";

module/t/scripts/script1.pl

+#!/usr/bin/perl -w
+
+use strict;
+
+my $i = 5;
+my $j = 100;
+
+$i *= 10;
+
+$j += $i;
+
+$j **= 2;
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.