VDBThreadPresenter.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 18 May 2021 11:21:13 +0100
changeset 219 6ab12a17ca3b
parent 212 62bb14c71a71
child 260 be963ee78dba
permissions -rw-r--r--
UX: selectively update stack tree to minimize changes Previously, a whole stack tree has been recreated upon stop event. For multithreaded programs with deep stacks this caused annoying flickering (especially when target is some slow dev board) as well as weird selection losses. This commit selectively updates stack tree upon stop event to minimize (or completely avoid) changes to the three. This reduces flickering.
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
212
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
     4
Copyright (C) 2020-2021 LabWare
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
     5
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
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
     7
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
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
     9
"
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
"{ Package: 'jv:vdb' }"
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    12
"{ NameSpace: Smalltalk }"
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    13
60
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    14
VDBAbstractPresenter subclass:#VDBThreadPresenter
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    15
	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
    16
	classVariableNames:''
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	poolDictionaries:''
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
	category:'VDB-Presentation'
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
!
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
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
    21
!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
    22
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
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
    24
"
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
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
    26
Copyright (C) 2015-now Jan Vrany
212
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
    27
Copyright (C) 2020-2021 LabWare
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
    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
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
    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
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
    32
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 45
diff changeset
    33
! !
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    34
197
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    35
!VDBThreadPresenter class methodsFor:'menu specs'!
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    36
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    37
contextMenu
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    38
    "This resource specification was automatically generated
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    39
     by the MenuEditor of ST/X."
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    40
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    41
    "Do not manually edit this!! If it is corrupted,
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    42
     the MenuEditor may not be able to read the specification."
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    43
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    44
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    45
    "
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    46
     MenuEditor new openOnClass:VDBThreadPresenter andSelector:#contextMenu
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    47
     (Menu new fromLiteralArrayEncoding:(VDBThreadPresenter contextMenu)) startUp
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    48
    "
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    49
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    50
    <resource: #menu>
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    51
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    52
    ^ 
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    53
     #(Menu (
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    54
         (MenuItem
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    55
            enabled: canCopyBacktrace
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    56
            label: 'Copy Backtrace To Clipboard'
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    57
            itemValue: doCopyBacktraceToClipboard
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    58
            isVisible: true
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    59
         )
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    60
       ) nil
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    61
        nil
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    62
     )
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
    63
! !
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
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
!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
    66
24
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    67
icon
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    68
    thread isRunning ifTrue:[ ^ VDBIconLibrary threadRunning16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    69
    thread isStopped ifTrue:[ ^ VDBIconLibrary threadStopped16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    70
    thread isTerminated ifTrue:[ ^ VDBIconLibrary threadTerminated16x16 ].
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    71
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    72
    ^ nil
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    73
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    74
    "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
    75
!
c33a063cb363 Added icons from Eclipse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
    76
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
    77
label
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    78
    name isNil ifTrue:[ 
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    79
        thread isRunning ifFalse:[
207
27e7fa4229b3 UI: show thread name (instead of id) in stack view
Jan Vrany <jan.vrany@labware.com>
parents: 197
diff changeset
    80
            name := '"' , thread name , '"'
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    81
        ]
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
    82
    ].
207
27e7fa4229b3 UI: show thread name (instead of id) in stack view
Jan Vrany <jan.vrany@labware.com>
parents: 197
diff changeset
    83
    ^ 'Thread %1 [%2] %3' bindWith: (thread id printStringRadix: 10 size: 2 fill: Character space) with: thread status with: name ? ''
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
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
    85
    "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
    86
    "Modified: / 12-07-2017 / 14:23:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
207
27e7fa4229b3 UI: show thread name (instead of id) in stack view
Jan Vrany <jan.vrany@labware.com>
parents: 197
diff changeset
    87
    "Modified: / 27-11-2020 / 13:44:36 / Jan Vrany <jan.vrany@labware.com>"
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
!
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
    89
60
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    90
subject
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    91
    "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
    92
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    93
    ^ thread
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    94
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    95
    "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
    96
!
bcdb393c956f Cleanup of (former) `VDBModelPresenter`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
    97
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
    98
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
    99
    ^ thread
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
219
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   102
!VDBThreadPresenter methodsFor:'change & update'!
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   103
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   104
updateChildren
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   105
    children isNil ifTrue: [ 
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   106
        ^ self 
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   107
    ].
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   108
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   109
    children isEmpty ifTrue: [ 
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   110
        super updateChildren.
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   111
        ^ self
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   112
    ].
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   113
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   114
    (children size = thread stack size and: [ children first frame == thread stack first ]) ifTrue: [ 
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   115
        ^ self
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   116
    ].
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   117
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   118
    super updateChildren.
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   119
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   120
    "Created: / 17-05-2021 / 19:45:32 / Jan Vrany <jan.vrany@labware.com>"
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   121
! !
6ab12a17ca3b UX: selectively update stack tree to minimize changes
Jan Vrany <jan.vrany@labware.com>
parents: 212
diff changeset
   122
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
!VDBThreadPresenter methodsFor:'initialization'!
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
setThread: aGDBThread
45
cd9f46746fd1 Cache the thread name
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   126
    thread := aGDBThread.
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
    "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
   129
    "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
   130
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
197
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   132
!VDBThreadPresenter methodsFor:'menu actions'!
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   133
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   134
doCopyBacktraceToClipboard
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   135
    | backtrace |
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   136
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   137
    backtrace := String streamContents:[:s|
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   138
        thread stack 
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   139
            do: [:frame | frame dumpOn: s ]
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   140
            separatedBy: [ s cr; nextPutAll: '--'; cr ]       
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   141
    ].
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   142
    self doCopy: backtrace
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   143
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   144
    "Modified: / 09-08-2020 / 07:15:42 / Jan Vrany <jan.vrany@labware.com>"
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   145
! !
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   146
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   147
!VDBThreadPresenter methodsFor:'menu queries'!
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   148
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   149
canCopyBacktrace
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   150
    ^ [ thread isStopped ]
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   151
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   152
    "Modified: / 09-08-2020 / 07:01:35 / Jan Vrany <jan.vrany@labware.com>"
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   153
! !
a4f790013a99 UI: add "Copy Backtrace to Clipboard" menu item
Jan Vrany <jan.vrany@labware.com>
parents: 60
diff changeset
   154
212
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   155
!VDBThreadPresenter methodsFor:'printing & storing'!
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   156
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   157
printOn:aStream
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   158
    "append a printed representation of the receiver to the argument, aStream"
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   159
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   160
    super printOn:aStream.
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   161
    aStream nextPut:$(.
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   162
    thread printOn:aStream.
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   163
    aStream nextPut:$).
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   164
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   165
    "Created: / 14-05-2021 / 14:33:55 / Jan Vrany <jan.vrany@labware.com>"
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   166
! !
62bb14c71a71 Add `#printOn:` to thread group, thread and frame presenters
Jan Vrany <jan.vrany@labware.com>
parents: 208
diff changeset
   167
22
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
!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
   169
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
fetchChildren
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    "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
   172
     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
   173
     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
   174
     *** 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
   175
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
   176
     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
   177
     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
   178
     ^ 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
   179
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
    "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
   181
    "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
   182
! !
6684f4d82301 Temporary commit: reworking VDBStackApplication to support multiple threads and inferiors
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
208
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   184
!VDBThreadPresenter methodsFor:'protocol-queries'!
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   185
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   186
hasChildren
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   187
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   188
    "/ Here we assume a thread has at least one frame.
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   189
    "/ This is NOT true is certain corner cases, however,
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   190
    "/ unconditionally answering `true` here avoids round-trip
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   191
    "/ to GDB until thread node is actually "expanded".
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   192
    ^ true
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   193
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   194
    "Created: / 10-12-2020 / 00:05:41 / Jan Vrany <jan.vrany@labware.com>"
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   195
    "Modified (comment): / 10-12-2020 / 20:17:56 / Jan Vrany <jan.vrany@labware.com>"
719dfb28b819 UX: avoid round trip to GDB until thread node is expanded
Jan Vrany <jan.vrany@labware.com>
parents: 207
diff changeset
   196
! !
207
27e7fa4229b3 UI: show thread name (instead of id) in stack view
Jan Vrany <jan.vrany@labware.com>
parents: 197
diff changeset
   197
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
   198
!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
   199
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
   200
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
   201
    ^ 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
   202
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
   203
    "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
   204
! !
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
   205
38
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   206
!VDBThreadPresenter class methodsFor:'documentation'!
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   207
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   208
version_HG
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   209
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   210
    ^ '$Changeset: <not expanded> $'
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   211
! !
9b861cb882c8 Show al thread groupd, even terminated ones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   212