Fwd: [squeak-dev] Strange behavior of ContextVariableInspector

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [squeak-dev] Strange behavior of ContextVariableInspector

Stéphane Ducasse


Begin forwarded message:

From: Eliot Miranda <[hidden email]>
Date: October 16, 2009 12:10:14 AM GMT+02:00
To: The general-purpose Squeak developers list <[hidden email]>
Subject: Re: [squeak-dev] Strange behavior of ContextVariableInspector
Reply-To: The general-purpose Squeak developers list <[hidden email]>



On Thu, Oct 15, 2009 at 1:02 PM, Igor Stasenko <[hidden email]> wrote:
I suspect this is due to latest updates to debugger & compiler etc,
brought by Eliot.

To display a context variable 'contents', a message #contents is sent
to ContextVariableInspector.
The problem is, that in TextMorphForEditView>>newContents:
which sends this message to model (which is a
ContextVariableInspector) expects that returned value is text, or
string at least.
While at some point, this is not always true, and inspection of
different context slots in debugger could lead to interesting results,
where
#contents returns an actual object, which does not implements #asText
, and as result i often get an
DNU: SmallInteger>>asText
or similar.

The root of evil, i think, is in
ContextVariableInspector>>toggleIndex: method, in following code:

self contentsIsString
       ifTrue: [contents := self selection]
       ifFalse: [contents := self selectionPrintString]].

which sometimes returns an actual object (self selection) instead of
(self selectionPrintString).

I don't really understand, what exactly tests the #contentsIsString method:

contentsIsString
       "Hacked so contents empty when deselected"

       ^ #(0 2 3) includes: selectionIndex

This defines which indices in the context inspector answer meta-values rather than actual slot contents.  Open up a debugger on the activation of a method with args and/or temps and you'll see
thisContext
stack top
all temp vars
textOrStream
aContext
receiver
aRequestor
failBlock
logFlag
methodNode
method
value
toLog
itsSelection
itsSelectionString
thisContext is an object, but "stack top" and "all temp vars" are strings computed by ContextvariablesInspector>>selection. i.e. 

selection 
"Refer to the comment in Inspector|selection."
selectionIndex = 0 ifTrue:[^''].
selectionIndex = 1 ifTrue: [^object].
selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object top]].
selectionIndex = 3 ifTrue: [^object tempsAndValues].
^object debuggerMap namedTempAt: selectionIndex - 3 in: object

So the meta values at index 0 (unselected null string), 2 & 3 shouldn't be sent printString, otherwise e.g. an unselected CVI would show '' (the printString of ByteString new) instead of nothing.


maybe a proper fix would be to test additionally, that selection is
string, and if not, then return false, so
caller will use #selectionPrintString later.

The right thing is to ensure thatContextvariablesInspector contentsIsString fieldList replaceSelectionValue: & selection all agree.  I think I added "stack top" to the list.  I may have forgotten to integrate the changes for one or more of these which in my image are (also attached):
 
 !ContextVariablesInspector methodsFor: 'accessing' stamp: 'eem 5/21/2008 12:31'!
fieldList 
"Refer to the comment in Inspector|fieldList."

object == nil ifTrue: [^Array with: 'thisContext'].
^fieldList ifNil:[fieldList := (Array with: 'thisContext' with: 'stack top' with: 'all temp vars') , object tempNames]! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 3/6/2009 10:05'!
contentsIsString
^ #(0 3) includes: selectionIndex! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 7/18/2008 11:18'!
replaceSelectionValue: anObject 
"Refer to the comment in Inspector|replaceSelectionValue:."

^selectionIndex = 1
ifTrue: [object]
ifFalse: [object namedTempAt: selectionIndex - 3 put: anObject]! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 6/10/2008 09:37'!
selection 
"Refer to the comment in Inspector|selection."
selectionIndex = 0 ifTrue:[^''].
selectionIndex = 1 ifTrue: [^object].
selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object top]].
selectionIndex = 3 ifTrue: [^object tempsAndValues].
^object debuggerMap namedTempAt: selectionIndex - 3 in: object! ! 

--
Best regards,
Igor Stasenko AKA sig.






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

ContextVariablesInspector.st (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [squeak-dev] Strange behavior of ContextVariableInspector

Henrik Sperre Johansen
That was issue 987 from the bugtracker, which you closed earlier today after integrating the fix made as per Eliot's pointers. ;)

Cheers,
Henry
On Oct 17, 2009, at 7:30 18PM, Stéphane Ducasse wrote:



Begin forwarded message:

From: Eliot Miranda <[hidden email]>
Date: October 16, 2009 12:10:14 AM GMT+02:00
To: The general-purpose Squeak developers list <[hidden email]>
Subject: Re: [squeak-dev] Strange behavior of ContextVariableInspector
Reply-To: The general-purpose Squeak developers list <[hidden email]>



On Thu, Oct 15, 2009 at 1:02 PM, Igor Stasenko <[hidden email]> wrote:
I suspect this is due to latest updates to debugger & compiler etc,
brought by Eliot.

To display a context variable 'contents', a message #contents is sent
to ContextVariableInspector.
The problem is, that in TextMorphForEditView>>newContents:
which sends this message to model (which is a
ContextVariableInspector) expects that returned value is text, or
string at least.
While at some point, this is not always true, and inspection of
different context slots in debugger could lead to interesting results,
where
#contents returns an actual object, which does not implements #asText
, and as result i often get an
DNU: SmallInteger>>asText
or similar.

The root of evil, i think, is in
ContextVariableInspector>>toggleIndex: method, in following code:

self contentsIsString
       ifTrue: [contents := self selection]
       ifFalse: [contents := self selectionPrintString]].

which sometimes returns an actual object (self selection) instead of
(self selectionPrintString).

I don't really understand, what exactly tests the #contentsIsString method:

contentsIsString
       "Hacked so contents empty when deselected"

       ^ #(0 2 3) includes: selectionIndex

This defines which indices in the context inspector answer meta-values rather than actual slot contents.  Open up a debugger on the activation of a method with args and/or temps and you'll see
thisContext
stack top
all temp vars
textOrStream
aContext
receiver
aRequestor
failBlock
logFlag
methodNode
method
value
toLog
itsSelection
itsSelectionString
thisContext is an object, but "stack top" and "all temp vars" are strings computed by ContextvariablesInspector>>selection. i.e. 

selection 
"Refer to the comment in Inspector|selection."
selectionIndex = 0 ifTrue:[^''].
selectionIndex = 1 ifTrue: [^object].
selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object top]].
selectionIndex = 3 ifTrue: [^object tempsAndValues].
^object debuggerMap namedTempAt: selectionIndex - 3 in: object

So the meta values at index 0 (unselected null string), 2 & 3 shouldn't be sent printString, otherwise e.g. an unselected CVI would show '' (the printString of ByteString new) instead of nothing.


maybe a proper fix would be to test additionally, that selection is
string, and if not, then return false, so
caller will use #selectionPrintString later.

The right thing is to ensure thatContextvariablesInspector contentsIsString fieldList replaceSelectionValue: & selection all agree.  I think I added "stack top" to the list.  I may have forgotten to integrate the changes for one or more of these which in my image are (also attached):
 
 !ContextVariablesInspector methodsFor: 'accessing' stamp: 'eem 5/21/2008 12:31'!
fieldList 
"Refer to the comment in Inspector|fieldList."

object == nil ifTrue: [^Array with: 'thisContext'].
^fieldList ifNil:[fieldList := (Array with: 'thisContext' with: 'stack top' with: 'all temp vars') , object tempNames]! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 3/6/2009 10:05'!
contentsIsString
^ #(0 3) includes: selectionIndex! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 7/18/2008 11:18'!
replaceSelectionValue: anObject 
"Refer to the comment in Inspector|replaceSelectionValue:."

^selectionIndex = 1
ifTrue: [object]
ifFalse: [object namedTempAt: selectionIndex - 3 put: anObject]! !

!ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem 6/10/2008 09:37'!
selection 
"Refer to the comment in Inspector|selection."
selectionIndex = 0 ifTrue:[^''].
selectionIndex = 1 ifTrue: [^object].
selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object top]].
selectionIndex = 3 ifTrue: [^object tempsAndValues].
^object debuggerMap namedTempAt: selectionIndex - 3 in: object! ! 

--
Best regards,
Igor Stasenko AKA sig.


<ContextVariablesInspector.st>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [squeak-dev] Strange behavior of ContextVariableInspector

Stéphane Ducasse
Excellent!
I like this music :)

Stef

On Oct 18, 2009, at 12:18 AM, Henrik Johansen wrote:

> That was issue 987 from the bugtracker, which you closed earlier  
> today after integrating the fix made as per Eliot's pointers. ;)
>
> Cheers,
> Henry
> On Oct 17, 2009, at 7:30 18PM, Stéphane Ducasse wrote:
>
>>
>>
>> Begin forwarded message:
>>
>>> From: Eliot Miranda <[hidden email]>
>>> Date: October 16, 2009 12:10:14 AM GMT+02:00
>>> To: The general-purpose Squeak developers list <[hidden email]
>>> >
>>> Subject: Re: [squeak-dev] Strange behavior of  
>>> ContextVariableInspector
>>> Reply-To: The general-purpose Squeak developers list <[hidden email]
>>> >
>>>
>>>
>>>
>>> On Thu, Oct 15, 2009 at 1:02 PM, Igor Stasenko  
>>> <[hidden email]> wrote:
>>> I suspect this is due to latest updates to debugger & compiler etc,
>>> brought by Eliot.
>>>
>>> To display a context variable 'contents', a message #contents is  
>>> sent
>>> to ContextVariableInspector.
>>> The problem is, that in TextMorphForEditView>>newContents:
>>> which sends this message to model (which is a
>>> ContextVariableInspector) expects that returned value is text, or
>>> string at least.
>>> While at some point, this is not always true, and inspection of
>>> different context slots in debugger could lead to interesting  
>>> results,
>>> where
>>> #contents returns an actual object, which does not implements  
>>> #asText
>>> , and as result i often get an
>>> DNU: SmallInteger>>asText
>>> or similar.
>>>
>>> The root of evil, i think, is in
>>> ContextVariableInspector>>toggleIndex: method, in following code:
>>>
>>> self contentsIsString
>>>        ifTrue: [contents := self selection]
>>>        ifFalse: [contents := self selectionPrintString]].
>>>
>>> which sometimes returns an actual object (self selection) instead of
>>> (self selectionPrintString).
>>>
>>> I don't really understand, what exactly tests the  
>>> #contentsIsString method:
>>>
>>> contentsIsString
>>>        "Hacked so contents empty when deselected"
>>>
>>>        ^ #(0 2 3) includes: selectionIndex
>>>
>>> This defines which indices in the context inspector answer meta-
>>> values rather than actual slot contents.  Open up a debugger on  
>>> the activation of a method with args and/or temps and you'll see
>>> thisContext
>>> stack top
>>> all temp vars
>>> textOrStream
>>> aContext
>>> receiver
>>> aRequestor
>>> failBlock
>>> logFlag
>>> methodNode
>>> method
>>> value
>>> toLog
>>> itsSelection
>>> itsSelectionString
>>> thisContext is an object, but "stack top" and "all temp vars" are  
>>> strings computed by ContextvariablesInspector>>selection. i.e.
>>>
>>> selection
>>> "Refer to the comment in Inspector|selection."
>>> selectionIndex = 0 ifTrue:[^''].
>>> selectionIndex = 1 ifTrue: [^object].
>>> selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object  
>>> top]].
>>> selectionIndex = 3 ifTrue: [^object tempsAndValues].
>>> ^object debuggerMap namedTempAt: selectionIndex - 3 in: object
>>>
>>> So the meta values at index 0 (unselected null string), 2 & 3  
>>> shouldn't be sent printString, otherwise e.g. an unselected CVI  
>>> would show '' (the printString of ByteString new) instead of  
>>> nothing.
>>>
>>>
>>> maybe a proper fix would be to test additionally, that selection is
>>> string, and if not, then return false, so
>>> caller will use #selectionPrintString later.
>>>
>>> The right thing is to ensure thatContextvariablesInspector  
>>> contentsIsString fieldList replaceSelectionValue: & selection all  
>>> agree.  I think I added "stack top" to the list.  I may have  
>>> forgotten to integrate the changes for one or more of these which  
>>> in my image are (also attached):
>>>
>>>  !ContextVariablesInspector methodsFor: 'accessing' stamp: 'eem  
>>> 5/21/2008 12:31'!
>>> fieldList
>>> "Refer to the comment in Inspector|fieldList."
>>>
>>> object == nil ifTrue: [^Array with: 'thisContext'].
>>> ^fieldList ifNil:[fieldList := (Array with: 'thisContext' with:  
>>> 'stack top' with: 'all temp vars') , object tempNames]! !
>>>
>>> !ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem  
>>> 3/6/2009 10:05'!
>>> contentsIsString
>>> ^ #(0 3) includes: selectionIndex! !
>>>
>>> !ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem  
>>> 7/18/2008 11:18'!
>>> replaceSelectionValue: anObject
>>> "Refer to the comment in Inspector|replaceSelectionValue:."
>>>
>>> ^selectionIndex = 1
>>> ifTrue: [object]
>>> ifFalse: [object namedTempAt: selectionIndex - 3 put: anObject]! !
>>>
>>> !ContextVariablesInspector methodsFor: 'selecting' stamp: 'eem  
>>> 6/10/2008 09:37'!
>>> selection
>>> "Refer to the comment in Inspector|selection."
>>> selectionIndex = 0 ifTrue:[^''].
>>> selectionIndex = 1 ifTrue: [^object].
>>> selectionIndex = 2 ifTrue: [^object stackPtr > 0 ifTrue: [object  
>>> top]].
>>> selectionIndex = 3 ifTrue: [^object tempsAndValues].
>>> ^object debuggerMap namedTempAt: selectionIndex - 3 in: object! !
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko AKA sig.
>>>
>>>
>> <ContextVariablesInspector.st>
>>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project