-
-
30 Sep 2013 11:50:49 UTC
- Distribution: Devel-GDB-Parser-Breakpoint
- Module version: 0.02
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (288 / 0 / 0)
- Kwalitee
Bus factor: 1- 80.00% Coverage
- License: unknown
- Perl: v5.11.2
- Activity
24 month- Tools
- Download (2.9KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Matthew Horsfall (alh)
- NAME
- SYNOPSIS
- DESCRIPTION
- WHY WOULD I WANT THIS?
- COMPATIBILITY
- SEE ALSO
- AUTHOR
- COPYRIGHT AND LICENSE
NAME
Devel::GDB::Parser::Breakpoint - Create easily identifiable gdb breakpoints in Perl parser code.
SYNOPSIS
In some Perl program (prog.pl):
#!/usr/bin/perl use strict; use warnings; use Devel::GDB::Parser::Breakpoint; print "before\n"; # Call bp(42) during parsing of this line parser_breakpoint 42; print "after\n";
Then:
$ gdb --args perl ./prog.pl ... (gdb) b bp if val == 42 Function "bp" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (bp if val == 42) pending. (gdb) run Starting program: /usr/bin/perl prog.pl [Thread debugging using libthread_db enabled] Breakpoint 1, bp (val=42) at Breakpoint.xs:7 7 void bp(int val) {} (gdb)
DESCRIPTION
This module allows you to inject breakpoints into the parsing of your Perl code by the perl binary that you can easily identify with gdb.
It exports the
parser_breakpoint
sub at runtime which can be called from any Perl code with an integer value as its argument. When the perl lexer/parser reaches the line, the module calls a C function calledbp
with the argument you gave as its only parameter, which is namedval
.IE, in Perl:
parser_breakpoint 3;
Equates to:
void bp(int val) {}; bp(3);
Which allows you in gdb to set breakpoints like so:
(gdb) b bp if val == 3 ...
Note that parser_breakpoint always returns the value 1. It can be used in complex statements/expressions to see what's going on:
if ($x && $y && parser_breakpoint 2 && $z) { ... }
And since it happens at lexer/parser time, it will still execute here:
if (0 && parser_breakpoint 3) { ... }
WHY WOULD I WANT THIS?
I'm really not sure you would.
But it may be useful if you want to easily see what the perl lexer/parser is doing as it reads different parts of your source.
Alternatively, in Perl you can:
BEGIN { study; }
And in gdb:
(gdb) b Perl_pp_study
However, this doesn't allow you to break inside of if blocks like in the examples above.
COMPATIBILITY
This module requires at least Perl 5.11.2 because of pluggable keywords. See "PL_keyword_plugin" in perlapi for more information.
SEE ALSO
Devel::GDB::Breakpoint - Create easily identifiable runtime gdb breakpoints in Perl code
AUTHOR
Matthew Horsfall (alh) - <wolfsage@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2013 by Matthew Horsfall
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
Module Install Instructions
To install Devel::GDB::Parser::Breakpoint, copy and paste the appropriate command in to your terminal.
cpanm Devel::GDB::Parser::Breakpoint
perl -MCPAN -e shell install Devel::GDB::Parser::Breakpoint
For more information on module installation, please visit the detailed CPAN module installation guide.