Search code examples
squeakgnu-smalltalk

how can I set a breakpoint in squeak code?


Hey, friends, Squeak is powerful, I knows that the Debugger in squeak played a central role, now I wanner to set a breakpoint in squeak code, should be self: halt, My problem is that how can I quickly trace into the code-piece where I set an breakpoint?


Solution

  • Answered by myself :)

    Assume we have a suffix method add to String, and it is not a buggy method!

    1  suffix
    2  "assumes that I'm a file name, and answers my suffix, the part after the last dot"
    3    | dot dotPosition |
    4   dot := FileDirectory dot asCharacter.
    5   dotPosition := (self size to: 1 by: -1) detect: [ :i | (self at: i) = dot ].
    6   self halt.
    7   ^ self copyFrom: dotPosition to: self size
    

    notice the line 7 self halt added . we can also just edit the suspect code by inserting self halt.

    When we run this method, the execution of the self halt will bring up the pre-debugger, from where we can proceed, or go into the debugger and look at variables, step the computation, and edit the code.