[squeak-dev] The Trunk: System-mt.1384.mcz

Eliot Miranda eliot.miranda at gmail.com
Sat Jan 21 16:57:06 UTC 2023


Wonderful to see this and System-mt.1385, etc. thank you Marcel, for a lovely new year’s gift.  Much appreciated.

_,,,^..^,,,_ (phone)

> On Jan 20, 2023, at 6:49 AM, commits at source.squeak.org wrote:
> 
> 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]!
> 
> 


More information about the Squeak-dev mailing list