the perl debugger

18
The Perl Debugger Issac Goldstand [email protected] Mirimar Networks http:// www.mirimar.net/

Upload: angelo

Post on 02-Feb-2016

77 views

Category:

Documents


0 download

DESCRIPTION

The Perl Debugger. Issac Goldstand [email protected] Mirimar Networks http://www.mirimar.net/. Credits / For more info. Based loosely on perldebtut Also, don’t forget perldeb Inside the debugger: h h or h [cmd]. Before we even get to the debugger…. Have you: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Perl Debugger

The Perl Debugger

Issac Goldstand

[email protected]

Mirimar Networks

http://www.mirimar.net/

Page 2: The Perl Debugger

Credits / For more info

Based loosely on perldebtut Also, don’t forget perldeb Inside the debugger: h h or h [cmd]

Page 3: The Perl Debugger

Before we even get to the debugger…

Have you: Turned on warnings via use warnings or perl –w?

Do you use strict wherever possible? Does your script pass syntax checking

(perl –c)?

Page 4: The Perl Debugger

Example 1 – Hello World

#!/usr/bin/perl

$var1 = ’Hello, world!’;

$var2 = “$varl\n”;

print $var2;

Page 5: The Perl Debugger

When not to use the debugger

Not every case needs the debugger The debugger would not have provided any

significant help with the previous example It is important to use other tools to find

problems

Page 6: The Perl Debugger

What to use?

perl5db.pl – The command line debugger

GUI debugger – ptkdb ActiveState – PDK,

Komodo

Page 7: The Perl Debugger

Starting the debugger

Called by perl –d Can be command line option: perl –d myscript.pl

…or part of the shebang line: #!/usr/bin/perl -d

Page 8: The Perl Debugger

The MOST IMPORTANT COMMAND ™

Page 9: The Perl Debugger

The MOST IMPORTANT COMMAND ™

q – Quits the debugger

Page 10: The Perl Debugger

The SECOND MOST IMPORTANT COMMAND™

Page 11: The Perl Debugger

The SECOND MOST IMPORTANT COMMAND™

h – Displays help

Page 12: The Perl Debugger

The text debugger

Other common commands:v [line] – View around line (current line by

default)x expr – Evaluates an expression (in list context)m expr – Shows methods that expr->can dos – Step inton – Step overc line – Set a “one time” breakpoint

Page 13: The Perl Debugger

Working with variables & symbols

M shows currently loaded modules + versions S shows currently available subroutines X / V shows variables in [current] package

Page 14: The Perl Debugger

Looking around

v – Shows a “block” of code, starting from current position

l – shows a single line of code, starting from current position

Either command takes an optional parameter of a line number

. resets the line position to the current line

Page 15: The Perl Debugger

Practical use

Normal “command line” scripts CGI scripts via –debug pragma or command

arguments mod_perl via Apache::DB Not helpful for XSUB debugging

Page 16: The Perl Debugger

GUIs

ptkdb IDEs ActiveState PDK I’ve personally found the

PDK to be very weak (while somewhat simpler to navigate, set breakpoints, etc)

Page 17: The Perl Debugger

Komodo

ActiveState’s opensource-language IDE Costs $$$ New version 3.0 just released with very complete

GUI debug tools Includes supports for watches, conditional

breakpoints, immediate pane, etc Includes support for simulating full CGI

environment

Page 18: The Perl Debugger

The End

Issac Goldstand

<[email protected]>

Mirimar Networks

http://www.mirimar.net/