To debug a python program using PDB mode introduction _python

Source: Internet
Author: User

Previously used in Windows Idel with the function of debugging a Python program, under Linux has not been debugged. (Most of the time just print) look up the Internet

Method:

Copy Code code as follows:

PYTHON-M PDB a.py

a.py is a python file.

Common commands in (PDB) mode:

Q
Exit Debug

H is Help, print all the commands you can

H W
Meaning of Print command W

N
Executes the current line until it reaches the next line or until it returns

S
Executes the current line and stops as soon as possible (for example, there is a function call to the current row). It differs from N (next) when a function call in the current row stops the execution of the current row and calls that function, and N does not stop until the calculation completes the line (the next line is reached).

B (Reak) [[Filename:]lineno | function[, condition]]
Set breakpoints, which can be line numbers or functions. such as B, b foo, b foo,n = 5, and finally set a breakpoint at the entrance of the function foo (), but only if the value of n is 5 o'clock. Prints all breakpoints when the B command has no arguments.

TB (reak) [[Filename:]lineno | function[, condition]]
Temporary breakpoint, hit only once.

disable [Bpnumber [Bpnumber ...]]
Invalidate breakpoints on a pointing line (members)

Enable [Bpnumber [Bpnumber ...]]
Make the breakpoint on the specified line valid

C
Continue executing the program until the next breakpoint is encountered

W
Where, print the location of the current execution point

l [A, [, last]]
Output the source near the current line

P expression
Executes an expression when its value is printed.

A (RGS)
Print the parameters of the current function and their values

< direct return >
Repeat the last command

And when you encounter a command that is not recognized by the PDB, it executes as a python expression. If you want to perform the expression when the front Plus! characters, such as!n = 5

Multiple debug commands can be written on one line, separated by two semicolons, as s;; S

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.