Perl: DebuggingDebuggingIf you invoke perl with a -d switch, your script will be run under a debugging monitor. It will halt before the first executable statement and ask you for a command, such as:hPrints out a help message. TStack trace. sSingle step. Executes until it reaches the beginning of another statement. nNext. Executes over subroutine calls, until it reaches the beginning of the next statement. fFinish. Executes statements until it has finished the current subroutine. cContinue. Executes until the next breakpoint is reached. c lineContinue to the specified line. Inserts a one-time-only breakpoint at the specified line. <CR>Repeat last n or s. l min+incrList incr+1 lines starting at min. If min is omitted, starts where last listing left off. If incr is omitted, previous value of incr is used. l min-maxList lines in the indicated range. l lineList just the indicated line. lList next window. -List previous window. w lineList window around line. l subnameList subroutine. If it's a long subroutine it just lists the beginning. Use "l" to list more. /pattern/Regular expression search forward for pattern; the final / is optional. ?pattern?Regular expression search backward for pattern; the final ? is optional. LList lines that have breakpoints or actions. SLists the names of all subroutines. tToggle trace mode on or off. b line conditionSet a breakpoint. If line is omitted, sets a breakpoint on the line that is about to be executed. If a condition is specified, it is evaluated each time the statement is reached and a breakpoint is taken only if the condition is true. Breakpoints may only be set on lines that begin an executable statement. b subname conditionSet breakpoint at first executable line of subroutine. <dt>d line Delete breakpoint. If line is omitted, deletes the breakpoint on the line that is about to be executed.DDelete all breakpoints. a line commandSet an action for line. A multi-line command may be entered by backslashing the newlines. ADelete all line actions. < commandSet an action to happen before every debugger prompt. A multi-line command may be entered by backslashing the newlines. > commandSet an action to happen after the prompt when you've just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines. V packageList all variables in package. Default is main package. ! numberRedo a debugging command. If number is omitted, redoes the previous command. ! -numberRedo the command that was that many commands ago. H -numberDisplay last n commands. Only commands longer than one character are listed. If number is omitted, lists them all. q or ^DQuit. commandExecute command as a perl statement. A missing semicolon will be supplied. p exprSame as "print DB'OUT expr". The DB'OUT filehandle is opened to /dev/tty, regardless of where STDOUT may be redirected to. If you want to modify the debugger, copy perldb.pl from the perl library to your current directory and modify it as necessary. (You'll also have to put -I. on your command line.) You can do some customization by setting up a .perldb file which contains initialization code. For instance, you could make aliases like these: $DB'alias{'len'} = 's/^len(.*)/p length()/';
|