VDBInstructionPresenter.st
author Jan Vrany <jan.vrany@labware.com>
Mon, 30 May 2022 14:18:03 +0100
changeset 264 23960fcb9dac
parent 225 0771f7b406d6
child 265 f2470f0dd9cd
permissions -rw-r--r--
Relicense under MIT license.

"
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:#VDBInstructionPresenter
	instanceVariableNames:'instruction basicBlock'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Presentation'
!

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

!VDBInstructionPresenter 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:VDBInstructionPresenter andSelector:#contextMenu
     (Menu new fromLiteralArrayEncoding:(VDBInstructionPresenter contextMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu (
         (MenuItem
            label: 'Copy Address'
            itemValue: doCopyAddress
            isVisible: true
         )
       ) nil
        nil
     )
! !

!VDBInstructionPresenter methodsFor:'accessing'!

address
    ^instruction address

    "Created: / 26-06-2018 / 12:42:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

basicBlock
    ^ basicBlock
!

instruction
    ^ instruction
!

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

    ^ instruction

    "Created: / 22-06-2018 / 15:10:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBInstructionPresenter methodsFor:'initialization'!

setBasicBlock: aVDBBasicBLock
    basicBlock := aVDBBasicBLock

    "Created: / 26-06-2018 / 12:37:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setInstruction: aGDBInstruction
    instruction := aGDBInstruction

    "Created: / 22-06-2018 / 12:19:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBInstructionPresenter methodsFor:'menu actions'!

doCopyAddress
    self doCopy: '0x', (instruction address printStringRadix: 16 size: 16 fill: $0)
! !

!VDBInstructionPresenter methodsFor:'protocol-accessing'!

icon
    | breakpoints |

    breakpoints := instruction breakpoints.
    breakpoints notEmpty ifTrue: [  
        (breakpoints anySatisfy: [:bkpt | bkpt enabled ]) ifTrue: [ 
            ^ VDBIconLibrary brkp_obj
        ] ifFalse: [ 
            ^ VDBIconLibrary brkpd_obj
        ].
    ].
    ^ nil

    "Created: / 28-05-2021 / 21:46:00 / Jan Vrany <jan.vrany@labware.com>"
    "Modified: / 01-06-2021 / 10:51:58 / Jan Vrany <jan.vrany@labware.com>"
!

label
    ^String streamContents:[ :s |
        (parent notNil and:[ parent askFor: #isInstructionsAndSourcePresenter ]) ifTrue:[
            s next: parent lineDigitsToDisplay put: Character space.   
        ].
        instruction address printOn: s base: 16 size: 16 fill: $0.
        s space.
        s nextPutAll: instruction assembly withTabsExpanded
    ]

    "Created: / 22-06-2018 / 12:21:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-01-2019 / 11:33:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBInstructionPresenter methodsFor:'testing'!

isInstructionPresenter
    ^ true
! !

!VDBInstructionPresenter class methodsFor:'documentation'!

version_HG

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