VDBThreadPresenter.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 26 Jun 2018 13:19:02 +0100
changeset 80 7a9cf1d6be50
parent 60 bcdb393c956f
child 197 a4f790013a99
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:
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     1
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     2
jv:vdb - Visual / VM Debugger
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     4
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     5
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     6
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     7
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
     8
"
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
"{ Package: 'jv:vdb' }"
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    11
"{ NameSpace: Smalltalk }"
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    12
60
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    13
VDBAbstractPresenter subclass:#VDBThreadPresenter
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    14
	instanceVariableNames:'thread name'
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	classVariableNames:''
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
	poolDictionaries:''
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	category:'VDB-Presentation'
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
!
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    20
!VDBThreadPresenter class methodsFor:'documentation'!
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    21
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    22
copyright
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    23
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    24
jv:vdb - Visual / VM Debugger
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    25
Copyright (C) 2015-now Jan Vrany
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    26
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    27
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    28
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    29
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    30
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    31
! !
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    32
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    33
!VDBThreadPresenter methodsFor:'accessing'!
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
24
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    35
icon
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    36
    thread isRunning ifTrue:[ ^ VDBIconLibrary threadRunning16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    37
    thread isStopped ifTrue:[ ^ VDBIconLibrary threadStopped16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    38
    thread isTerminated ifTrue:[ ^ VDBIconLibrary threadTerminated16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    39
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    40
    ^ nil
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    41
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    42
    "Created: / 22-09-2014 / 22:00:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    43
!
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    44
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    45
label
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    46
    name isNil ifTrue:[ 
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    47
        thread isRunning ifFalse:[
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    48
            name := thread name.
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    49
        ]
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    50
    ].
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    51
    ^ '%1 [%2]' bindWith: (name notNil ifTrue:[name] ifFalse:['thread ' , thread id printString]) with: thread status
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    53
    "Created: / 22-09-2014 / 00:14:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    54
    "Modified: / 12-07-2017 / 14:23:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    55
!
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    56
60
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    57
subject
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    58
    "Return an instance of GDB object that this presenter displays."
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    59
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    60
    ^ thread
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    61
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    62
    "Modified: / 05-02-2018 / 13:08:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    63
!
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    64
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    65
thread
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    66
    ^ thread
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
!VDBThreadPresenter methodsFor:'initialization'!
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
setThread: aGDBThread
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    72
    thread := aGDBThread.
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    "Created: / 21-09-2014 / 23:39:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    75
    "Modified: / 12-07-2017 / 14:21:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
!VDBThreadPresenter methodsFor:'protocol-accessing'!
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
fetchChildren
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    "should compute the list of children via the model.
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
     Be aware, that the somewhat stupid 'optimization' of how the model is fetched may lead to
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
     a O(n*log n) or even O(n^2) behavior here.
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
     *** to optimize: redefine by subClass"
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    86
     thread isDead ifTrue:[ ^ #() ].
31
00f6de198c7f Minor fixes in the UI - redraw stack list when execution state changes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    87
     thread isRunning ifTrue:[ ^ #() ].
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    88
     ^ thread stack collect:[ :f | VDBFramePresenter new setFrame: f; parent: self ]
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    "Created: / 21-09-2014 / 23:42:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
31
00f6de198c7f Minor fixes in the UI - redraw stack list when execution state changes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    91
    "Modified: / 30-09-2014 / 00:04:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
23
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    94
!VDBThreadPresenter methodsFor:'testing'!
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    95
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    96
isThreadPresenter
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    97
    ^ true
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    98
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    99
    "Created: / 21-09-2014 / 23:54:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   100
! !
ed5f4b55cee5 Added toolbar and icons. Show all thread groups and threads in stack view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   101
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   102
!VDBThreadPresenter class methodsFor:'documentation'!
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   103
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   104
version_HG
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   105
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   106
    ^ '$Changeset: <not expanded> $'
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   107
! !
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   108