[squeak-dev] Review Request: enhance-debug-logs.2.cs

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Fri Oct 7 12:39:13 UTC 2022


If you don't have any objections, I'd like to merge this in two weeks. Let's make bug reports more helpful for everyone. :-)

Best,
Christoph

=============== Summary ===============

Change Set:        enhance-debug-logs
Date:            7 October 2022
Author:            Christoph Thiede

[Proposal] Enhances bug reports aka debug logs that can be produced via logDebuggerStackToFile or the debugger's 'copy bug report to clipboard' command:

* Adds a preference #maxFullStackDepthForASingleDebugLogReport for a previously hardcoded value and increases its default from 20 to 60.
* Increases the default value of the preference #maxStackDepthForASingleDebugLogReport from 60 to 100.
* Increases the default value of the preference #maxLengthForASingleDebugLogReport from 40000 to 100000.
* Logs the current pc for each context.

=============== Diff ===============

Context class>>maxFullStackDepthForASingleDebugLogReport {preferences} · ct 9/20/2022 09:58
+ maxFullStackDepthForASingleDebugLogReport
+     <preference: 'Max. Debug Report Full Stack Depth'
+         category: 'debug'
+         description: 'In an exception stack, any sender deeper than this value will not be logged with all its variables.'
+         type: #Number>
+     ^ MaxFullStackDepthForASingleDebugLogReport ifNil: [60]

Context class>>maxFullStackDepthForASingleDebugLogReport: {preferences} · ct 9/20/2022 09:58
+ maxFullStackDepthForASingleDebugLogReport: anInteger
+ 
+     MaxFullStackDepthForASingleDebugLogReport := anInteger

Context class>>maxLengthForASingleDebugLogReport {preferences} · ct 10/7/2022 14:35 (changed)
maxLengthForASingleDebugLogReport
    <preference: 'Max. Debug Report Length'
        category: 'debug'
        description: 'The description of an Exception stack will be truncated so as to not exceed this value'
        type: #Number>
-     ^MaxLengthForASingleDebugLogReport ifNil: [40000]
+     ^MaxLengthForASingleDebugLogReport ifNil: [100000]

Context class>>maxStackDepthForASingleDebugLogReport {preferences} · ct 10/7/2022 14:27 (changed)
maxStackDepthForASingleDebugLogReport
    <preference: 'Max. Debug Report Stack Depth'
        category: 'debug'
        description: 'In an exception stack, any sender deeper than this value will not be logged.'
        type: #Number>
-     ^MaxStackDepthForASingleDebugLogReport ifNil: [60]
+     ^MaxStackDepthForASingleDebugLogReport ifNil: [100]

Context>>errorReportOn: {*Tools-debugger access} · ct 9/20/2022 09:59 (changed)
errorReportOn: strm
    "Write a detailed error report on the stack (above me) on a stream.  For both the error file, and emailing a bug report.  Suppress any errors while getting printStrings.  Limit the length."

    | cnt aContext startPos |
     strm print: Date today; space; print: Time now; cr.
    strm cr.
    strm nextPutAll: 'VM: ';
        nextPutAll:  Smalltalk platformName asString;
        nextPutAll: ' - ';
        nextPutAll: Smalltalk asString;
        cr.
    strm nextPutAll: 'Image: ';
        nextPutAll:  SystemVersion current version asString;
        nextPutAll: ' [';
        nextPutAll: Smalltalk lastUpdateString asString;
        nextPutAll: ']';
        cr.
    strm cr.
    SecurityManager default printStateOn: strm.
    
    "Note: The following is an open-coded version of Context>>stackOfSize: since this method may be called during a low space condition and we might run out of space for allocating the full stack."
    cnt := 0.  startPos := strm position.
    aContext := self.
-     [aContext notNil and: [(cnt := cnt + 1) < 20]] whileTrue:
+     [aContext notNil and: [(cnt := cnt + 1) < self class maxFullStackDepthForASingleDebugLogReport]] whileTrue:
        [aContext printDetails: strm.    "variable values"
        strm cr.
        aContext := aContext sender].

    strm cr; nextPutAll: '--- The full stack ---'; cr.
    aContext := self.
    cnt := 0.
    [aContext == nil] whileFalse:
        [cnt := cnt + 1.
-         cnt = 20 ifTrue: [strm nextPutAll: ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; cr].
+         cnt = self class maxFullStackDepthForASingleDebugLogReport ifTrue: [strm nextPutAll: ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; cr].
        strm print: aContext; cr.  "just class>>selector"    

        "exit early if too long..."
        strm position > (startPos+ self class maxLengthForASingleDebugLogReport) ifTrue: [strm nextPutAll: '...etc...'.    ^ self].         cnt > self class maxStackDepthForASingleDebugLogReport ifTrue: [strm nextPutAll: '-- and more not shown --'.    ^ self].
-         aContext := aContext sender]
+         aContext := aContext sender].


Context>>printDetails: {printing} · ct 9/21/2022 17:59 (changed)
printDetails: strm
    "Put my class>>selector and instance variables and arguments and temporaries on the stream.  Protect against errors during printing."

    | pe str pos |
    self printOn: strm.
    strm cr.
+     strm tab; nextPutAll: 'pc: '; print: self pc; cr.
    strm tab; nextPutAll: 'Receiver: '.
    pe := '<<error during printing>>'.
    strm nextPutAll: ([receiver printStringLimitedTo: 90] ifError: [:err :rcvr | pe]).

    strm cr; tab; nextPutAll: 'Arguments and temporary variables: '; cr.
    str := [(self tempsAndValuesLimitedTo: 80 indent: 2) 
                padded: #right to: 1 with: $x] ifError: [:err :rcvr | pe].
    strm nextPutAll: (str allButLast).

    strm cr; tab; nextPutAll: 'Receiver''s instance variables: '; cr.
    pos := strm position.
    [receiver longPrintOn: strm limitedTo: 80 indent: 2] ifError: [:err :rcvr | 
                strm nextPutAll: pe].
    pos = strm position ifTrue: ["normal printString for an Array (it has no inst vars)"
        strm nextPutAll: ([receiver printStringLimitedTo: 90] ifError: [:err :rcvr | pe])].
    strm peekLast == Character cr ifFalse: [strm cr].

["enhance-debug-logs.2.cs"]

---
Sent from Squeak Inbox Talk
["enhance-debug-logs.2.cs"]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221007/5067b240/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enhance-debug-logs.2.cs
Type: application/octet-stream
Size: 5290 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221007/5067b240/attachment.obj>


More information about the Squeak-dev mailing list