Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.2069.mcz
==================== Summary ====================
Name: Morphic-mt.2069
Author: mt
Time: 20 January 2023, 3:49:44.701382 pm
UUID: 54851436-afad-d543-837a-1705eb3d1905
Ancestors: Morphic-mt.2068
Complements System-mt.1384
=============== Diff against Morphic-mt.2068 ===============
Item was changed:
----- Method: MorphicProject>>openDebuggerWindow: (in category 'scheduling & debugging') -----
openDebuggerWindow: windowOrModel
+ "Open the debugger window in the world. Verify integrity of visual representation here so that recursive-error detection kicks in immediately. See #guardRecursiveError:during:."
- "Open the debugger window in the world. Verify integrity of visual representation here so that recursive-error detection kicks in immediately."
| window |
window := self uiManager toolBuilder open: windowOrModel.
"There are way too many #fullBounds sends. Layout errors might already have happened."
window allMorphsDo: [:m |
(m hasProperty: #errorOnLayout)
ifTrue: [self error: 'Layout error' translated]].
"Try layouting the debugger tool at least once to avoid freeze."
self world doLayout. "Not safely!! to trigger layout errors if any"
"Try redrawing the UI at least once to avoid freeze."
self world displayWorld. "Not safely!! to trigger drawing errors if any"!
Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1185.mcz
==================== Summary ====================
Name: Tools-mt.1185
Author: mt
Time: 20 January 2023, 3:49:16.090382 pm
UUID: 094aa194-809e-394a-9cdd-33097af84d33
Ancestors: Tools-mt.1184
Complements System-mt.1384
=============== Diff against Tools-mt.1184 ===============
Item was changed:
----- Method: Debugger class>>openOn:context:label:contents:fullView: (in category 'opening') -----
+ openOn: process context: context label: title contents: contentsStringOrNil fullView: bool
+ "PRIVATE!! Open a notifier or a full debugger window for the given process
+ at the given context. Clients MUST use a ToolSet that is configured with the
+ receiver class (or tool) to then debug a process via
+ Process >> #debug(WithTitle:)
+ ProcessorScheduler >> #debugWithTitle:
+ ToolSet >> #debugProcess:context:...
+ and similar messages in Process or ProcessorScheduler.
- openOn: process context: context label: titleOrNil contents: contentsStringOrNil fullView: bool
- "Open a notifier or a full debugger window for the given process at the given context. Decorates that invocation with (1) recursive-error detection and (2) error logging, which are both independent from the active GUI framework, that is, MVC or Morphic.
+ Example invocations:
+ Processor debugWithTitle: 'Example'.
+ (Process forBlock: [3+4]) debug.
+ 7/0.
- Note that clients should debug processes through Process >> #debug or ToolSet instead of calling this method directly."
-
- | activeProcess title |
- activeProcess := Processor activeProcess.
- title := titleOrNil ifNil: ['Debugger' translated].
+ Configure a new tool set like this
+ ToolSet default: StandardToolSet
+ See commentary in
+ Process >> #debugWithTitle:full:contents:
+ ProcessorScheduler >> #debugContext:title:full:contents:"
- "If the active process re-enters this method again, something went wrong with invoking the debugger."
- activeProcess hasRecursiveError ifTrue: [
- activeProcess clearErrorRecursionFlag.
- ^ ToolSet handleRecursiveError: title].
-
- "Explicitely handle logging exceptions. No need to bother the recursion mechanism here."
- [Preferences logDebuggerStackToFile
- ifTrue: [Smalltalk logSqueakError: title inContext: context]
- ] on: Error do: [:ex |
- Preferences disable: #logDebuggerStackToFile.
- ToolSet debugException: ex].
+ ^ (self onProcess: process context: context)
+ openWithLabel: title
+ contents: contentsStringOrNil
+ fullView: bool;
+ yourself!
- "If project-specific debuggers mess up, we have to flag that recursion here. See above."
- [activeProcess setErrorRecursionFlag.
- ^ (self onProcess: process context: context)
- openWithLabel: title contents: contentsStringOrNil fullView: bool;
- yourself
- ] ensure: [activeProcess clearErrorRecursionFlag].!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1384.mcz
==================== Summary ====================
Name: System-mt.1384
Author: mt
Time: 20 January 2023, 3:48:54.016382 pm
UUID: 85b1fd2e-0162-b54c-b735-f046350d97ad
Ancestors: System-mt.1383
Move (1) recursive-error detection and (2) stack-to-file logging from Debugger class to ToolSet/Project so that custom (process) debugging tools cannot omit to include these features.
Note that, by now, most of the actual "debugging logic" is simply contained in
- Context and Process (for code simulation, i.e., step into etc.)
- Project and subclasses (for GUI/system responsiveness protection, i.e., recursive error detection, project fallback, emergency evaluator, ...)
It's now easier to write a custom debugger, install it through a custom toolset, and then use it for the next unhandled error.
=============== Diff against System-mt.1383 ===============
Item was changed:
----- Method: Process>>debug (in category '*System-debugging') -----
debug
"See the comment in #debugWithTitle:full:contents:."
+ ^ self debugWithTitle: 'Debugger' translated!
- ^ self debugWithTitle: nil!
Item was added:
+ ----- Method: Project>>debugProcess:inDialog: (in category 'scheduling & debugging') -----
+ debugProcess: aProcess inDialog: aMessageText
+ "Inform the user about a debugging incident where no interactive debugger is available. Give a choice between #terminate and #inspect. Suspend the process anway."
+
+ self addDeferredUIMessage: [
+ (self uiManager confirm: aMessageText, '\\Terminate process?' translated withCRs)
+ ifTrue: [aProcess terminateAggressively]
+ ifFalse: [aProcess inspect]].
+
+ self suspendProcessSafely: aProcess.
+
+ ^ nil "There is no debugger tool to answer."!
Item was added:
+ ----- Method: Project>>guardRecursiveError:during: (in category 'scheduling & debugging') -----
+ guardRecursiveError: errorMessage during: workBlock
+
+ "If the active process re-enters this method again, something went wrong with invoking the debugger."
+ Processor activeProcess hasRecursiveError
+ ifTrue: [
+ Processor activeProcess clearErrorRecursionFlag.
+ ToolSet handleRecursiveError: errorMessage].
+
+ "If project-specific debuggers mess up, we have to flag that recursion here."
+ Processor activeProcess setErrorRecursionFlag.
+ ^ workBlock ensure: [Processor activeProcess clearErrorRecursionFlag]!
Item was changed:
----- Method: SmalltalkImage>>logError:inContext:to: (in category 'miscellaneous') -----
logError: errMsg inContext: aContext to: aFilename
"Log the error message and a stack trace to the given file."
+ FileStream forceNewFileNamed: aFilename do: [:stream |
+ stream nextPutAll: (errMsg ifNil: ['(unspecified error)']); cr.
+ aContext errorReportOn: stream].!
- | ff |
- FileDirectory default deleteFileNamed: aFilename ifAbsent: [].
- (ff := FileStream fileNamed: aFilename) ifNil: [^ self "avoid recursive errors"].
-
- ff nextPutAll: errMsg; cr.
- aContext errorReportOn: ff.
- ff close.!
Item was added:
+ ----- Method: SmalltalkImage>>tryLogSqueakError:inContext: (in category 'miscellaneous') -----
+ tryLogSqueakError: errorMessage inContext: aContext
+ "Log error message and stack trace in file. Can be disabled via preference. Guard errors to avoid recursive error."
+
+ Preferences logDebuggerStackToFile ifFalse: [^ false].
+
+ [Smalltalk logSqueakError: errorMessage inContext: aContext]
+ on: Error do: [:ex |
+ Preferences disable: #logDebuggerStackToFile.
+ ToolSet debugException: ex.
+ ^ false].
+
+ ^ true!
Item was changed:
----- Method: ToolSet class>>debugProcess:context:label:contents:fullView: (in category 'debugging') -----
debugProcess: aProcess context: aContext label: aString contents: contents fullView: aBool
+ "Open a debugger on the given process, which might be active, suspended, or terminated. You can also use the convenience protocol for debugging on Process and ProcessorScheduler.
+
+ NOTE that you SHOULD NOT pass 'Processor activeProcess' directly to this method to avoid mixing code simulation with genuine code execution. Always use the indirection via ProcessorScheduler >>#debug... See also the comment in Process >> #debugWithTitle:full:contents:."
- "Open a debugger on the given process, which might be active, suspended, or terminated. You can also use the convenience protocol for debugging on Process and ProcessorScheduler. NOTE that you should not pass Processor activeProcess directly to this method. Always use the indirection via ProcessorScheduler >>#debug... See also the comment in Process >> #debugWithTitle:full:contents:."
+ "First, guard this incident to detect and handle recursive errors."
+ ^ Project current guardRecursiveError: aString during: [
+
+ "In any case, log the debugging incident into an external file."
+ Smalltalk tryLogSqueakError: aString inContext: aContext.
+
+ self default
+ ifNotNil: [:toolSet |
+ "Let the current tool set decide about the best tool for the job."
+ toolSet
+ debugProcess: aProcess context: aContext
+ label: aString contents: contents
+ fullView: aBool]
+ ifNil: [
+ "There is no tool set!! :-O ... Inform the user in a simple dialog."
+ Project current
+ debugProcess: aProcess
+ inDialog: ('No debugger available for process:\\ Name: {1}\ Hash: {2}\ Context: {3}\ Title: {4}\ Message: {5}' translated withCRs
+ format: {aProcess name. aProcess hash. aContext. aString. contents})] ]!
- ^ self default
- ifNil: [(self confirm: 'Debugger request -- proceed?' translated) ifFalse: [Processor terminateActive]]
- ifNotNil: [:ts | ts debugProcess: aProcess context: aContext label: aString contents: contents fullView: aBool]!
Marcel Taeumel uploaded a new version of ToolBuilder-Kernel to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Kernel-mt.162.mcz
==================== Summary ====================
Name: ToolBuilder-Kernel-mt.162
Author: mt
Time: 18 January 2023, 5:09:26.397866 pm
UUID: cccbe57c-2d70-7d4e-98e9-23976df3aee1
Ancestors: ToolBuilder-Kernel-eem.161
*** Debugger Refactoring - Step 3 of 2 ***
Remove and/or deprecate the old interface.
=============== Diff against ToolBuilder-Kernel-eem.161 ===============
Item was removed:
- ----- Method: ToolBuilder>>openDebugger: (in category 'opening') -----
- openDebugger: aSpec
- "Build and open a debugger from the given spec.
- Answer the widget opened. Subclasses can override this
- method if opening a debugger has specific requirements
- different from opening other widgets."
-
- ^ self open: aSpec
- !
Item was removed:
- ----- Method: ToolBuilder>>openDebugger:label: (in category 'opening') -----
- openDebugger: aSpec label: aString
- "Build and open a debugger from the given spec, labeling it appropriately.
- Answer the widget opened. Subclasses can override this
- method if opening a debugger has specific requirements
- different from opening other widgets."
-
- ^self open: aSpec label: aString
- !
Item was removed:
- ----- Method: ToolBuilder>>openDebugger:label:closing: (in category 'opening') -----
- openDebugger: aSpec label: aString closing: topView
- "Build and open a debugger from the given spec, labeling it appropriately.
- Answer the widget opened. Subclasses can override this
- method if opening a debugger has specific requirements
- different from opening other widgets."
-
- self close: topView.
- ^ self open: aSpec label: aString
- !