Tim
Tim

Reputation: 99428

How is pdb invoked when running a debugged program till a function from pdb module?

I find there are two ways to invoke pdb.

My questions are:

Upvotes: 1

Views: 304

Answers (1)

Eirik Fuller
Eirik Fuller

Reputation: 1514

On my Debian system, various versions of /usr/bin/pdb (including pdb3.5 and pdb2.7) are symlinks pointing at ../lib/python?.?/pdb.py (for the two versions of pdb I mentioned ?.? is 3.5 or 2.7). So for me the module and the script are literally the same file (with two different pathnames). The script conditionally calls pdb.main() in the usual "a python module is a script" manner.

If a debugged python program uses the pdb module without the pdb command, a common way of doing that is to insert a call to pdb.set_trace() in a suitable location (it has the same intent as a pdb breakpoint when using the pdb command).

Another common way of invoking pdb is to use pdb.run; I have used a call to pdb.run within gdb's python interpreter to debug gdb extension code written in python.

Upvotes: 1

Related Questions