[Glass] How can I get the start/end of a step in a GsContext?
Dale Henrichs via Glass
glass at lists.gemtalksystems.com
Sat Nov 4 14:25:03 PDT 2017
Yeah I think that would make a lot of sense ...
On 11/3/17 9:14 PM, Mariano Martinez Peck wrote:
> Cool. It did work. Now my web debugger is way cooler. See attached
> screenshot.
>
> BTW, wouldn't this be nice additions to add directly to GsContext? I
> added this standalone methods and they seem to work:
>
>
> Below method is a simplified version of tODE one assuming the data we
> have in the GsContext and to avoid calling other methods we do not
> have here.
>
> calculateSelectionRange
> | stepPoint begin end frameContents |
> frameContents := continuation _frameContentsAt: level.
> (method respondsTo: #'_stepPointForIp:level:isNative:')
> ifTrue: [
> stepPoint := method
> perform: #'_stepPointForIp:level:isNative:'
> withArguments:
> {(frameContents at: 2).
> level.
> (continuation _nativeStack)} ]
> ifFalse: [
> "v3.3"
> stepPoint := method
> perform: #'_stepPointForIp:level:useNext:'
> withArguments:
> {(frameContents at: 2).
> level.
> (continuation _nativeStack)} ].
> begin := method _sourceOffsetsAt: stepPoint.
> end := self calculateSourceRangeEnd: begin in: method sourceString.
> ^ begin to: end
>
>
>
>
> Below one is exact copy from tODE one.
>
>
> calculateSourceRangeEnd: start in: string
> | scan i char characterStack beginners enders |
> i := start.
> (string at: i) = $^
> ifTrue: [ ^ string size - 1 ].
> (char := string at: i) isCompilerSpecial
> ifTrue: [
> ^ (i < string size and: [ (char := string at: i + 1)
> isCompilerSpecial ])
> ifTrue: [ i + 1 ]
> ifFalse: [ i ] ].
> scan := true.
> [ scan ]
> whileTrue: [
> [ i <= string size and: [ (string at: i) isSeparator ] ]
> whileTrue: [ i := i + 1 ].
> [
> i <= string size
> and: [ (char := string at: i) isAlphaNumeric or: [ char = $_ ] ] ]
> whileTrue: [ i := i + 1 ].
> char = $:
> ifFalse: [ ^ i - 1 ].
> scan := start == 1.
> scan
> ifTrue: [ i := i + 1 ] ].
> characterStack := OrderedCollection new.
> beginners := String
> with: $'
> with: $"
> with: $(
> with: $[.
> enders := String with: $) with: $].
> [
> i := i + 1.
> i < string size ]
> whileTrue: [
> char := string at: i.
> characterStack isEmpty
> ifTrue: [
> (char = $. or: [ char = $; ])
> ifTrue: [ ^ i - 1 ].
> (beginners includes: char)
> ifTrue: [ characterStack addLast: char ]
> ifFalse: [
> (enders includes: char)
> ifTrue: [ ^ i - 1 ] ] ]
> ifFalse: [
> (characterStack last = $' or: [ characterStack last = $" ])
> ifTrue: [
> char = characterStack last
> ifTrue: [ characterStack removeLast ] ]
> ifFalse: [
> (beginners includes: char)
> ifTrue: [ characterStack addLast: char ]
> ifFalse: [
> (characterStack last = $( and: [ char = $) ])
> ifTrue: [ characterStack removeLast ]
> ifFalse: [
> (characterStack last = $[ and: [ char = $] ])
> ifTrue: [ characterStack removeLast ] ] ] ] ] ].
> ^ i - 1
>
>
> On Fri, Nov 3, 2017 at 7:15 PM, Dale Henrichs via Glass
> <glass at lists.gemtalksystems.com
> <mailto:glass at lists.gemtalksystems.com>> wrote:
>
> Mariano,
>
> Take a look at TDStackFrame>>calculateSelectionRange ...
>
> You can easily look at the implementation of the debugger ... in
> the text pane that has the highlighted source from the debugger,
> use the `Window > inspect builder` menu item to bring up the code
> that implements that pane ... you'll get an inspector on something
> like this:
>
> Inspect aTDStackFrameMethodElementBuilder/
> --------------------
> . -> aTDStackFrameMethodElementBuilder
> (class)@ -> TDStackFrameMethodElementBuilder
> (oop)@ -> 204640769
> formatOnAccept@ -> nil
> formatOnDisplay@ -> nil
> object@ ->
> SmallInteger(Object)>>_doesNotUnderstand:args:envId:reason: @7 line 12
> objectBlock@ -> nil
> theEditorSpec@ -> aTDEditorSpec
> theWindowLocation@ -> nil
> theWindowName@ -> nil
>
> and then clicking on the `object` field, you'll find what I think
> your are looking for:
>
> Inspect
> aTDStackFrameMethodElementBuilder/SmallInteger(Object)>>_doesNotUnderstand:args:envId:reason:
> @7 line 12/
> --------------------
> . ->
> SmallInteger(Object)>>_doesNotUnderstand:args:envId:reason: @7 line 12
> .. -> aTDStackFrameMethodElementBuilder
> (class)@ -> TDStackFrame
> (oop)@ -> 197204737
> argAndTempNames@ -> anArray( 'aSymbol', 'anArray', 'aSmallInt',
> 'dnuKind', '.t1', '.t2')
> frameContents@ -> anArray( aGsNMethod, 144, nil, nil, nil, nil,
> nil, 2, anArray( #'aSymbol', #'anArray', #'aSmallInt', #'dnuKind',
> '.t1', '.t2'), 2, #'foo'...
> frameIndex@ -> 5
> next@ -> Executed Code
> previous@ -> SmallInteger(Object)>>doesNotUnderstand: @10
> line 10
> selectionRange@ -> anInterval( 579, 580, 581, 582, 583, 584, 585,
> 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598,
> 599, 600, 601, 602, 603, ...
> stack@ -> error printing
>
> You will see that the object behind the text pane is a
> TDStackFrame with an instance variable selectionRange ... and that
> should lead you to TDStackFrame>>calculateSelectionRange....
>
> Most of the raw information you will need is in the frameContents
> that you can get from the continuation instance ...
>
> Hope this helps,
>
> Dale
>
>
> On 11/3/17 2:22 PM, Mariano Martinez Peck via Glass wrote:
>> Hi guys,
>>
>> Imagine the debugger prints
>>
>> "8. [] in
>> DpQuuveProductionWalkbackErrorHandler(WAExceptionHandler)>>handleExceptionsDuring:
>> @7 line 8"
>>
>> I manage to get to do doing some hack like this:
>>
>> (self instVarNamed: 'continuation' ) _reportAt: 8
>>
>> I understand 7 is the step pointer and 8 is the line number. The
>> debugger knows where to start and where to stop that part of the
>> step. See attached picture. See the blue text? how can I ask that
>> to the GsContext ?
>>
>> Thanks in advance,
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com <http://marianopeck.wordpress.com>
>>
>>
>> _______________________________________________
>> Glass mailing list
>> Glass at lists.gemtalksystems.com
>> <mailto:Glass at lists.gemtalksystems.com>
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>> <http://lists.gemtalksystems.com/mailman/listinfo/glass>
>
>
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com <mailto:Glass at lists.gemtalksystems.com>
> http://lists.gemtalksystems.com/mailman/listinfo/glass
> <http://lists.gemtalksystems.com/mailman/listinfo/glass>
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20171104/9dbe1a13/attachment.html>
More information about the Glass
mailing list