home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!srvr1.engin.umich.edu!uvaarpa!mmdf
- From: " (Paul Marquess)" <pmarquess@rosebud.bfsec.bt.co.uk>
- Subject: Re: Perl debugger under X ?
- Message-ID: <1993Jan21.143028.19327@uvaarpa.Virginia.EDU>
- Sender: mmdf@uvaarpa.Virginia.EDU (Mail System)
- Reply-To: pmarquess@bfsec.bt.co.uk
- Organization: The Internet
- Date: Thu, 21 Jan 1993 14:30:28 GMT
- Lines: 164
-
- In message <1992Dec3.132739.21282@news.eng.convex.com>
- tchrist@convex.COM (Tom Christiansen) writes:
- | Maybe... not sure what that means. Here's a system I have
- | for starting several xterms, one for the debugger, one for
- | program i/o, and one for a slave-vi that autorepositions
- | at each break point or line number. You need named pipes
- | and the TIOCSTI ioctl. There's a two-line or so mod to
- | perldb to support this.
- |
- | I first invented this to debug plum, cause it does screen
- | handling stuff, which is highly inconvenient when you're
- | using the same window to debug.
-
- I have used this for quite a while and found it VERY useful. One small
- problem, though, is that it is difficult to use it to debug programs
- which require special copies of the perl interpreter, e.g. oraperl,
- curseperl etc.
-
- These sort of scripts usually have a #! line to specify the interpreter
- name, so below is a patch for Tom's pwdb program which will search the
- script to be debugged for the initial #! line and extract the name of
- the interpreter. This will then be the used to debug the script.
-
- For those scripts which do not have the appropriate #! line I have
- added a -i option which allow the interpreter to be specified. If the
- interpreter specified is not a relative or absolute path, it will be
- searched for on the path.
-
- So, for example, to debug an oraperl script which does not contain
- the appropriate #! line, use
-
- pwdb -i oraperl script
-
- Whilst on the subject of debuggers and X, I am in the middle of writing
- a perl interface to XView (freely available OPEN LOOK user interface
- toolkit). One of my reasons is to attempt to implement an enhanced
- X-wondows perl debugger. If I ever get around to finishing the XView
- interface I will post it - it sort of works at the moment, but there
- are still quite a few loose end which need tying.
-
-
- *** old/pwdb Thu Jan 21 12:48:17 1993
- --- pwdb Thu Jan 21 12:51:32 1993
- ***************
- *** 2,7 ****
- --- 2,22 ----
-
- die "no program to dbg" unless @ARGV;
-
- + # Parse the command line
- + if ($ARGV[0] eq '-i')
- + {
- + shift ;
- + ($interp = shift) || die "usage: $0 [-i interpreter] script [parameters]\n";
- + $interp = &SearchPath($interp) ;
- + }
- + else
- + {
- + $interp = &GetInterpreterName ($ARGV[0]) ;
- + }
- +
- +
- + print "Perl Interpreter is $interp\n" ;
- +
- open (TTY, "</dev/tty") || die "can't open /dev/tty: $!";
-
- system("stty -echo");
- ***************
- *** 60,66 ****
- close (STDOUT);
- open(STDOUT, "> $bugtty") || die "can't reopen STDOUT: $!";
- open(STDERR, ">&STDOUT") || die "can't reopen STDERR: $!";
- ! exec "perl -d @ARGV 2>&1 >$bugtty";
- die "can't exec perl debugger: $!";
- }
-
- --- 75,81 ----
- close (STDOUT);
- open(STDOUT, "> $bugtty") || die "can't reopen STDOUT: $!";
- open(STDERR, ">&STDOUT") || die "can't reopen STDERR: $!";
- ! exec "$interp -d @ARGV 2>&1 >$bugtty";
- die "can't exec perl debugger: $!";
- }
-
- ***************
- *** 92,94 ****
- --- 107,175 ----
- sub newpgrp {
- setpgrp($$,$$);
- }
- +
- + sub GetInterpreterName
- + {
- + local ($file) = @_ ;
- + local ($line) ;
- + local ($interpreter) = "perl" ; # Initialise to default interpterer name
- +
- +
- + # check that the script file actually is a text file
- + die "$file is not a text file\n" if ! -T $file ;
- +
- + # get the first line from the script
- + open (FIL, "<$file") || die "Cannot open $file: $!\n" ;
- + $line = <FIL> ;
- + close FIL ;
- +
- + # now figure out the name of the interpreter
- +
- + chop $line ;
- +
- + # Check for a #! -- if not then assume bog standard perl
- + if ( $line =~ s/^#! *//o )
- + {
- + # The first word must be the interpreter
- + $interpreter = (split (/ /, $line)) [0] ;
- + }
- +
- + &SearchPath ($interpreter) ;
- + }
- +
- + sub SearchPath
- + {
- + local ($interpreter) = @_ ;
- + local ($found, $dir, @absdirs) ;
- +
- + # only search for the interpreter on the path if it is
- + # neither an absolute or relative path
- + if ( $interpreter !~ m#^[/.]#o )
- + {
- + # Now check for the existance of the interpreter
- + @absdirs = reverse grep(m!^/!, split(/:/, $ENV{'PATH'}, 999)) ;
- +
- + $found = '' ;
- + foreach $dir (@absdirs)
- + {
- + stat ("$dir/$interpreter") ;
- +
- + # file must be executable but
- + # not be a directory, block special or character special file
- + $found = "$dir/$interpreter"
- + if -x _ && ! ( -d _ || -b _ || -c _) ;
- + }
- +
- + die "cannot find $interpreter in path\n" if ! $found ;
- +
- + $interpreter = $found ;
- + }
- + else
- + {
- + # Check that specified interpterer can be executed
- + die "Cannot execute $interpreter\n"
- + unless -x $interpreter ;
- + }
- +
- + $interpreter ;
- + }
- *** end of patch
-
- Paul Marquess Tel: +44 232 894-265
- BT Fax: +44 232 333-600
- Royston House e-mail: pmarquess@bfsec.bt.co.uk
- 34 Upper Queen Street
- BELFAST BT8 4QY
- UK
-