Introduction to debugging Python programs using PDB mode

Source: Internet
Author: User
The functionality of the Idel ribbon that used to be used under Windows has been debugged by the Python program, which has not been debugged under Linux. (many times just print) to find out from the Internet ~

Method:
Copy the 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 commands

H W
The meaning of the Print command W

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

S
Executes the current row, stopping at the first possible moment (such as having a function call on the current line). It differs from N (next) in that the current line has a function call when s (step) stops the execution of the current row and calls that function, and N does not stop until the calculation completes the line (to the next line).

B (Reak) [[Filename:]lineno | function[, Condition]
Sets a breakpoint, which can be a line number or function. such as B, b foo, b foo,n = = 5, and finally set a breakpoint at the entrance to the function foo (), but only if the value of n is 5 o'clock. When the B command has no parameters, all breakpoints are printed.

TB (reak) [[Filename:]lineno | function[, Condition]
A temporary breakpoint, hit only once.

disable [Bpnumber [Bpnumber ...]
Invalidates the breakpoint (of the Pointing line)

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

C
Continue executing the program until the next breakpoint is encountered

W
Where, where the current execution point is printed

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

P expression
Executes an expression when printing its value.

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

<直接回车>
Repeat the last command

When you encounter a command that the PDB does not recognize, it is executed as a Python expression. If you want to perform the expression, add the front top! characters, such as!n = = 5

Multiple debug commands can be written on a single line, separated by two semicolons, such 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.