GDBFrame.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 17 Nov 2017 20:36:08 -0300
changeset 90 6046abc9ddf4
parent 82 7ee72b7a498f
child 91 472a4841a8b6
permissions -rw-r--r--
Replaced Squek computed arrays by more verbose `Array with:...` ...to workaround a buggy stx, sigh.

"{ Package: 'jv:libgdbs' }"

"{ NameSpace: Smalltalk }"

GDBTransientObject subclass:#GDBFrame
	instanceVariableNames:'thread level addr func file fullname line from variables'
	classVariableNames:''
	poolDictionaries:''
	category:'GDB-Core'
!


!GDBFrame class methodsFor:'accessing - GDB value descriptors'!

description
    ^ (super description)
        define:#level as:Integer;
        define:#func as:String;
        define:#file as:String;
        define:#fullname as:String;
        define:#line as:Integer;
        define:#from as:String;
        define:#addr as:Integer;
        yourself

    "Created: / 16-09-2014 / 23:59:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBFrame methodsFor:'accessing'!

addr
    ^ addr
!

file
    "Return filename containing frame's function source."
    ^ fullname notNil ifTrue:[ fullname ] ifFalse:[ file ]

    "Modified: / 11-06-2017 / 20:59:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

from
    ^ from
!

fullname
    ^ fullname
!

func
    ^ func
!

level
    ^ level
!

line
    ^ line
!

thread
    ^ thread
!

variables
    self ensureIsValid.
    variables isNil ifTrue:[
        variables := GDBTransientDataHolder debugger: debugger factory:[ 
            | result |

            result := debugger send: (GDBMI_stack_list_variables new arguments: (Array with: '--thread' with: thread id with: '--frame' with: level with: '--simple-values')).
            (result propertyAt: #variables) ? #()
                do:[ :each | each setFrame: self ];
                yourself
        ].
    ].
    ^ variables value

    "Created: / 27-02-2015 / 14:56:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-11-2017 / 20:22:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBFrame methodsFor:'printing & storing'!

displayString
    ^ String streamContents: [ :aStream |
        | f |

        f := self file.
        level printOn:aStream base: 10 size: 2 fill: Character space.
        aStream nextPutAll:' '.
        addr printOn:aStream.
        aStream nextPutAll:' '.
        func notNil ifTrue:[
            func printOn:aStream.
        ] ifFalse:[ 
            aStream nextPutAll: '?'
        ].
        f notNil ifTrue:[
            aStream nextPutAll:' ('.
            aStream nextPutAll: f startingAt: (f lastIndexOf: Filename separator) + 1.
            line notNil ifTrue:[
                aStream nextPutAll:':'.
                line printOn:aStream.
            ].
            aStream nextPutAll:')'.
        ].
    ].

    "Created: / 27-02-2015 / 15:20:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-06-2017 / 09:04:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

printOn:aStream
    "append a printed representation if the receiver to the argument, aStream"

    super printOn: aStream.
    aStream nextPutAll:'('.
    level printOn:aStream base: 10 size: 2 fill: Character space.
    aStream nextPutAll:' '.
    addr printOn:aStream.
    aStream nextPutAll:' '.
    func printOn:aStream.
    aStream nextPutAll:' - '.
    file printOn:aStream.
    aStream nextPutAll:':'.
    line printOn:aStream.
    aStream nextPutAll:')'.

    "Modified: / 27-02-2015 / 15:21:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBFrame class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !