develooper Front page | perl.perl5.porters | Postings from September 2013

A few Perl gdb debugging tools

Thread Next
September 26, 2013 15:27
A few Perl gdb debugging tools
Message ID:
Howdy folks,

I've written two debugging tools for use with Perl and gdb that may be
of use to some of you.

They are:

Devel::GDB::Breakpoint lets you insert easy-to-break-on subs into your
Perl code that will be executed at runtime:

  use Devel::GDB::Breakpoint;

  print "before";
  breakpoint 42;
  print "after";

  $ gdb --args perl ./
  > b bp if val == 42
  > run

This will break when the op containing breakpoint() gets executed and
the underlying C bp() call is made.

Devel::GDB::Parser::Breakpoint allows similar functionality, but the C
function is executed at parse/lexer time:

  use Devel::GDB::Parser::Breakpoint;

  print "before";
  parser_breakpoint 42;
  if ; # syntax error

  $ gdb --args perl ./
  > b bp if val == 42
  > run

This will break at the parser_breakpoint line before "if ;" has been
parsed, so you can look around.

Hope these are useful.

If there's a better way to do both of these things (prior art, simpler
tricks with gdb without needing external modules) please share.


-- Matthew Horsfall (alh)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About