SIGSEGV has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Wisdom Holders,

I'm a newbie in your divine monastery. So please be clement if my posting here offends your code of conduct. (I haven't discovered all corners of the monastery yet, nor have read the FAQs thoroughly)

I got so accustomed to the nice built-in Perl debugger that I can hardly do without anymore.

Recently I upgraded my Perl from 5.6.0 to 5.8.0 i.e. built it from the source tarball stable.tar.gz on HP-UX 11.00 and 11.11

I used the the HP-UX ANSI C compiler because I needed to install DBD::Oracle as well, which caused me too much grief to build with GNU gcc until I got hold of the HP compiler.

My bearable though annoying "trouble" with this build is the strange behaviour of the Perl debugger.

When I built this Perl 5.8.0 I only had the standard HP-UX pager more on the box and no PAGER env var set. Later I additionally installed the GNU Pager less.

I like to inspect my nested data structures in the Perl debugger. Especially the Data::Dumper like dump when one is x'ing a LoL reference is a nice feature.

e.g. DB<1> x \%nested_hash Since these can get quite large I used to pipe it into my pager like DB<2> |x \%nested_hash But somehow this feature doesn't seem to work in the Perl 5.8.X debugger anymore.

I tried all feasible sorts of invocation.

e.g.

PAGER=/usr/local/bin/less perl -d buggy_script.pl export PAGER=/usr/local/bin/less perl -d buggy_script.pl
or within the debug session
DB<3> o pager=/usr/local/bin/less pager = '|/usr/local/bin/less' DB<4> o pager? pager = '|/usr/local/bin/less'
or   DB<5> $ENV{PAGER}='/usr/local/bin/less' I even tried to edit a .perldb file though I found no sample or hints on the required format in "perldoc DB".

So probably wrong syntax here, I tried

vi .perldb $DB::option{pager}='/usr/local/bin/less'
Well, all these tricks didn't work at all.

The output may be piped through the pager (because there is a short but noticable latency), but nothing gets displayed on the debugger screen.

Here's an example

DB<2> o pager? pager = '|/usr/bin/more' DB<3> |x \%mnt DB<4> @a=1..100 DB<5> |x @a DB<6> o pager? pager = '|/usr/bin/more' DB<7> o pager=/usr/local/bin/less pager = '|/usr/local/bin/less' DB<8> !5 |x @a DB<9> x @a&#091;0..4] 0 1 1 2 2 3 3 4 4 5 DB<10> |x @a DB<11> p exists $ENV{PAGER} DB<12> $ENV{PAGER}='/usr/local/bin/less' DB<13> p $ENV{PAGER} /usr/local/bin/less DB<14> !10 DB<15>
Has anyone come accross this who could tell me what the remedy is?

Regards

Edit by tye to replace PRE with proper formatting

Replies are listed 'Best First'.
Re: Perl 5.8.0 debugger annoyances
by demerphq (Chancellor) on Dec 09, 2002 at 18:53 UTC
    There has been a lot of discussion about how the debugger has been broken in recent releases by poorly thought out additions and modification to the interface. One of the best comments came from Dominus
      But it seems to me that this problem really stems from the fact that the internals of the debugger are so crabbed. If they were more rational and open, with more hooks, then it would be easier to extend or alter the command set on a per-user basis. As it is, we get a new, ill-thought-out patch to perl5db.pl every time some pinhead wants another extension.
    As for a remedy, I dont know, suffice it say that with the number of p5p people getting annoyed about it recently id say theres a good chance somebody will get the tuits to sort it out.

    --- demerphq
    my friends call me, usually because I'm late....

Re: Perl 5.8.0 debugger annoyances
by Jaap (Curate) on Dec 09, 2002 at 15:30 UTC
    Well SIGSEGV,

    That's quite a story. Although i am not familiar with the ins and outs of HP-UX i assume just typing
    x @a
    works. Now did you try the normal approach like this:
    x @a |more
    does that work?

      Hi Jaap,

      first of all I should apologize for not having read the bottom of this page where it explicitly says not to use <pre> tags but to use the <code> tag instead for its enhanced feature set and mainly for braking lines.

      I also have to thank tye for reediting my post, and making it thus more readable. I mistook this kind intervention for some moderation by the site maintainers.
      Sorry, for causing you invonvenience but this site has such a bewildering, barockesque adornment just like Perl's idiomatic syntax which makes it a bit difficult for the newbie (viz. TIMTOWDI)

      Now back to the subject.
      I forgot to mention that not only the piping mechanism is broken but the same goes for shell escapes from the debugger's prompt.
      In my pre-5.8.0 Perls I could do this with the double bang.

      e.g.

      DB<1> !!pwd
Re: Perl 5.8.0 debugger annoyances
by pg (Canon) on Dec 10, 2002 at 04:08 UTC
    The pager functionality is fine in Perl 5.8.0 debug, and I tested.

    What you need to do is to set environment variable PAGER from your OS/shell, before you start debug. It is too later, to set $ENV{PAGER} after you start your debug. That does not work.

    Why? it is simple. There is a file called perl5db.pl in the lib directory, which determines the behavior of perl -d. Examine that file, you will find, perl reads in $ENV{PAGER} once after you start your debug, and then saved the value in a variable named $pager. After that, it just use the value stored in $pager, and never check ENV again. Now, it is clear.
      Hi pg,

      gathering from your nick name, if not you who else should be familiar with the inards of pagers ;-)

      n.b. @ perlmonks' moderators, sorry for using the <pre> tag once again. When I logged in I just noticed for a second your request on my first posting here to refrain from using this tag. I'm afraid, I still will have to read your FAQs on formatting guidelines. I have been too impatient to reply to my post's responders, and didn't know for now how else to avoid the clutter.

      Now back to pg.
      Of course I felt that setting $ENV{PAGER} within the debug session was at a too late stage. That's why I already tried the shell's (i.e. HP-UX's standard shell which is a POSIX Bourne type) way of giving processes an environment by invocating the Perl debugger like this:

      $ PAGER=/usr/local/bin/less /usr/bin/perl -de ./my_buggy_script.pl
      (of course one could have also used the Unix "env" command)

      and I also tried the even better way (like you mentioned) of explicitly exporting PAGER:

      $ export PAGER=/usr/local/bin/less $ printenv PAGER /usr/local/bin/less $ perl -de my_buggy_script.pl
      Then in the debugger I did this:
      'time' => 1039509243 '/var/spool/sw' => HASH(0x4033aca0) 'basetype' => 'vxfs' 'bavail' => 262045 'bfree' => 279512 'blocks' => 512000 'bsize' => 8192 'favail' => 69876 'ffree' => 69876 'files' => 73740 'flag' => 0 'frsize' => 1024 'fsid' => 1073741834 'fstr' => '/var/spool/sw' 'namemax' => 255 'size' => 512000 'time' => 1037307204 DB<4> H 3: x \%mnt 2: |x \%mnt 1: o pager? DB<4> !1 o pager? pager = '|/usr/local/bin/less' DB<5>
      n.b. the hash %mnt is a lol with mount points as keys and as values the results of statvfs syscalls on these as a hashref (retrieved through the wonderful Filesys::Statvfs CPAN module).

      By the debugger history above I just wanted to show that "|x \%mnt" fails (i.e. displays nothing), whereas "x \%mnt" scrolls over the screen (I only copied the last key's value here).

      This only happens with my Perl builds of "new" releases > 5.6.0 On the boxes where I still have Perl <= 5.6.0 the debugger works as expected, and honours preset PAGER settings.

      Looks to me as if there is a bug in the Perl port for HP-UX 11.X 64Bit.

      Btw, have you tried to build a Perl 5.8.X on HP-UX (in case you have access to this platform)? Maybe the Configure routine is broken for this platform. I can tell you how long I struggled to get DBD::Oracle working on this platform. Maybe I miss some library, patch, or the linking was insufficient after Configure and make (e.g. PIC etc.)

      Would be nice to here from someone who uses the Perl debugger on HP-UX if they encounter similar strangenesses.

      Anyway, many thanks for pointing me to the involved Perl code.

      Edit by tye (replace PRE with formatting)