As far as the OS is concerned, the running program is perl, and your script is just an argument to it. So you would do:
gdb /usr/bin/perl 1234

But this is doing to drop you into the middle of a running perl process, and you may not find that very helpful. It's easy enough to write a test script that will sleep for long enough that you can attach to it and poke around in the debugger. That should give you an idea of how to get around in the debugger, and whether or not you'll find this useful.

Ideally, you would want to drop into perl -d, but that currently isn't possible; see How to attach a perl debugger to a running perl.

I usually debug these sorts of things by printing out a lot of debugging information. Then when it's stuck, you can see the last thing it printed out to figure out what it's doing. As others have mentioned, strace/truss can also be very useful.


In reply to Re: Trying to track a sleeping CGI request with gdb by sgifford
in thread Trying to track a sleeping CGI request with gdb by talexb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.