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

is there a way to set e.g. breakpoints & actions from a side file when starting perl debug? That is, I'd really like not to have to re-enter my breakpoints etc. manually at the debugger command prompt, and instead put them in a file which the debugger will read whenever it starts.
(I'm sure there is a way, given perl's ability to do everything, but i can't figure it out -- ./.perldb doesn't seem to do breakpoints but maybe i've missed it in man perldebug?)
thanks for any hints
alan

Replies are listed 'Best First'.
Re: perl debug options file
by osunderdog (Deacon) on Oct 26, 2004 at 18:00 UTC

    There is more information in perldoc perldebguts that would be helpful to you. Also, here is my ~/.perldb file:

    print "Reading ~/.perldb options.\n"; parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=4 inhibit_e +xit=1 DumpPackages=1"); parse_options("windowSize=25 ");

    Hope this helps.


    "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


    OSUnderdog

      Ah, I learned something new. Here is another .perldb file with the breakpoint stuff:

      print "Reading ~/.perldb options.\n"; parse_options("NonStop=0 LineInfo=db.out AutoTrace=1 frame=4 inhibit_e +xit=1 DumpPackages=1"); parse_options("windowSize=25 "); sub afterinit { push @DB::typeahead, "b 22", "b 23";}

      "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


      OSUnderdog
      Great. Many thanks to you both!

      update: hmm - not so fast alan

      unfortunately 'source' doesn't seem to be supported by our version of perl (version 5.005_03 built for MSWin32-x86-object) ... will get newer perl to try

      and using the .perldb example doesn't print "Reading ~/.perldb options" ... maybe will be fixed by newer perl?
      (or perhaps .perldb should be in a different directory than the current working dir? will investigate, though 'perldebguts' isn't found by perldoc on my system either) ... onward!

        Well, you didn't tell me it was windows! ;) Details details. I don't think it's a perl version issue. Although I have slept since then, I do remember running this on perl 5.005.

        I think the debugger is having trouble finding the .perldb file. I tried putting the .perldb file in %HOME% with no luck.

        An alternative suggestion for you. If you are in a long debugging session (debug, tweak, debug...), you could add $DB:single=1 at locations in your script that you're trying to debug. Then when you run perl with the -d option, the script will break right after the $DB:single=1 line.

        Just an alternative. I don't have an answer for the .perldb issue. *sorry*


        "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


        OSUnderdog
Re: perl debug options file
by fglock (Vicar) on Oct 26, 2004 at 17:46 UTC

    Use the source - it is a debugger command:

    source file Read and execute debugger commands from file. file may itself contain "source" commands.