Breakpoints and Probes in VisualWorks
In VisualWorks, breakpoints are added to methods by adding a probe. A probe is a more powerful concept than a breakpoint, which will always stop execution whenever the code is executed.
Probes in VisualWorks have a "trigger condition" code snippet. The purpose of the code is to answer a Boolean value indicating whether the probe should halt (like a breakpoint) or simply continue when its method is executed.
Since you execute any Smalltalk code you like in a probe, anything can be done. As an example, the following code snippet in a probe will log the method having the probe in the transcript window:
Transcript cr; show: DOITCONTEXT displayString.
false
Note that I end the code with "false", just to skip breaking on the method. Below is another, more powerful example. In this code the probe removes itself.
|method|
method := DOITCONTEXT method.
method allProbesDo: [:each | method basicRemoveProbe: each].
false
Would removing the probe ever be useful? Well, you can add probes to methods you want to mark as "not executed yet". Then you can execute some code, and finally use the browsers to see which probes are left. This is commonly known as "code coverage". There exists special tools for code coverage in Smalltalk , and I will cover these later.
Anyway, probes can function as a "quick & dirty" code coverage tool. Also note that probes can be inserted (in one single operation) on multiple methods. For example, you can use the Rewrite Tool to find a set of methods, and add the same type of probe to this set.