[squeak-dev] The Trunk: Tools-eem.428.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Nov 15 20:59:54 UTC 2012
Eliot Miranda uploaded a new version of Tools to project The Trunk:
==================== Summary ====================
Time: 15 November 2012, 12:59:12.101 pm
Provide a run-until-expression facility for the debugger.
Thanks to Bob Arning and Bert Freudenberg for UI advice.
=============== Diff against Tools-eem.427 ===============
Item was changed:
CodeHolder subclass: #Debugger
+ instanceVariableNames: 'interruptedProcess interruptedController contextStack contextStackIndex contextStackList receiverInspector contextVariablesInspector externalInterrupt proceedValue selectingPC savedCursor isolationHead failedProject errorWasInUIProcess labelString message untilExpression'
- instanceVariableNames: 'interruptedProcess interruptedController contextStack contextStackIndex contextStackList receiverInspector contextVariablesInspector externalInterrupt proceedValue selectingPC savedCursor isolationHead failedProject errorWasInUIProcess labelString message'
classVariableNames: 'ContextStackKeystrokes ErrorRecursion InterruptUIProcessIfBlockedOnErrorInBackgroundProcess'
!Debugger commentStamp: '<historical>' prior: 0!
I represent the machine state at the time of an interrupted process. I also represent a query path into the state of the process. The debugger is typically viewed through a window that views the stack of suspended contexts, the code for, and execution point in, the currently selected message, and inspectors on both the receiver of the currently selected message, and the variables in the current context.
Special note on recursive errors:
Some errors affect Squeak's ability to present a debugger. This is normally an unrecoverable situation. However, if such an error occurs in an isolation layer, Squeak will attempt to exit from the isolation layer and then present a debugger. Here is the chain of events in such a recovery.
* A recursive error is detected.
* The current project is queried for an isolationHead
* Changes in the isolationHead are revoked
* The parent project of isolated project is returned to
* The debugger is opened there and execution resumes.
If the user closes that debugger, execution continues in the outer project and layer. If, after repairing some damage, the user proceeds from the debugger, then the isolationHead is re-invoked, the failed project is re-entered, and execution resumes in that world. !
Item was changed:
----- Method: Debugger>>codePaneMenu:shifted: (in category 'code pane menu') -----
codePaneMenu: aMenu shifted: shifted
+ add: 'run to here' target: self selector: #runToSelection: argument: thisContext sender receiver selectionInterval;
+ add: 'run until...' target: self selector: #runUntil;
- aMenu add: 'run to here' target: self selector: #runToSelection: argument: thisContext sender receiver selectionInterval.
- aMenu addLine.
super codePaneMenu: aMenu shifted: shifted.
Item was added:
+ ----- Method: Debugger>>runUntil (in category 'code pane menu') -----
+ "Step until an expression evaluates to other than false, reporting an erroer if it doesn't evaluate to true.
+ Remember the expression in an inst var. If shift is pressed when the expression is supplied, don't update the UI.
+ If shift is pressed while stepping, stop stepping. Using a user interrupt to break out would be more natural
+ but Squeak currently doesn't provide a UserInterrupt expection. It should do."
+ | expression receiver context method value lastUpdate updateUI breakOnShift |
+ expression := UIManager default
+ request: 'run until expression is true (shift to disable ui update; shift to break).'
+ initialAnswer: (untilExpression ifNil: 'boolean expression').
+ (expression isNil or: [expression isEmpty]) ifTrue:
+ updateUI := breakOnShift := Sensor shiftPressed not.
+ untilExpression := expression.
+ context := self selectedContext.
+ receiver := context receiver.
+ FakeClassPool adopt: receiver class.
+ method := receiver class evaluatorClass new
+ compiledMethodFor: untilExpression
+ in: context
+ to: receiver
+ notifying: nil
+ ifFail: [FakeClassPool adopt: nil. ^ #failedDoit]
+ logged: false.
+ lastUpdate := Time millisecondClockValue.
+ FakeClassPool adopt: nil.
+ [self selectedContext == context
+ and: [(value := receiver with: context executeMethod: method) == false]] whileTrue:
+ [self doStep.
+ Time millisecondClockValue - lastUpdate > 50 ifTrue:
+ [updateUI ifTrue: [World displayWorldSafely].
+ ifTrue: [Sensor shiftPressed ifTrue: [^self]]
+ ifFalse: [Sensor shiftPressed ifFalse: [breakOnShift := true]].
+ lastUpdate := Time millisecondClockValue]].
+ (value ~~ false and: [value ~~ true]) ifTrue:
+ [UIManager default inform: 'expression ', (untilExpression contractTo: 40), ' answered ', (value printString contractTo: 20), '!!!!']!
More information about the Squeak-dev