SlideShare a Scribd company logo
Debugging with PDB
Chrissy Wainwright
Debugging with PDB - Chrissy Wainwright
Who Am I?
Director of Engineering for Six Feet Up
Vice President of the Plone Foundation
Co-organizer of FayettePy
Pythonista
Debugging with PDB - Chrissy Wainwright
What is PDB?
Python Debugger
Interactive debugging tool
Debugging with PDB - Chrissy Wainwright
How to invoke it?
Set a trace directly in the code:
import pdb; pdb.set_trace()
# or in Python 3.7+
breakpoint()
Or start a script with pdb directly:
$ python -m pdb example.py
It is that easy!
Debugging with PDB - Chrissy Wainwright
Now what?
Common commands
Navigating the stack
Debugging with PDB - Chrissy Wainwright
Help
Type help or ? for short to know what
commands are available
Further help on commands help help or help
list
Debugging with PDB - Chrissy Wainwright
Show the current
context
Type list or l to see the current position in
the code
Type longlist or ll to see the whole function
Debugging with PDB - Chrissy Wainwright
Go to the next line
Type next or n to go to the next line
Debugging with PDB - Chrissy Wainwright
Examine variables
Type the variable name, hit enter!
Or type print or p to see what a variable is set
to
Use pp to pretty print the result for easier
reading
Debugging with PDB - Chrissy Wainwright
Examine available
variables
dir(variable)
args
dir()
Debugging with PDB - Chrissy Wainwright
Repeat the last
command
Just type return
Debugging with PDB - Chrissy Wainwright
Continue execution
Type continue or c to go to the next
breakpoint or finish execution
Debugging with PDB - Chrissy Wainwright
Step into a function
Type step or s to step into a function for
further inspection
Debugging with PDB - Chrissy Wainwright
Skip to the end of a
function
Type return or r to go to the end of a function
Debugging with PDB - Chrissy Wainwright
Getting out
Type quit or q to exit pdb and stop execution
Debugging with PDB - Chrissy Wainwright
Breakpoints
Type break or b to see a list of breakpoints
Then b and a line number to set one
To clear out a breakpoint clear or cl and a
breakpoint number
Debugging with PDB - Chrissy Wainwright
Conditional
breakpoints
Breakpoints can take an expression to know
when to break:
b 89, t_billable == 't'
Debugging with PDB - Chrissy Wainwright
See where you are in
the stack
Type where or w to see the current stack
You can debug at any point in the stack
Debugging with PDB - Chrissy Wainwright
Traverse the stack
Type up or u to go up the stack
Type down or d to go back down the stack
Debugging with PDB - Chrissy Wainwright
Interact
Type interact
Allows for functions, multiple lines
Ctrl + D to quit
Debugging with PDB - Chrissy Wainwright
Other options
Work on top of PDB to offer better interfaces,
tab completion, etc.
pdb++ (pdbpp)
pudb
bpdb (bpython)
Debugging with PDB - Chrissy Wainwright
Links
Python Module of the Week: PDB
In Depth PDB - Nathan Yergler
Debugging with PDB - Chrissy Wainwright

More Related Content

More from cdw9

Crafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will LoveCrafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will Love
cdw9
 
Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)
cdw9
 
Introduction to Transmogrifier
Introduction to TransmogrifierIntroduction to Transmogrifier
Introduction to Transmogrifier
cdw9
 
Contributing to Open Source
Contributing to Open SourceContributing to Open Source
Contributing to Open Source
cdw9
 
The Future of [Plone] Theming
The Future of [Plone] ThemingThe Future of [Plone] Theming
The Future of [Plone] Theming
cdw9
 
Unknown plone
Unknown ploneUnknown plone
Unknown plonecdw9
 
How to Get Started Theming Plone
How to Get Started Theming PloneHow to Get Started Theming Plone
How to Get Started Theming Plonecdw9
 
Making CSS and Firebug Your New Friends
Making CSS and Firebug Your New FriendsMaking CSS and Firebug Your New Friends
Making CSS and Firebug Your New Friends
cdw9
 
Intro to TAL
Intro to TALIntro to TAL
Intro to TAL
cdw9
 
Plone Theming in a Nutshell
Plone Theming in a NutshellPlone Theming in a Nutshell
Plone Theming in a Nutshell
cdw9
 

More from cdw9 (10)

Crafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will LoveCrafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will Love
 
Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)
 
Introduction to Transmogrifier
Introduction to TransmogrifierIntroduction to Transmogrifier
Introduction to Transmogrifier
 
Contributing to Open Source
Contributing to Open SourceContributing to Open Source
Contributing to Open Source
 
The Future of [Plone] Theming
The Future of [Plone] ThemingThe Future of [Plone] Theming
The Future of [Plone] Theming
 
Unknown plone
Unknown ploneUnknown plone
Unknown plone
 
How to Get Started Theming Plone
How to Get Started Theming PloneHow to Get Started Theming Plone
How to Get Started Theming Plone
 
Making CSS and Firebug Your New Friends
Making CSS and Firebug Your New FriendsMaking CSS and Firebug Your New Friends
Making CSS and Firebug Your New Friends
 
Intro to TAL
Intro to TALIntro to TAL
Intro to TAL
 
Plone Theming in a Nutshell
Plone Theming in a NutshellPlone Theming in a Nutshell
Plone Theming in a Nutshell
 

Recently uploaded

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Debugging with PDB

  • 1. Debugging with PDB Chrissy Wainwright Debugging with PDB - Chrissy Wainwright
  • 2. Who Am I? Director of Engineering for Six Feet Up Vice President of the Plone Foundation Co-organizer of FayettePy Pythonista Debugging with PDB - Chrissy Wainwright
  • 3. What is PDB? Python Debugger Interactive debugging tool Debugging with PDB - Chrissy Wainwright
  • 4. How to invoke it? Set a trace directly in the code: import pdb; pdb.set_trace() # or in Python 3.7+ breakpoint() Or start a script with pdb directly: $ python -m pdb example.py It is that easy! Debugging with PDB - Chrissy Wainwright
  • 5. Now what? Common commands Navigating the stack Debugging with PDB - Chrissy Wainwright
  • 6. Help Type help or ? for short to know what commands are available Further help on commands help help or help list Debugging with PDB - Chrissy Wainwright
  • 7. Show the current context Type list or l to see the current position in the code Type longlist or ll to see the whole function Debugging with PDB - Chrissy Wainwright
  • 8. Go to the next line Type next or n to go to the next line Debugging with PDB - Chrissy Wainwright
  • 9. Examine variables Type the variable name, hit enter! Or type print or p to see what a variable is set to Use pp to pretty print the result for easier reading Debugging with PDB - Chrissy Wainwright
  • 11. Repeat the last command Just type return Debugging with PDB - Chrissy Wainwright
  • 12. Continue execution Type continue or c to go to the next breakpoint or finish execution Debugging with PDB - Chrissy Wainwright
  • 13. Step into a function Type step or s to step into a function for further inspection Debugging with PDB - Chrissy Wainwright
  • 14. Skip to the end of a function Type return or r to go to the end of a function Debugging with PDB - Chrissy Wainwright
  • 15. Getting out Type quit or q to exit pdb and stop execution Debugging with PDB - Chrissy Wainwright
  • 16. Breakpoints Type break or b to see a list of breakpoints Then b and a line number to set one To clear out a breakpoint clear or cl and a breakpoint number Debugging with PDB - Chrissy Wainwright
  • 17. Conditional breakpoints Breakpoints can take an expression to know when to break: b 89, t_billable == 't' Debugging with PDB - Chrissy Wainwright
  • 18. See where you are in the stack Type where or w to see the current stack You can debug at any point in the stack Debugging with PDB - Chrissy Wainwright
  • 19. Traverse the stack Type up or u to go up the stack Type down or d to go back down the stack Debugging with PDB - Chrissy Wainwright
  • 20. Interact Type interact Allows for functions, multiple lines Ctrl + D to quit Debugging with PDB - Chrissy Wainwright
  • 21. Other options Work on top of PDB to offer better interfaces, tab completion, etc. pdb++ (pdbpp) pudb bpdb (bpython) Debugging with PDB - Chrissy Wainwright
  • 22. Links Python Module of the Week: PDB In Depth PDB - Nathan Yergler Debugging with PDB - Chrissy Wainwright