Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How perl debugger breakpoint works?

by DanielSpaniel (Scribe)
on Sep 05, 2011 at 17:52 UTC ( #924281=note: print w/ replies, xml ) Need Help??


in reply to How perl debugger breakpoint works?

You may find it useful to see the information available by doing:

perldoc perldebug

Unless I am misunderstanding you, then using the debugger is pretty straightforward. So, for example, if you want to debug a program from the command line, you'd simply do:

perl -d program_name

... and then you can step through each line using the letter "n" (or you can just hit enter, after you've hit "n" the first time). If you want to go into a sub-routine then you type "s" instead of "n", when you get to that line (and then do "n" again once you're in there). To show line numbers when you're debugging you can just scroll through using the letter "l". Using "l" doesn't execute code, it just lists it; so, when you're done with listing it you can just carry on from where you were with an "n". If you want to break on a specific line number then, once you've started the program in debug mode you can just type in "b 99" (for example), where "99" is the line number. Then just type in "c" to continue the program. It will continue without intervention until/if it reaches the breakpoint. Once you get familiar with it you can also break on conditions too, such as when a variable =xyz.

Does that help?


Comment on Re: How perl debugger breakpoint works?
Select or Download Code
Re^2: How perl debugger breakpoint works?
by ForgotPasswordAgain (Deacon) on Sep 05, 2011 at 20:18 UTC
    He's not asking how to use the debugger, but rather how it works under the hood. See for example (based on C) "Playing with ptrace". You might be interested in perldebguts.

      Yup, I want to know how debugger works.

      I'm very familiar with its usage.

      Every debugger needs to call ptrace finally, how does the bridge between Perl code and assembly work?

        Every debugger needs to call ptrace

        Hardly.

        • For a start, ptrace is a linux api.

          Do you think other operating systems don't have debuggers?

        • Secondly, ptrace (or an equivalent) is only required if your are tracing at assembler level.

          Perl's debugger operates at the perl opcode level, each of which may represent many hundreds or thousands of assembler instructions.

          ptrace is not used by perl's debugger.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
      Yeah, realized that afterwards, but then figured it might be helpful to anybody actually looking to see how to use the debugger too. Apologies for the misguided post, and thanks for the links - very interesting to know about all that under-the-hood bits and pieces.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924281]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-20 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls