SlideShare a Scribd company logo
http://www.skillbrew.com
/Skillbrew
Talent brewed by the industry itself
pdb – The interactive Debugger
Pavan Verma
@YinYangPavan
Founder, P3 InfoTech Solutions Pvt. Ltd.
1
Python Programming Essentials
© SkillBrew http://skillbrew.com
Content
 Python debugger introduction
 Enter into debugger via command line
 pdb commands
2
© SkillBrew http://skillbrew.com
PDB - The Python Debugger
1. pdb implements an interactive debugging
environment for Python programs
2. It lest you do a the following :
1. Pause your program
2. Look at the values of variables
3. Program execution step-by-step
4. Step up and down the call stack
3
© SkillBrew http://skillbrew.com
Enter into Debugger via command line
python –m pdb filename
Running the debugger from the command line causes it to
load your source file and stop execution on the first
statement it finds
4
© SkillBrew http://skillbrew.com
Enter into Debugger from within program (1)
import pdb
pdb.set_trace()
Use pdb.set_trace()in the program where
ever you want the program to enter into the
debugger
5
© SkillBrew http://skillbrew.com
pdb commands
list or l
Using list with a single
numerical argument lists 11
lines around that line
instead of the current line
6
© SkillBrew http://skillbrew.com
pdb commands (2)
where
At any point while the
debugger is running
you can use where
(abbreviated w) to find
out exactly what line is
being executed and
where on the call stack
you are
7
© SkillBrew http://skillbrew.com
pdb commands (3)
step
Use step to execute the
current line and then stop
at the next execution
point – either the first
statement inside a
function being called or
the next line of the
current function
8
© SkillBrew http://skillbrew.com
pdb commands (4)
next or n:
The next command is like
step, but does not enter
functions called from the
statement being executed. In
effect, it steps all the way
through the function call to
the next statement in the
current function in a single
operation.
9
© SkillBrew http://skillbrew.com
pdb commands (5)
up (u) and down (d)
• Move between frames
within the current call stack
using up and down
• up (abbreviated u) moves
towards older frames on
the stack
• down (abbreviated d)
moves towards newer
frames
10
© SkillBrew http://skillbrew.com
Resources
 http://docs.python.org/2/library/pdb.html
11
12

More Related Content

PPTX
Python Programming Essentials - M27 - Logging module
PPTX
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
PPTX
Python Programming Essentials - M6 - Code Blocks and Indentation
PPTX
Python Programming Essentials - M7 - Strings
PPTX
Python Programming Essentials - M18 - Modules and Packages
PDF
Python Testing Fundamentals
PPT
Command line arguments.21
ODP
Gcc opt
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M7 - Strings
Python Programming Essentials - M18 - Modules and Packages
Python Testing Fundamentals
Command line arguments.21
Gcc opt

What's hot (20)

PPT
Rifartek Robot Training Course - How to use ClientRobot
PPT
What do you mean it needs to be Java based? How jython saved the day.
PPT
Presentation_C++UnitTest
PPTX
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
PPT
Communication between Java and Python
PPTX
Python Programming Essentials - M9 - String Formatting
PPT
Google C++ Testing Framework in Visual Studio 2008
PPTX
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
PDF
Firefox Easily Analyzed by PVS-Studio Standalone
ODP
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
PPT
Perl Modules
ODP
Testing Toolbox
PPTX
Oop object oriented programing topics
PDF
Codeception: introduction to php testing (v2 - Aberdeen php)
PDF
Analysis of merge requests in GitLab using PVS-Studio for C#
PPTX
Command line arguments
PDF
Karma - JS Test Runner
PPTX
Preprocessor
PPTX
Dead-Simple Async Control Flow with Coroutines
Rifartek Robot Training Course - How to use ClientRobot
What do you mean it needs to be Java based? How jython saved the day.
Presentation_C++UnitTest
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Communication between Java and Python
Python Programming Essentials - M9 - String Formatting
Google C++ Testing Framework in Visual Studio 2008
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
Firefox Easily Analyzed by PVS-Studio Standalone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
Perl Modules
Testing Toolbox
Oop object oriented programing topics
Codeception: introduction to php testing (v2 - Aberdeen php)
Analysis of merge requests in GitLab using PVS-Studio for C#
Command line arguments
Karma - JS Test Runner
Preprocessor
Dead-Simple Async Control Flow with Coroutines
Ad

Viewers also liked (17)

PPTX
Python Programming Essentials - M40 - Invoking External Programs
PPTX
Python Programming Essentials - M31 - PEP 8
PPTX
Python Programming Essentials - M44 - Overview of Web Development
PPTX
Python Programming Essentials - M35 - Iterators & Generators
PPTX
Python Programming Essentials - M39 - Unit Testing
PPTX
Python Programming Essentials - M4 - Editors and IDEs
PPTX
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
PPTX
Python Programming Essentials - M8 - String Methods
PPTX
Python Programming Essentials - M23 - datetime module
PPTX
Python Programming Essentials - M21 - Exception Handling
PPTX
Python Programming Essentials - M1 - Course Introduction
PPTX
Python Programming Essentials - M25 - os and sys modules
PPTX
Python Programming Essentials - M29 - Python Interpreter and Files
PPTX
Python Programming Essentials - M34 - List Comprehensions
PPTX
Python Programming Essentials - M5 - Variables
ODP
Introduction To Django
PPTX
Python Programming Essentials - M15 - References
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M4 - Editors and IDEs
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M1 - Course Introduction
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M5 - Variables
Introduction To Django
Python Programming Essentials - M15 - References
Ad

Similar to Python Programming Essentials - M28 - Debugging with pdb (20)

PDF
Open Dayligth usando SDN-NFV
PPT
gdb.ppt
PDF
OpenPOWER Application Optimization
PPTX
Openshift Presentation ppt compare with VM
PPTX
Debugging Modern C++ Application with Gdb
PDF
Python debuggers slides
PDF
Buffer overflow tutorial
DOCX
Python introduction
PPT
ES-CH5.ppt
PDF
Reverse engineering – debugging fundamentals
PDF
ECET 360 help A Guide to career/Snaptutorial
PDF
ECET 360 help A Guide to career/Snaptutorial
PDF
Make your application expressive
PDF
Becoming A Plumber: Building Deployment Pipelines - LISA17
PPTX
assisgnment 2 python.pptx important questions
PPTX
Wavedigitech gdb
PDF
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
PDF
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
DOCX
Debugger & Profiler in NetBeans
PDF
Architecting the Future: Abstractions and Metadata - KCDC
Open Dayligth usando SDN-NFV
gdb.ppt
OpenPOWER Application Optimization
Openshift Presentation ppt compare with VM
Debugging Modern C++ Application with Gdb
Python debuggers slides
Buffer overflow tutorial
Python introduction
ES-CH5.ppt
Reverse engineering – debugging fundamentals
ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
Make your application expressive
Becoming A Plumber: Building Deployment Pipelines - LISA17
assisgnment 2 python.pptx important questions
Wavedigitech gdb
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
Debugger & Profiler in NetBeans
Architecting the Future: Abstractions and Metadata - KCDC

More from P3 InfoTech Solutions Pvt. Ltd. (9)

PPTX
Python Programming Essentials - M24 - math module
PPTX
Python Programming Essentials - M22 - File Operations
PPTX
Python Programming Essentials - M20 - Classes and Objects
PPTX
Python Programming Essentials - M17 - Functions
PPTX
Python Programming Essentials - M16 - Control Flow Statements and Loops
PPTX
Python Programming Essentials - M14 - Dictionaries
PPTX
Python Programming Essentials - M13 - Tuples
PPTX
Python Programming Essentials - M12 - Lists
PPTX
Python Programming Essentials - M11 - Comparison and Logical Operators
Python Programming Essentials - M24 - math module
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M14 - Dictionaries
Python Programming Essentials - M13 - Tuples
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M11 - Comparison and Logical Operators

Python Programming Essentials - M28 - Debugging with pdb