Introduction to Python program debugging in PDB mode and python debugging in pdb Mode

Source: Internet
Author: User

Introduction to Python program debugging in PDB mode and python debugging in pdb Mode

I used the idel feature in windows to debug python programs. I have not debugged python programs in linux. (Most of the time it's just print) search for it online ~

Method:
Copy codeThe Code is as follows:
Python-m pdb a. py

A. py is a python file.

Common commands in (Pdb) mode:

Q
Exit debug

H is the help, print all commands available

H w
Print the meaning of command w

N
Execute the current row until it reaches the next line or until it returns

S
The execution of the current row may stop as soon as possible (for example, there is a function call in the current row ). The difference between this function and n (next) is that s (step) will stop the execution of the current row when there is a function call in the current row, and n will not stop, until the calculation is complete (to the next line ).

B (reak) [[filename:] lineno | function [, condition]
Set the breakpoint, which can be a row number or function. For example, B 10, B foo, B foo, n = 5. Finally, a breakpoint is set at the entrance of the function foo (), which is valid only when the value of n is 5. When command B has no parameters, all breakpoints are printed.

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

Disable [bpnumber [bpnumber...]
Make the breakpoint of the pointing line invalid

Enable [bpnumber [bpnumber...]
Make the breakpoint on the specified row valid

C
Execute the program until the next breakpoint occurs.

W
That is, where: prints the position of the current execution point

L [first, [, last]
Output source code near the current line

P expression
Execute an expression to print its value.

A (rgs)
Print the parameters and values of the current function

<Press enter directly>
Repeat the previous command

If a command is not recognized by pdb, it is executed as a python expression. If you want to execute the expression, add the first! Characters, such! N = 5

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

Related Article

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.