Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DDP in Perl debugger prints data twice #176

Open
clharrison opened this issue Feb 26, 2023 · 2 comments
Open

Using DDP in Perl debugger prints data twice #176

clharrison opened this issue Feb 26, 2023 · 2 comments

Comments

@clharrison
Copy link

I set up to use Data::Printer from the debugger using these instructions. It successfully rebound the debugger's p() command, except that it prints the data twice in succession:

Test program foo.pl:

> > #!/usr/bin/env perl
> > use v5.36;
> > 
> > say "Here is ~/.perldb:\n";
> > say qx(cat ~/.perldb);
> > 
> > my @xx = (qw/a b c d e/);
> > push @xx, [ 1,2,3 ];
> > 
> > my $foo = 1; # set breakpoint here and issue p @xx
> > 

Debug session:

> > $ perl -d ./foo.pl
> > 
> > Loading DB routines from perl5db.pl version 1.73
> > Editor support available.
> > 
> > Enter h or 'h h' for help, or 'man perldebug' for more help.
> > 
> > main::(./foo.pl:4):    say "Here is ~/.perldb:\n";
> >   DB<1> b 10
> >   DB<2> c
> > Here is ~/.perldb:
> > 
> > use DB::Pluggable;
> > DB::Pluggable->run_with_config( \'[DataPrinter]' );
> > 
> > main::(./foo.pl:10):    my $foo = 1; # use as breakpoint
> >   DB<2> p @xx
> > [
> >     [0] "a",
> >     [1] "b",
> >     [2] "c",
> >     [3] "d",
> >     [4] "e",
> >     [5] [
> >             [0] 1,
> >             [1] 2,
> >             [2] 3
> >         ]
> > ]
> > [
> >     [0] "a",
> >     [1] "b",
> >     [2] "c",
> >     [3] "d",
> >     [4] "e",
> >     [5] [
> >             [0] 1,
> >             [1] 2,
> >             [2] 3
> >         ]
> > ]
> > 
> > 
> 

Also note that the same documentation demonstrates how to bind an alias (px) to a subroutine that invokes Data::Printer::p(). The line reading
print Data::Printer::p($expr)
will print $expr twice; it should read simply
Data::Printer::p($expr)

@choroba
Copy link

choroba commented Feb 26, 2023

See the discussion at PerlMonks.

@kcaran
Copy link

kcaran commented Mar 9, 2023

Hi. I stumbled on this a couple of years ago. The issue is with DB::Pluggable. I've finally adopted the module and updated it with a fix. The new version is 1.12 and here is the repository:

github.com/kcaran/DB-Pluggable

You can now add Data::Printer configuration in your .perldb file if you wish. I found that redirecting the output to *DB::OUT helps with displaying unicode characters correctly. Here's mine:

use DB::Pluggable;
DB::Pluggable->run_with_config( \<<EOINI );
[DataPrinter]
sort_keys = 1
colored = 1
output = *DB::OUT
theme = Solarized
string_max = 8192
EOINI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants