You are on page 1of 2

Experiment :3

Aim: Perform Debugging Using Bug tracking tool like PDP in Python .
Introduction: In the context of software engineering, debugging is the process of fixing
a bug in the software. In other words, it refers to identifying, analyzing and removing
errors. This activity begins after the software fails to execute properly and concludes by
solving the problem and successfully testing the software.
Debugging Process: Steps involved in debugging are:
• Problem identification and report preparation.
• Assigning the report to software engineer to the defect to verify that it is genuine.
• Defect Analysis using modeling, documentations, finding and testing candidate
flaws, etc.
• Defect Resolution by making required changes to the system.
• Validation of corrections

PDP- THE PYTHON DEBUGGER

The module pdb defines an interactive source code debugger for Python programs. It
supports setting (conditional) breakpoints and single stepping at the source line level,
inspection of stack frames, source code listing, and evaluation of arbitrary Python code
in the context of any stack frame. It also supports post-mortem debugging and can be
called under program control.The debugger is extensible – it is actually defined as the
class Pdb. This is currently undocumented but easily understood by reading the source.
The extension interface uses the modules bdb and cmd.

The debugger’s prompt is (Pdb). Typical usage to run a program under control of the
debugger is:

>>> import pdb

>>> import mymodule


>>> pdb.run('mymodule.test()')
> <string>(0)?()
(Pdb) continue
> <string>(1)?()
(Pdb) continue
NameError: 'spam'
> <string>(1)?()
(Pdb)

Getting started:
• start pdb from within a script:
• import pdb;pdb.set_trace()
• start pdb from the commandline: python -m pdb

Basics

• h(elp) print available commands


• h(elp) command print
• help about command q(quit) quit debugger

Movement

• repeat the last command


• n(ext) execute the current statement (step over)
• s(tep) execute and step into function
• r(eturn) continue execution until the current function returns
• c(ontinue) continue execution until a breakpoint is encountered
• u(p) move one level up in the stack trace d(own) move one level down in the stack trace

Breakpoints

• b(reak) show all breakpoints


• b(reak) lineno set a breakpoint at lineno
• b(reak) func set a breakpoint at the first line of a func

You might also like