VDBThreadGroupPresenter.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 01 Jun 2017 12:23:04 +0100
changeset 40 d766d4c854a2
parent 38 9b861cb882c8
child 44 41cc5a7840fe
permissions -rw-r--r--
Cleanup in debugger and inferior console applications to catch up changes in `jv:libgdbs` Recent `jv:libgdbs` spawns GDB on a PTY and opening MI channel on another, debugger console has no need to emulate history, command completion and all that stuff. This is now handled by GDB itself.

"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBModelPresenter subclass:#VDBThreadGroupPresenter
	instanceVariableNames:'threadGroup'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Presentation'
!


!VDBThreadGroupPresenter methodsFor:'accessing'!

icon
    threadGroup isRunning ifTrue:[ ^ VDBIconLibrary threadGroupRunning16x16 ].
    threadGroup isStopped ifTrue:[ ^ VDBIconLibrary threadGroupStopped16x16 ].
    threadGroup isDead    ifTrue:[ ^ VDBIconLibrary threadGroupTerminated16x16 ].
    ^ nil

    "Created: / 22-09-2014 / 22:13:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-09-2014 / 00:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

label
    | pidOrEmpty state |

    (threadGroup type = 'process' and:[ threadGroup pid notNil ]) ifTrue:[
        pidOrEmpty := 'pid ', threadGroup pid printString , ', '.
    ].
    threadGroup isRunning ifTrue:[ 
        state := 'running'
    ] ifFalse:[ 
        threadGroup isStopped ifTrue:[ 
            state := 'stopped'
        ] ifFalse:[ 
            threadGroup isDead ifTrue:[ 
                state := 'terminated'
            ] ifFalse:[
                state := 'not run'
            ]
        ].
    ].

    ^ 'thread group %1 [%2%3]' bindWith: threadGroup id 
                                   with: pidOrEmpty ? ''
                                   with: state

    "Created: / 22-09-2014 / 00:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-03-2015 / 06:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

threadGroup
    ^ threadGroup
! !

!VDBThreadGroupPresenter methodsFor:'initialization'!

setThreadGroup: aGDBThreadGroup
    threadGroup := aGDBThreadGroup

    "Created: / 21-09-2014 / 23:38:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBThreadGroupPresenter methodsFor:'protocol-accessing'!

fetchChildren
    "should compute the list of children via the model.
     Be aware, that the somewhat stupid 'optimization' of how the model is fetched may lead to
     a O(n*log n) or even O(n^2) behavior here.
     *** to optimize: redefine by subClass"

    ^ threadGroup threads collect:[ :t | VDBThreadPresenter new setThread: t; parent: self ]

    "Created: / 21-09-2014 / 23:41:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBThreadGroupPresenter methodsFor:'testing'!

isThreadGroupPresenter
    ^ true

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

!VDBThreadGroupPresenter class methodsFor:'documentation'!

version_HG

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