VDBDisassemblyApplication.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 29 Jul 2022 16:12:54 +0100
changeset 266 e21d777d076e
parent 264 23960fcb9dac
permissions -rw-r--r--
Fix `VDBInstructionListApplication` to analyze blocks for standalone instruction list ...that is, for instructions without any "disassemblable" (function, address range). This is used in some inspector goodies on Compiler's code buffer.

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

VDBAbstractContentsApplication subclass:#VDBDisassemblyApplication
	instanceVariableNames:'disassemblableHolder expressionHolder frameHolder'
	classVariableNames:'LastExpression'
	poolDictionaries:''
	category:'VDB-UI-Others'
!

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

!VDBDisassemblyApplication 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:VDBDisassemblyApplication andSelector:#windowSpec
     VDBDisassemblyApplication new openInterface:#windowSpec
     VDBDisassemblyApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       uuid: 'de1aaf20-0410-11ea-a8dd-606720e43e2c'
       window: 
      (WindowSpec
         label: 'Disassembly'
         name: 'Disassembly'
         uuid: '577b9b41-f381-11e9-a8dd-606720e43e2c'
         min: (Point 10 10) bounds: (Rectangle 0 0 639 463)
      ) component: 
      (SpecCollection
         collection: (
          (MenuPanelSpec
             name: 'ToolBar'
             layout: (LayoutFrame 0 0 0 0 30 0 30 0) uuid: '9ba6c0d6-0231-11e8-b0df-606720e43e2c'
             menu: toolbarMenu
             textDefault: true
          )
          (HorizontalPanelViewSpec
             name: 'HeaderBar'
             layout: (LayoutFrame 30 0 0 0 0 1 30 0) uuid: '6ec0ff21-f386-11e9-a8dd-606720e43e2c'
             horizontalLayout: rightSpaceFit
             verticalLayout: center
             horizontalSpace: 3
             verticalSpace: 3
             component: 
            (SpecCollection
               collection: (
                (InputFieldSpec
                   name: 'Expression'
                   uuid: '6ec0ff22-f386-11e9-a8dd-606720e43e2c'
                   model: expressionHolder
                   acceptOnReturn: true
                   acceptOnTab: true
                   acceptOnPointerLeave: true
                   emptyFieldReplacementText: 'Function or Address Range'
                   translateEmptyFieldReplacementText: true
                   extent: (Point 601 22)
                )
              )
            )
          )
          (SubCanvasSpec
             name: 'Instructions'
             layout: (LayoutFrame 0 0 30 0 0 1 0 1) uuid: '577b9b42-f381-11e9-a8dd-606720e43e2c'
             hasHorizontalScrollBar: false
             hasVerticalScrollBar: false
             majorKey: VDBInstructionListApplication
             subAspectHolders: 
            (Array 
              (SubChannelInfoSpec
                 subAspect: debuggerHolder
                 aspect: debuggerHolder
              ) 
              (SubChannelInfoSpec
                 subAspect: disassemblableHolder
                 aspect: disassemblableHolder
              ) 
              (SubChannelInfoSpec
                 subAspect: frameHolder
                 aspect: frameHolder
              )
            ) createNewApplication: true
             createNewBuilder: true
          )
        )
      )
    )
! !

!VDBDisassemblyApplication class methodsFor:'menu specs'!

toolbarMenu
    "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:VDBMemoryApplication andSelector:#toolbarMenu
     (Menu new fromLiteralArrayEncoding:(VDBMemoryApplication toolbarMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'Refresh'
            itemValue: doRefresh
            labelImage: (ResourceRetriever VDBIconLibrary #'refresh_tab')
          )
         )
        nil
        nil
      )
! !

!VDBDisassemblyApplication 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
      ).

! !

!VDBDisassemblyApplication methodsFor:'accessing'!

disassemblable
    ^ self disassemblableHolder value

    "Created: / 10-06-2019 / 10:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

disassemblable: anObject
    self disassemblableHolder value: anObject

    "Created: / 10-06-2019 / 10:06:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

expression
    ^ self expressionHolder value

    "Created: / 10-11-2019 / 23:33:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

expression: expr
    self expressionHolder value: expr asString

    "Created: / 10-11-2019 / 23:33:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

frame
    ^ self frameHolder value

    "Created: / 10-06-2019 / 12:44:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

frame: aGDBFrame
    ^ self frameHolder value: aGDBFrame

    "Created: / 10-06-2019 / 12:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBDisassemblyApplication methodsFor:'aspects'!

disassemblableHolder
    "return/create the 'disassemblableHolder' value holder (automatically generated)"

    disassemblableHolder isNil ifTrue:[
        disassemblableHolder := ValueHolder new.
    ].
    ^ disassemblableHolder
!

disassemblableHolder:aValueModel
    disassemblableHolder := aValueModel.

    "Modified (comment): / 20-10-2019 / 23:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

expressionHolder
    "return/create the 'expressionHolder' value holder (automatically generated)"

    expressionHolder isNil ifTrue:[
        expressionHolder := ValueHolder with: LastExpression.
        expressionHolder addDependent:self.
    ].
    ^ expressionHolder

    "Modified: / 14-10-2021 / 13:25:39 / Jan Vrany <jan.vrany@labware.com>"
!

expressionHolder:aValueModel
    "set the 'expressionHolder' value holder (automatically generated)"

    |oldValue newValue|

    expressionHolder notNil ifTrue:[
        oldValue := expressionHolder value.
        expressionHolder removeDependent:self.
    ].
    expressionHolder := aValueModel.
    expressionHolder notNil ifTrue:[
        expressionHolder addDependent:self.
    ].
    newValue := expressionHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:expressionHolder.
    ].
!

frameHolder
    "return/create the 'frameHolder' value holder (automatically generated)"

    frameHolder isNil ifTrue:[
        frameHolder := ValueHolder new.
        frameHolder addDependent:self.
    ].
    ^ frameHolder
!

frameHolder:something
    "set the 'frameHolder' value holder (automatically generated)"

    |oldValue newValue|

    frameHolder notNil ifTrue:[
        oldValue := frameHolder value.
        frameHolder removeDependent:self.
    ].
    frameHolder := something.
    frameHolder notNil ifTrue:[
        frameHolder addDependent:self.
    ].
    newValue := frameHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:frameHolder.
    ].
! !

!VDBDisassemblyApplication methodsFor:'change & update'!

update:aspect with:param from:sender
    "Invoked when an object that I depend upon sends a change notification."

    sender == expressionHolder ifTrue:[ 
         self enqueueDelayedUpdateContents.
         ^ self.
    ].
    super update:aspect with:param from:sender

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

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

delayedUpdateContents
    | expression disassemblable |

    expression := self expression.
    expression isNil ifTrue:[
        self disassemblableHolder value: nil.
    ] ifFalse:[ 
        Error ignoreIn: [
            disassemblable := VDBParser parse: expression.
            disassemblable isPetitFailure ifTrue:[ 
                disassemblable := nil.
            ] ifFalse:[
                LastExpression := expression.
                disassemblable setDebugger: debugger.
            ].
        ].
        self disassemblableHolder value: disassemblable.
    ].

    "Modified: / 10-11-2019 / 23:37:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-10-2021 / 13:26:39 / Jan Vrany <jan.vrany@labware.com>"
! !

!VDBDisassemblyApplication methodsFor:'drag & drop'!

dropObjects:aCollectionOfDropObjects
    "drop manager wants to drop.
     This is ony sent, if #canDrop: returned true.
     Must be redefined in order for drop to work."

    ^ self shouldImplement
! !

!VDBDisassemblyApplication class methodsFor:'documentation'!

version_HG

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