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. :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
<b>=============== Summary ===============</b><br>
<br>
Change Set: enhance-debug-logs<br>
Date: 7 October 2022<br>
Author: Christoph Thiede<br>
<br>
[Proposal] Enhances bug reports aka debug logs that can be produced via logDebuggerStackToFile or the debugger's 'copy bug report to clipboard' command:<br>
<br>
* Adds a preference #maxFullStackDepthForASingleDebugLogReport for a previously hardcoded value and increases its default from 20 to 60.<br>
* Increases the default value of the preference #maxStackDepthForASingleDebugLogReport from 60 to 100.<br>
* Increases the default value of the preference #maxLengthForASingleDebugLogReport from 40000 to 100000.<br>
* Logs the current pc for each context.<br>
<br>
<b>=============== Diff ===============</b><br>
<br>
<b>Context class>>maxFullStackDepthForASingleDebugLogReport {preferences} · ct 9/20/2022 09:58</b><br>
<font color="#FF0000">+ maxFullStackDepthForASingleDebugLogReport<br>
+ <preference: 'Max. Debug Report Full Stack Depth'<br>
+ category: 'debug'<br>
+ description: 'In an exception stack, any sender deeper than this value will not be logged with all its variables.'<br>
+ type: #Number><br>
+ ^ MaxFullStackDepthForASingleDebugLogReport ifNil: [60]</font><br>
<br>
<b>Context class>>maxFullStackDepthForASingleDebugLogReport: {preferences} · ct 9/20/2022 09:58</b><br>
<font color="#FF0000">+ maxFullStackDepthForASingleDebugLogReport: anInteger<br>
+ <br>
+ MaxFullStackDepthForASingleDebugLogReport := anInteger</font><br>
<br>
<b>Context class>>maxLengthForASingleDebugLogReport {preferences} · ct 10/7/2022 14:35 (changed)</b><br>
maxLengthForASingleDebugLogReport<br>
<preference: 'Max. Debug Report Length'<br>
category: 'debug'<br>
description: 'The description of an Exception stack will be truncated so as to not exceed this value'<br>
type: #Number><br>
<s><font color="#0000FF">- ^MaxLengthForASingleDebugLogReport ifNil: [40000]<br>
</font></s><font color="#FF0000">+ ^MaxLengthForASingleDebugLogReport ifNil: [100000]</font><br>
<br>
<b>Context class>>maxStackDepthForASingleDebugLogReport {preferences} · ct 10/7/2022 14:27 (changed)</b><br>
maxStackDepthForASingleDebugLogReport<br>
<preference: 'Max. Debug Report Stack Depth'<br>
category: 'debug'<br>
description: 'In an exception stack, any sender deeper than this value will not be logged.'<br>
type: #Number><br>
<s><font color="#0000FF">- ^MaxStackDepthForASingleDebugLogReport ifNil: [60]<br>
</font></s><font color="#FF0000">+ ^MaxStackDepthForASingleDebugLogReport ifNil: [100]</font><br>
<br>
<b>Context>>errorReportOn: {*Tools-debugger access} · ct 9/20/2022 09:59 (changed)</b><br>
errorReportOn: strm<br>
"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."<br>
<br>
| cnt aContext startPos |<br>
strm print: Date today; space; print: Time now; cr.<br>
strm cr.<br>
strm nextPutAll: 'VM: ';<br>
nextPutAll: Smalltalk platformName asString;<br>
nextPutAll: ' - ';<br>
nextPutAll: Smalltalk asString;<br>
cr.<br>
strm nextPutAll: 'Image: ';<br>
nextPutAll: SystemVersion current version asString;<br>
nextPutAll: ' [';<br>
nextPutAll: Smalltalk lastUpdateString asString;<br>
nextPutAll: ']';<br>
cr.<br>
strm cr.<br>
SecurityManager default printStateOn: strm.<br>
<br>
"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."<br>
cnt := 0. startPos := strm position.<br>
aContext := self.<br>
<s><font color="#0000FF">- [aContext notNil and: [(cnt := cnt + 1) < 20]] whileTrue:<br>
</font></s><font color="#FF0000">+ [aContext notNil and: [(cnt := cnt + 1) < self class maxFullStackDepthForASingleDebugLogReport]] whileTrue:<br>
</font> [aContext printDetails: strm. "variable values"<br>
strm cr.<br>
aContext := aContext sender].<br>
<br>
strm cr; nextPutAll: '--- The full stack ---'; cr.<br>
aContext := self.<br>
cnt := 0.<br>
[aContext == nil] whileFalse:<br>
[cnt := cnt + 1.<br>
<s><font color="#0000FF">- cnt = 20 ifTrue: [strm nextPutAll: ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; cr].<br>
</font></s><font color="#FF0000">+ cnt = self class maxFullStackDepthForASingleDebugLogReport ifTrue: [strm nextPutAll: ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; cr].<br>
</font> strm print: aContext; cr. "just class>>selector" <br>
<br>
"exit early if too long..."<br>
strm position > (startPos+ self class maxLengthForASingleDebugLogReport) ifTrue: [strm nextPutAll: '...etc...'. ^ self]. cnt > self class maxStackDepthForASingleDebugLogReport ifTrue: [strm nextPutAll: '-- and more not shown --'. ^ self].<br>
<s><font color="#0000FF">- aContext := aContext sender]<br>
</font></s><font color="#FF0000">+ aContext := aContext sender].<br>
</font><br>
<br>
<b>Context>>printDetails: {printing} · ct 9/21/2022 17:59 (changed)</b><br>
printDetails: strm<br>
"Put my class>>selector and instance variables and arguments and temporaries on the stream. Protect against errors during printing."<br>
<br>
| pe str pos |<br>
self printOn: strm.<br>
strm cr.<br>
<font color="#FF0000">+ strm tab; nextPutAll: 'pc: '; print: self pc; cr.<br>
</font> strm tab; nextPutAll: 'Receiver: '.<br>
pe := '<<error during printing>>'.<br>
strm nextPutAll: ([receiver printStringLimitedTo: 90] ifError: [:err :rcvr | pe]).<br>
<br>
strm cr; tab; nextPutAll: 'Arguments and temporary variables: '; cr.<br>
str := [(self tempsAndValuesLimitedTo: 80 indent: 2) <br>
padded: #right to: 1 with: $x] ifError: [:err :rcvr | pe].<br>
strm nextPutAll: (str allButLast).<br>
<br>
strm cr; tab; nextPutAll: 'Receiver''s instance variables: '; cr.<br>
pos := strm position.<br>
[receiver longPrintOn: strm limitedTo: 80 indent: 2] ifError: [:err :rcvr | <br>
strm nextPutAll: pe].<br>
pos = strm position ifTrue: ["normal printString for an Array (it has no inst vars)"<br>
strm nextPutAll: ([receiver printStringLimitedTo: 90] ifError: [:err :rcvr | pe])].<br>
strm peekLast == Character cr ifFalse: [strm cr].<br>
<br>
["enhance-debug-logs.2.cs"]<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
["enhance-debug-logs.2.cs"]