Home arrow Perl Programming arrow Page 4 - Perl Debuggers in Detail

Devel::ebug - Perl

In this second part of a two-part series on debugging Perl, we will go beyond the author's favorite debugger and look at a number of alternative Perl debuggers. This article is excerpted from chapter four of the book Mastering Perl, written by Brian D Foy (O'Reilly; ISBN: 0596527241). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Perl Debuggers in Detail
  2. perl5db.pl
  3. Alternative Debuggers
  4. Devel::ebug
  5. Other Debuggers
  6. Summary
By: O'Reilly Media
Rating: starstarstarstarstar / 3
July 31, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The Devel::ebug module by Léon Brocard provides an object-oriented interface to Perl’s debugger facility. It’s a work in progress, so what I say here might be different by the time you read this. The main features should still be there, though.

It comes with its own terminal-based debugger named ebug. It’s a bit of an odd name until you realize how you call it. The missing d in the name comes from Perl’s -d switch.

  $ perl -d:ebug program.pl

I don’t need to use the -d switch, though, since I can call it directly with the ebug program, but I have to call it by quoting the entire command line:

  $ ebug "add_numbers.pl 5 6"
 
* Welcome to Devel::ebug 0.46
  main(add_numbers.pl#3):
  my $n = shift @ARGV;
  ebug: x @ARGV
  --- 5
  --- 6

  main(add_numbers.pl#3):
  my $n = shift @ARGV;
  ebug: s
  main(add_numbers.pl#4):
  my $m = $ARGV[0];
  ebug: x $n
  --- 5

The ebug program is really just a wrapper around Devel::ebug::Console, and I can call Devel::ebug in many different ways. At the core of its design is a detached process. The backend runs the program under the debugger, and the frontend communicates with it over TCP. This means, for instance, I can debug the program on a different machine than on the one it’s running.

The Devel::ebug::HTTP module uses the same Devel::ebug backend, but sets up a mini web server.I start the ebug_http the same way I did with the console version, but instead of giving me a prompt, it tells me the URL I need to access to see the debugger:§

  $ ebug_http "add_numbers.pl 4 5"
  You can connect to your server at http://albook.local:8321

The web page shows me a bare bones debugger interface (Figure 4-4). Remember, this is basically a proof of concept, but even as that it’s very impressive and can serve as the basis for your own tailor-made programs.


Figure 4-4.  The Devel::ebug::HTTP module lets me debug a program on a remote server through my browser



 
 
>>> More Perl Programming Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
   

PERL PROGRAMMING ARTICLES

- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: