VDBInstructionBasicBlock.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 26 Jun 2018 13:19:02 +0100
changeset 80 7a9cf1d6be50
child 93 bd0a7febf26d
permissions -rw-r--r--
UX: improvements in disasembly view (`VDBInstructionListApplication`) Namely: * when a branch instruction is selected, highlight target address, i.e, an address of next instruction if branch is taken. * highlight all instruction in basic block of currently selected instruction. This is not as cool as in Hexray IDA Pro but better than nothing. We'll get there, eventually.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
jv:vdb - Visual / VM Debugger
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
"{ Package: 'jv:vdb' }"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
"{ NameSpace: Smalltalk }"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
Object subclass:#VDBInstructionBasicBlock
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
	instanceVariableNames:'instructions precedessors successor1 successor2'
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	classVariableNames:''
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
	poolDictionaries:''
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	category:'VDB-UI-Support'
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
!VDBInstructionBasicBlock class methodsFor:'documentation'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
copyright
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
jv:vdb - Visual / VM Debugger
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
Copyright (C) 2015-now Jan Vrany
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
!VDBInstructionBasicBlock class methodsFor:'utilities'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
analyze: instructions
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    "
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
    Analyzes `instructions`, create and connect basic blocks and return
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    them in a collection.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
    `instructions` parameter should be a list of GDBInstruction or 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
    polymorphic objects).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    "
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
    | blocks curBB firstI |
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    "/ Pass 1, initial blocks by cutting after each branch
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    "/ or return instruction.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
    blocks := OrderedCollection new.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    curBB := VDBInstructionBasicBlock new.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
    instructions withIndexDo:[:last :lastI | 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
        firstI isNil ifTrue:[
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
            firstI := lastI
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
        ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
        last isBranchInstruction ifTrue:[
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
            | prevBB |
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
            curBB setInstructions: (instructions copyFrom: firstI to: lastI).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
            blocks add: curBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
            prevBB := curBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
            curBB := VDBInstructionBasicBlock new.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
            prevBB setSuccessor1: curBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
            firstI := nil.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
        ] ifFalse:[
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
        last isReturnInstruction ifTrue:[
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
            curBB setInstructions: (instructions copyFrom: firstI to: lastI).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
            blocks add: curBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
            curBB := VDBInstructionBasicBlock new.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
            firstI := nil.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
        ]].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
    ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
    curBB setInstructions: (instructions copyFrom: firstI).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
    blocks add: curBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    "/ Pass 2: iterate ober basic blocks and connect successor2 based on
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
    "/ last instructions #branchTargetAddress. If target address points in
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    "/ the middle of basic block, split it.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    blocks copy do:[:bb | 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
        bb last isBranchInstruction ifTrue:[
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
            | targetAddress succBB |
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
            targetAddress := bb last branchTargetAddress.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
            "/ Find successor block. Note, that we may found none if the branch target is
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
            "/ outside given coce.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
            succBB := blocks detect:[:e | e includesAddress: targetAddress ] ifNone: [ nil ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
            succBB notNil ifTrue:[ 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
                "/ If `targetAddress` points into the middle of `succBB` we have to split
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
                "/ succBB into two.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
                succBB firstAddress < targetAddress ifTrue:[ 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
                    | succBBs |
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
                    succBBs := succBB splitAtAddress: targetAddress.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
                    blocks remove: succBB; addAll: succBBs.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
                    succBB := succBBs last.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
                ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
                bb setSuccessor2: succBB.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
            ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
        ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
    "/ Jo done!!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    ^ blocks.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
    ^ blocks
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    "Created: / 27-06-2018 / 13:03:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    "Modified: / 27-06-2018 / 16:13:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
!VDBInstructionBasicBlock methodsFor:'accessing'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
first
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    ^ instructions first
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    "Created: / 27-06-2018 / 15:41:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
firstAddress
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    ^ self first address
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
    "Created: / 27-06-2018 / 15:41:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
last
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    ^ instructions last
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    "Created: / 27-06-2018 / 15:42:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
lastAddress
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
    ^ self last address
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
    "Created: / 27-06-2018 / 15:41:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
!VDBInstructionBasicBlock methodsFor:'initialization'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
addPrecedessor: aVDBInstructionBlock
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
    precedessors isNil ifTrue:[ 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
        precedessors := Array with: aVDBInstructionBlock.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
    ] ifFalse:[ 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
        precedessors := precedessors copyWith: aVDBInstructionBlock
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
    ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
    "Created: / 27-06-2018 / 15:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
setInstructions: aCollection
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
    instructions := aCollection
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
    "Created: / 27-06-2018 / 14:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
setSuccessor1: aVDBInstructionBasicBlock
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
    successor1 := aVDBInstructionBasicBlock.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
    successor1 addPrecedessor: self.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
    "Created: / 27-06-2018 / 15:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
setSuccessor2: aVDBInstructionBasicBlock
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
    successor2 := aVDBInstructionBasicBlock.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    successor2 addPrecedessor: self.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
    "Created: / 27-06-2018 / 15:28:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
!VDBInstructionBasicBlock methodsFor:'queries'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
includes: instruction
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
    ^ instructions includes: instruction
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
    "Created: / 27-06-2018 / 15:37:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
includesAddress: address
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
    "Return `true`, if this basic block includes an instruction
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
     with given address, false otherwise."
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
    ^ (address between: instructions first address and: instructions last address)
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
    "Created: / 27-06-2018 / 15:40:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
!VDBInstructionBasicBlock methodsFor:'utilities'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
splitAtAddress: address
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    | splitIdx bb1 bb2 |
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
    splitIdx := instructions indexOf: (instructions detect:[:e | e address = address ] ifNone:[ nil ]).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
    "/ Note, that thhere might not be any instruction with that address, such as
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
    "/ when ill-code jumps into the middle of instruction...
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
    splitIdx == 0 ifTrue:[ 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
        "/ ...in that case, make no split and return self so this case is 
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
        "/ transparent to users.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
        ^Array with: self.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
    ].
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
    bb1 := self class new setInstructions: (instructions copyTo: splitIdx - 1).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
    bb2 := self class new setInstructions: (instructions copyFrom: splitIdx).
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
    bb1 setSuccessor1: bb2.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
    ^ Array with: bb1 with: bb2.
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    "Created: / 27-06-2018 / 16:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
!VDBInstructionBasicBlock class methodsFor:'documentation'!
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
version_HG
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
    ^ '$Changeset: <not expanded> $'
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
! !
7a9cf1d6be50 UX: improvements in disasembly view (`VDBInstructionListApplication`)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211