= a few hours of unbridled fun and printNl debugging :-)
<bla>
So I'm running the most recent smalltalk and the most recent Iliad.
And after I actually started doing something _with_ Iliad instead of
_to_ it (what a willing victim for testing packaging Iliad is), I
notice that sometimes my browser hangs waiting for a response...
and always I manage to find a bug.
Switching the application to deploymentMode displays the expected 500
message, so it must have something to do with the default verboseMode.
Veni, vidi, and there are messages in ErrorHandler>>produceVerboseResponse
that cannot be found in the docs ... if this ain't an invitation to mess
around, I don't know what is.
Removing the "weird" stuff and sprinkling it with "self error inspect"
and "self error backtraceOn: Transcript" produces quite interesting
information ... on the console.
</bla>
So gst has inspect with hardcoded Transcript references in it.
And there are four definitions of inspect in the base classes to
accomodate different types of objects.
Well, my local gst now only has one inspect in Object but four
inspectOn: aStream in the base classes ... and things still work.
The good new is that I now can produce some really helpful debugging
info in ErrorHandler.st
produceVerboseResponse [
<category: 'responding'>
|info|
info := WriteStream on: String new.
self error inspectOn: info.
self error context backtraceOn: info.
FileStream stderr nextPutAll: info contents.
self respond: [:response || page |
page := Page new.
page bodyElement h1: 'Internal Error';
h2: self error description;
h3: self error messageText;
preformatted: info contents.
page build printHtmlOn: response]
]
So now I not only see _where_ the problem occurred, I also see
with _what data_ it occurred.... sweeet.
I'm attaching the two patches to this message for your consideration.
s.diff --git a/kernel/Collection.st b/kernel/Collection.st
index 60f8923..42ddb4e 100644
--- a/kernel/Collection.st
+++ b/kernel/Collection.st
@@ -524,14 +524,13 @@ of objects.'>
]
- inspect [
- "Print all the instance variables and objects in the receiver on the
- Transcript"
+ inspectOn: aStream [
+ "Print all the instance variables and objects in the receiver on aStream"
<category: 'printing'>
| instVars output object |
self beConsistent.
- Transcript
+ aStream
nextPutAll: 'An instance of ';
print: self class;
nl.
@@ -547,13 +546,13 @@ of objects.'>
return: '%1 %2' %
{object class article.
object class name asString}].
- Transcript
+ aStream
nextPutAll: ' ';
nextPutAll: (instVars at: i);
nextPutAll: ': ';
nextPutAll: output;
nl].
- Transcript
+ aStream
nextPutAll: ' contents: [';
nl.
self do:
@@ -566,11 +565,11 @@ of objects.'>
return: '%1 %2' %
{obj class article.
obj class name asString}].
- Transcript
+ aStream
nextPutAll: ' ';
nextPutAll: output;
nl].
- Transcript
+ aStream
nextPutAll: ' ]';
nl
]
diff --git a/kernel/CompildCode.st b/kernel/CompildCode.st
index 26181d2..b3cc067 100644
--- a/kernel/CompildCode.st
+++ b/kernel/CompildCode.st
@@ -362,13 +362,13 @@ superclass for blocks and methods'>
^self shallowCopy postCopy
]
- inspect [
+ inspectOn: aStream [
"Print the contents of the receiver in a verbose way."
<category: 'debugging'>
| instVars lit object output |
instVars := self class allInstVarNames.
- Transcript
+ aStream
nextPutAll: 'An instance of ';
print: self class;
nl.
@@ -383,35 +383,35 @@ superclass for blocks and methods'>
return: '%1 %2' %
{object class article.
object class name asString}].
- Transcript
+ aStream
nextPutAll: ' ';
nextPutAll: (instVars at: i);
nextPutAll: ': ';
nextPutAll: output;
nl.
- i = 2 ifTrue: [self printHeaderOn: Transcript]].
+ i = 2 ifTrue: [self printHeaderOn: aStream]].
self numLiterals > 0
ifTrue:
- [Transcript
+ [aStream
nextPutAll: ' literals: [';
nl.
1 to: self numLiterals
do:
[:i |
- self bytecodeIndex: i with: Transcript.
- Transcript tab.
+ self bytecodeIndex: i with: aStream.
+ aStream tab.
lit := self literalAt: i.
lit printNl].
- Transcript
+ aStream
nextPutAll: ' ]';
nl].
self numBytecodes > 0
ifTrue:
- [Transcript
+ [aStream
nextPutAll: ' byte codes: [';
nl.
- self printByteCodesOn: Transcript.
- Transcript
+ self printByteCodesOn: aStream.
+ aStream
nextPutAll: ' ]';
nl]
]
diff --git a/kernel/Dictionary.st b/kernel/Dictionary.st
index 6c688ee..9866cec 100644
--- a/kernel/Dictionary.st
+++ b/kernel/Dictionary.st
@@ -430,35 +430,34 @@ certain special cases.'>
^hashValue
]
- inspect [
- "Print all the instance variables and objects in the receiver on the
- Transcript"
+ inspectOn: aStream [
+ "Print all the instance variables and objects in the receiver on aStream"
<category: 'printing'>
| class instVars i |
self beConsistent.
class := self class.
instVars := class allInstVarNames.
- Transcript nextPutAll: 'An instance of '.
+ aStream nextPutAll: 'An instance of '.
class printNl.
1 to: instVars size
do:
[:i |
- Transcript
+ aStream
nextPutAll: ' ';
nextPutAll: (instVars at: i);
nextPutAll: ': '.
(self instVarAt: i) printNl].
- Transcript
+ aStream
nextPutAll: ' contents: [';
nl.
self associationsDo:
[:obj |
- Transcript
+ aStream
nextPutAll: ' ';
print: obj;
nl].
- Transcript
+ aStream
nextPutAll: ' ]';
nl
]
diff --git a/kernel/Object.st b/kernel/Object.st
index a4a44d5..4caafaa 100644
--- a/kernel/Object.st
+++ b/kernel/Object.st
@@ -700,8 +700,15 @@ All classes in the system are subclasses of me.'>
"Print all the instance variables of the receiver on the Transcript"
<category: 'debugging'>
+ self inspectOn: Transcript
+ ]
+
+ inspectOn: aStream [
+ "Print all the instance variables of the receiver on aStream"
+
+ <category: 'debugging'>
| instVars output object |
- Transcript
+ aStream
nextPutAll: 'An instance of ';
print: self class;
nl.
@@ -719,16 +726,16 @@ All classes in the system are subclasses of me.'>
object class name asString}].
i <= instVars size
ifTrue:
- [Transcript
+ [aStream
nextPutAll: ' ';
nextPutAll: (instVars at: i);
nextPutAll: ': ']
ifFalse:
- [Transcript
+ [aStream
nextPutAll: ' [';
print: i - instVars size;
nextPutAll: ']: '].
- Transcript
+ aStream
nextPutAll: output;
nl]
]
diff --git a/kernel/SeqCollect.st b/kernel/SeqCollect.st
index 77ba039..e24c2f8 100644
--- a/kernel/SeqCollect.st
+++ b/kernel/SeqCollect.st
@@ -54,14 +54,13 @@ some access and manipulation methods.'>
^newInst
]
- inspect [
- "Print all the instance variables and context of the receiver on the
- Transcript"
+ inspectOn: aStream [
+ "Print all the instance variables and context of the receiver on aStream"
<category: 'testing'>
| instVars object output |
self beConsistent.
- Transcript
+ aStream
nextPutAll: 'An instance of ';
print: self class;
nl.
@@ -77,13 +76,13 @@ some access and manipulation methods.'>
return: '%1 %2' %
{object class article.
object class name asString}].
- Transcript
+ aStream
nextPutAll: ' ';
nextPutAll: (instVars at: i);
nextPutAll: ': ';
nextPutAll: output;
nl].
- Transcript
+ aStream
nextPutAll: ' contents: [';
nl.
self keysAndValuesDo:
@@ -96,13 +95,13 @@ some access and manipulation methods.'>
return: '%1 %2' %
{obj class article.
obj class name asString}].
- Transcript
+ aStream
nextPutAll: ' [';
print: i;
nextPutAll: ']: ';
nextPutAll: output;
nl].
- Transcript
+ aStream
nextPutAll: ' ]';
nl
]
Index: Core/RequestHandlers/ErrorHandler.st
===================================================================
--- Core/RequestHandlers/ErrorHandler.st (revision 1368)
+++ Core/RequestHandlers/ErrorHandler.st (working copy)
@@ -82,14 +82,17 @@
produceVerboseResponse [
<category: 'responding'>
- self respond: [:response || page e |
- response nextPutAll: (String streamContents: [:stream |
+ |info|
+ info := WriteStream on: String new.
+ self error inspectOn: info.
+ self error context backtraceOn: info.
+ FileStream stderr nextPutAll: info contents.
+ self respond: [:response || page |
page := Page new.
page bodyElement h1: 'Internal Error';
h2: self error description;
h3: self error messageText;
- preformatted: (String streamContents: [:str |
- self error resumeContext backtraceOn: str]).
- page build printHtmlOn: stream])]
+ preformatted: info contents.
+ page build printHtmlOn: response]
]
]
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk