GDBThreadInfo.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 07 Dec 2023 12:33:31 +0000
changeset 322 1b26d0a9560c
parent 272 cdd1c9ad00de
permissions -rw-r--r--
Emit and handle (custom) `-register-changed` notification This commit adds new (custom) asynchronous notification about register value being changed. Standard GDB does not notify MI clients about register value being changed when debugging (for example, by CLI command `set $rax = 1` or via Python's `Value.assign()`). This caused libgdb's register value cache being out of sync. In the past, this was partially worked around by manually emiting the notification on `GDBRegisterWithValue` APIs, but this did not (and could not) handle the case register was changed from GDB command line. To solve this problem, this commit installs a custom Python event handler that emits new GDB/MI notification - `-register-changed` - whenever a register changes after debugee is stopped. This has been enabled by upstream GDB commit 4825fd "gdb/python: implement support for sending custom MI async notifications" On libgdbs side, complete inferior state is invalidated. In theory, one could carefully invalidate only the changed `GDBRegisterWithValue` but in certain cases this could also change the backtrace (for example, if one updates stack pointer) or position in code. So it seems safer to just invalidate everything.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
     1
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
     2
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
214
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
     4
Copyright (C) 2020 LabWare
272
cdd1c9ad00de Change class categories to facilitate Pharo port
Jan Vrany <jan.vrany@labware.com>
parents: 259
diff changeset
     5
Copyright (C) 2022-2023 LabWare
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
     6
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
     7
Permission is hereby granted, free of charge, to any person obtaining a copy
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
     8
of this software and associated documentation files (the 'Software'), to deal
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
     9
in the Software without restriction, including without limitation the rights
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    10
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    11
copies of the Software, and to permit persons to whom the Software is
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    12
furnished to do so, subject to the following conditions:
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    13
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    14
The above copyright notice and this permission notice shall be included in all
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    15
copies or substantial portions of the Software.
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    16
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    17
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    20
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    21
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    22
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    23
SOFTWARE.
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    24
"
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
"{ Package: 'jv:libgdbs' }"
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
"{ NameSpace: Smalltalk }"
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
GDBObject subclass:#GDBThreadInfo
214
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    30
	instanceVariableNames:'id target_id name frame state'
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
	classVariableNames:''
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
	poolDictionaries:''
272
cdd1c9ad00de Change class categories to facilitate Pharo port
Jan Vrany <jan.vrany@labware.com>
parents: 259
diff changeset
    33
	category:'GDB-Internal'
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    36
!GDBThreadInfo class methodsFor:'documentation'!
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    37
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    38
copyright
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    39
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    40
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    41
Copyright (C) 2015-now Jan Vrany
214
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    42
Copyright (C) 2020 LabWare
272
cdd1c9ad00de Change class categories to facilitate Pharo port
Jan Vrany <jan.vrany@labware.com>
parents: 259
diff changeset
    43
Copyright (C) 2022-2023 LabWare
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    44
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    45
Permission is hereby granted, free of charge, to any person obtaining a copy
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    46
of this software and associated documentation files (the 'Software'), to deal
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    47
in the Software without restriction, including without limitation the rights
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    48
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    49
copies of the Software, and to permit persons to whom the Software is
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    50
furnished to do so, subject to the following conditions:
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    51
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    52
The above copyright notice and this permission notice shall be included in all
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    53
copies or substantial portions of the Software.
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    54
259
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    55
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    56
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    57
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    58
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    59
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    60
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
651864c2aa29 Relicense under MIT license.
Jan Vrany <jan.vrany@labware.com>
parents: 214
diff changeset
    61
SOFTWARE.
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    62
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    63
! !
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    64
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
!GDBThreadInfo class methodsFor:'accessing - GDB value descriptors'!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
description
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
    ^ (super description)
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
        define:#'id' as:Integer;
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
        define:#'target-id' as:String;
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
        "/ define:#'frame' as: GDBFrame
89
ba62d486014f Initial support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    72
        define:#'state' as: String;
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
        yourself
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    "Created: / 06-09-2014 / 02:21:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
89
ba62d486014f Initial support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    76
    "Modified: / 12-11-2017 / 17:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
! !
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
!GDBThreadInfo methodsFor:'accessing'!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
id
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    ^ id
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
214
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    85
name
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    86
    ^ name
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    87
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    88
    "Created: / 27-11-2020 / 13:40:04 / Jan Vrany <jan.vrany@labware.com>"
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    89
!
0c56387e5d12 Add `GDBThread >> #name`
Jan Vrany <jan.vrany@labware.com>
parents: 104
diff changeset
    90
67
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
state
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    ^ state
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
targetId
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    ^ target_id
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
    "Created: / 08-03-2015 / 08:39:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
! !
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
!GDBThreadInfo methodsFor:'accessing-private'!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
_state: aString
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
    state := GDBThreadState fromString: aString
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    "Created: / 08-03-2015 / 08:35:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
! !
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
!GDBThreadInfo methodsFor:'initialization'!
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
setId: idArg state: stateArg
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    id := idArg.
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
    state := stateArg
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
    "Created: / 08-03-2015 / 10:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
! !
c4ac76afe03d Keep thread information in transient thread-info object.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
100
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   118
!GDBThreadInfo class methodsFor:'documentation'!
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   119
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   120
version_HG
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   121
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   122
    ^ '$Changeset: <not expanded> $'
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   123
! !
aab8dd376f29 Fixed SubscriptionCollection >> value:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   124