VDBFramePresenter.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 }"

VDBAbstractPresenter subclass:#VDBFramePresenter
	instanceVariableNames:'frame'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Presentation'
!

!VDBFramePresenter 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.
"
! !

!VDBFramePresenter class methodsFor:'menu specs'!

contextMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

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


    "
     MenuEditor new openOnClass:VDBFramePresenter andSelector:#contextMenu
     (Menu new fromLiteralArrayEncoding:(VDBFramePresenter contextMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'Disassemble'
            itemValue: doDisassemble
            isVisible: true
          )
         (MenuItem
            enabled: canCopyFunctionName
            label: 'Copy Function Name'
            itemValue: doCopyFunctionName
            isVisible: true
          )
         )
        nil
        nil
      )
! !

!VDBFramePresenter methodsFor:'accessing'!

frame
    ^ frame
!

icon
    ^ frame thread isRunning 
        ifTrue:[ VDBIconLibrary frameRunning16x16 ]
        ifFalse:[ VDBIconLibrary frameStopped16x16 ]

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

label
    ^ frame displayString

    "Created: / 22-09-2014 / 00:14:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

subject
    "Return an instance of GDB object that this presenter displays."

    ^ frame

    "Modified: / 05-02-2018 / 13:08:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBFramePresenter methodsFor:'initialization'!

setFrame: aGDBFrame
    ^ frame := aGDBFrame

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

!VDBFramePresenter methodsFor:'menu-actions'!

doCopyFunctionName
    <resource: #uiCallback>

    self doCopy: frame func.

    "Modified: / 16-01-2018 / 22:36:37 / jv"
!

doDisassemble
    VDBDisassemblyApplication new
        title: (self class classResources string: '%1 (disassembly)' with: frame func ? '?');
        debugger: frame debugger;
        expression: (VDBAddress value: frame address);
        frame: frame;
        open.

    "Modified: / 10-11-2019 / 23:40:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBFramePresenter methodsFor:'menu-queries'!

canCopyFunctionName
   ^ frame func notNil

    "Modified: / 16-01-2018 / 22:19:59 / jv"
    "Modified: / 05-02-2018 / 12:13:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBFramePresenter methodsFor:'printing & storing'!

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

    super printOn:aStream.
    aStream nextPut:$(.
    frame printOn:aStream.
    aStream nextPut:$).

    "Modified: / 14-05-2021 / 14:34:52 / Jan Vrany <jan.vrany@labware.com>"
! !

!VDBFramePresenter 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"

    ^  #()

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

!VDBFramePresenter methodsFor:'testing'!

isFramePresenter
    ^ true

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

!VDBFramePresenter class methodsFor:'documentation'!

version_HG

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