VDBStatusApplication.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 26 Jul 2022 15:01:33 +0100
changeset 265 f2470f0dd9cd
parent 264 23960fcb9dac
permissions -rw-r--r--
Do not show address for (pseudo) instructions with no code While such instructions do not appear in GDB-produced disassembly, they may appear in some manually-generated instruction lists. One example of such (pseudo) instruction is label.

"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
Copyright (C) 2021-2022 LabWare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBAbstractApplication subclass:#VDBStatusApplication
	instanceVariableNames:'statusTextHolder running commands'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others'
!

!VDBStatusApplication class methodsFor:'documentation'!

copyright
"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
Copyright (C) 2021-2022 LabWare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
! !

!VDBStatusApplication class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VDBStatusApplication andSelector:#windowSpec
     VDBStatusApplication new openInterface:#windowSpec
     VDBStatusApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       uuid: 'd148ed70-316b-11e9-8b55-606720e43e2c'
       window: 
      (WindowSpec
         label: 'Debugger Status'
         name: 'Debugger Status'
         uuid: '7f956341-3167-11e9-8b55-606720e43e2c'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 30)
       )
       component: 
      (SpecCollection
         collection: (
          (LabelSpec
             label: 'Label'
             name: 'StatusText'
             layout: (LayoutFrame 0 0 0 0 0 1 30 0)
             uuid: '7f956342-3167-11e9-8b55-606720e43e2c'
             translateLabel: true
             labelChannel: statusTextHolder
             adjust: left
             postBuildCallback: postBuildStatusText:
             usePreferredHeight: true
           )
          )
        
       )
     )
! !

!VDBStatusApplication class methodsFor:'plugIn spec'!

aspectSelectors
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this. If it is corrupted,
     the UIPainter may not be able to read the specification."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #debuggerHolder
      ).

! !

!VDBStatusApplication methodsFor:'aspects'!

statusTextHolder
    <resource: #uiAspect>

    statusTextHolder isNil ifTrue:[
        statusTextHolder := ValueHolder new.
        self enqueueDelayedUpdateStatusText.
    ].
    ^ statusTextHolder.

    "Modified: / 18-02-2019 / 08:39:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'change & update'!

enqueueDelayedUpdateStatusText
    self enqueueMessage: #delayedUpdateStatusText

    "Created: / 16-02-2019 / 08:20:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-02-2019 / 10:23:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'change & update-delayed'!

delayedUpdateStatusText
    | status |

    debugger notNil ifTrue:[
        running ifTrue:[ 
            status := resources string: 'RUN'
        ] ifFalse:[ 
            debugger hasPendingCommands ifTrue:[ 
                status := resources string: 'BSY'
            ] ifFalse:[ 
                status := resources string: 'RDY'
            ].
        ].
    ] ifFalse:[ 
        status := resources string: 'DIS'
    ].
    self statusTextHolder value:
        ('[%1] C: %2' bindWith: status with: commands)

    "Created: / 16-02-2019 / 08:19:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'event handling'!

onCommandEvent: event
    commands := commands + 1.
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:41:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onCommandResultEvent: event
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:41:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onRunningEvent: event
    running := true.
    commands := 0.
    self enqueueDelayedUpdateStatusText

    "Created: / 19-01-2019 / 23:46:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onStoppedEvent: event
    running := false.
    commands := 0.
    self enqueueDelayedUpdateStatusText

    "Created: / 19-01-2019 / 23:46:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'hooks'!

postBuildStatusText: aLabel
    <resource: #uiCallback>

    aLabel font: self textFont

    "Modified: / 15-02-2019 / 21:50:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'initialization & release'!

initialize
    super initialize.
    running := false.
    commands := 0

    "Created: / 15-02-2019 / 21:47:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

subscribe   
    super subscribe.

    debugger announcer
        when: GDBRunningEvent       send: #onRunningEvent:      to: self;
        when: GDBStoppedEvent       send: #onStoppedEvent:      to: self;

        when: GDBCommandEvent       send: #onCommandEvent:      to: self;
        when: GDBCommandResultEvent send: #onCommandResultEvent: to: self. 

    running := debugger inferiors anySatisfy:[ :tg | tg isRunning and:[ tg isStopped not ] ].
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-02-2019 / 08:39:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-11-2021 / 16:39:33 / Jan Vrany <jan.vrany@labware.com>"
    "Modified (comment): / 18-11-2021 / 16:24:58 / Jan Vrany <jan.vrany@labware.com>"
! !