LinuxCommandLibrary

pdb3.4

Debug Python 3.4 programs

SYNOPSIS

pdb3.4 [script.py | -m module] [arguments]

PARAMETERS

script.py
    (Optional) The name of the Python script to be debugged. If not provided, pdb enters an interactive mode.

-m module
    (Optional) Runs a module as a script. It searches `sys.path` for the named module and executes its contents as the `__main__` module. Use with caution in a debugging environment.

arguments
    (Optional) Any command-line arguments to be passed to the Python script being debugged.

DESCRIPTION

The `pdb3.4` command launches the Python debugger (pdb) specifically using the Python 3.4 interpreter. Pdb allows users to interactively debug Python scripts by setting breakpoints, stepping through code, inspecting variables, and evaluating expressions. It's crucial for identifying and resolving errors in Python programs.

By using `pdb3.4`, you ensure that the debugger utilizes the correct Python version for the script you're debugging. This is particularly important when working with projects that depend on specific Python versions and associated libraries. When you run a Python script with pdb3.4, execution pauses allowing inspection and control. You can use `pdb3.4` directly with the python script or import pdb within your python script and launch it using pdb.set_trace() command. It provides a powerful environment for understanding program behavior and diagnosing problems.

CAVEATS

The availability of `pdb3.4` depends on whether Python 3.4 is installed on the system and if the pdb module is accessible.

BASIC PDB COMMANDS

Some essential pdb commands include: `break` (b) for setting breakpoints, `continue` (c) for continuing execution, `next` (n) for stepping to the next line, `step` (s) for stepping into a function call, `return` (r) for continuing execution until the current function returns, `print` (p) for printing the value of a variable, and `quit` (q) for exiting the debugger.

RUNNING POST-MORTEM DEBUGGING

PDB can also be used in post-mortem debugging to examine the state of a program after an exception has occurred. You can automatically enter the debugger after an unhandled exception by using the `pdb.post_mortem()` function in conjunction with `sys.excepthook`.

HISTORY

The Python debugger, pdb, has been a standard library module in Python for many years. `pdb3.4` represents the version specifically associated with Python 3.4. Its usage and functionality have remained relatively consistent across different Python versions, with enhancements and bug fixes implemented over time.

SEE ALSO

pdb(1), python3.4(1)

Copied to clipboard