Debugging in Pharo
Damien Cassou, Stéphane Ducasse and Luc Fabresse
http://stephane.ducasse.free.fr
What You Will Learn
- The system is alive: Communicate with it
- The debugger is your best friend
- Don't be afraid of it
Debugging
Debugging
- Closing the debugger does not solve bugs
- The debugger is your best friend
- communicate with objects of the context
- check state
- send messages to specific objects
- compile code on the fly
- continue without restarting from scratch
Watch the videos and practice
Simple Trace
- used when you don't have tools
- often inefficient
- we can do better
Defining a Breakpoint
Halt now
(or self halt
)
- pause the program
- invoke the debugger
Single-Shot Halt
To enable it, evaluate
Halt once
, if enabled :
- pauses the program
- opens a debugger
- disables itself
Halt After n Iterations
Conditional Halt
if: aSelector
stops when invoked from a aSelector
if: aBlock
stops if the block evaluates to true
faces
will stop only when invoked from printString
Conditional Halt
The parameter passed to if:
can be a test name too:
faces
will stop only when invoked from testLargeDice
Create Your Own Breakpoints
now
, once
, onCount:
and if:
are methods in Halt class
- you can add your own methods, e.g.,
faces
will halt only between midnight and 2am.
What You Should Know
- The debugger is a powerful tool
- You should communicate with objects
- Breakpoints are powerful and customizable
/