Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDB won't stop on breakpoint

Tags:

I'm quite new with debugging directly with pdb and I am having some issues debugging my Django application. Here is what I'm doing:

python -m pdb manage.py runserver (pdb) b core/views.py:22 Breakpoint 2 at /Users/raphaelcruzeiro/Documents/Projects/pdb_test/core/views.py:22 (Pdb) c 

However the execution passes directly through the breakpoint. Am I missing some command? The manual doesn't elaborate on setting a breakpoint anymore than this.

like image 636
Raphael Avatar asked Sep 30 '11 23:09

Raphael


People also ask

How do I force quit pdb?

Whenever you want to leave the pdb console, type the command quit or exit . If you would like to explicitly restart a program at any place within the program, you can do so with the command run .

How do you stop a breakpoint in Python?

set_trace() at the corresponding line in the Python code and execute it. The execution will stop at the breakpoint. An interactive shell (the pdb shell) will appear and allows you to run regular Python code, i.e. to print the current contents of variables and data structures.

How do you end a breakpoint?

Disable the breakpoint. from pdb, just type disable N, where N is the breakpoint number you are stuck on. If you don't know the number of your troubling breakpoint, enter tbreak.

Does breakpoint stop before or after line?

The breakpoint will stop your program just before it executes any of the code on that line. Set a breakpoint at line linenum in source file filename . Set a breakpoint at entry to function function found in file filename .


1 Answers

I've been through the same problem.

Try something like python -m pdb ./manage.py runserver --nothreading --noreload 127.0.0.1:8080. It solved the issue for me.

It seems that breakpoints with PDB are thread-specific, and the --nothreading and --noreload options are necessary to avoid some forking that may confuse PDB. This is also why set_trace works, as it's called directly inside the thread of interest.

like image 62
Gustavo Meira Avatar answered Sep 18 '22 13:09

Gustavo Meira