friends As showed on the title, while I am debugging in squeak4.1, the menu "debug it" is powerful, there have Proceed, Restart, Into, Over, Through buttons etc. Each time wh开发者_如何学编程en I enter Into button, I can trace into the specific code, But what is the diffenrce of Over and Through buttons?
The Squeak debugger can be a bit intimidating at first. Let's examine the various parts of it.
The context stack
The list at the top of the debugger window is a representation of the context stack or call stack. A context is the state of an active block or method.
The topmost context in the stack is the one currently executing. Normally after returning from a context program execution resumes in the context bellow it (i.e. the context of it's sender).
The code pane
The code for the method highlighted in the context stack is shown in the code pane at the center of the debugger window and the current statement in that method is highlighted.
Instance and context variables
At the bottom of the debugger window there are two watch lists used for displaying variables.
The list on the left contains all the instance variables for the receiver of the current method. The list on the right contains all the temporary variables in the current context.
When a variable is selected in those list its value is displayed in the space at the right of the list.
Debugger buttons
Here's what the debugger buttons do supposing the debugger is in the state shown in this image:
Proceed: Close the debugger and proceed.
Continue the program execution normally. Here display "12345" on the transcript, make a beep sound, return to #someMethod
and so on...
Restart: Reset the context to its start.
Restart execution of the current stack context highlighting its first message send (here to: 5
) again.
Into: Step into the message sends
Step inside a method (here Interval>>do:
) highlighting the first message send inside it.
Over: Step over message send
Execute the highlighted message send (#do:
) and highlight the next one (#beep
).
Through: Step into a block
Step through code like over except that the debuggers also halts when entering any context whose code is part of the currently displayed method. Here that means:
- The execution halt inside the
[:each | Transcript show: each]
) block instead of stepping over the whole#do:
call in one go. - When returning from the block the debugger steps up to the next point in this method instead of retuning to the place where the block was evaluated (i.e. inside
Interval>>do:
).
Some simple block construct like ifTrue: []
and ifFalse: []
are not compiled as actual message sends and the debugger always step inside such blocks whether Over or Through is used.
Full Stack: Show full stack
Show more frames in the stack pane.
Run to Here: Run to Selection
For instance if you highlight the text "beep" in this method the program will resume and halt just before the #beep
message send.
Where: Select current pc range
If the cursor was moved re-highlight the next message send in the code pane (here do: [:each |Transcript show: each]
).
Other features
The Squeak debugger also allows you to:
- easily create a missing method by clicking the Create button when you get a DNU
- let you edit code directly in the debugger
- evaluate bits of code using the do it (cmd-a) and print it (cmd-p) commands in the code
- open a browser or inspector from the context menu of stack, variable list and code pane
精彩评论