Python debugger pdb uses detailed

[Introduction]

【Instructions】

1. Use the command:

python -m pdb xxx.py # can directly enter the single-step mode

2. Set a breakpoint debugging where it is needed (more commonly)

import pdb

pdb.set_trace()

[Common Syntax

break or b

Set a breakpoint

continue or c

Continue program execution to the next breakpoint

list or l

View the current code segment line

step or s

Enter the function

return or r

Executing code from the current until the function returns

exit or q

Abort and exit

next or n

The next line

clear or cl

Clear Breakpoint

p or pp

Print variable values

cl

Clear Breakpoint

help

help

b # print breakpoint location

b + lineno # set a breakpoint in this line

b + file: lineno # ibid.

b + function # set a breakpoint in the first line of the function

tbreak # temporary breakpoint, and b the same, but the execution will end automatically deleted

cl # Clear all breakpoints

cl + filename: lineno # Clear breakpoints

l + View vertical starting line number # Five

l + starting line number, line number # to see the end of a period of

[Other] command

jump or j

Execution to line number

w

Print function stack

disable

Disable Breakpoint

enable

Enable Breakpoint

args or a

Lists the functions currently executing function

run

Restart debug, equivalent to restart

【note】

1. When debug can change the value of the variable.

2. Direct Input Enter, will execute the command.

3. The first explanation, input commands do not know PDB, PDB python treats it as a normal command execution.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159984.htm