debug in C,Java,Python

 

languge: C Java Python
compiler: gcc -g hello_world.c javac -g HelloWorld.java

method 1:

import pdb

pdb.set_trace()

python hello_world.py

 

method 2:

python -m pdb hello_world.py

execute program: gdb ./a.out jdb Helloworld same with compiler
set breakpoint:

break 18(line number

you want to set break)

break at print()

break in 18 

break
start execution: run run  no start exection command
continue execution: continue continue continue
step execution: step step step
print variable: print your_variable_name print/dump your_variable_name p your_variable_name
show local variable: info locals locals

locals() (priority use, it will not print extra info)

globals()

dir()

eval()

nextline: next next next
show code: list list list
end execution: quit quit quit
posted @ 2025-08-31 10:39  MikeLi  阅读(5)  评论(0)    收藏  举报