When setting register value, invalidate only register that has changed
...and all of them. This avoids unnecessary refetch of register values.
--- a/GDBFrame.st Thu Nov 18 16:03:54 2021 +0000
+++ b/GDBFrame.st Thu Nov 18 16:12:07 2021 +0000
@@ -368,8 +368,21 @@
!GDBFrame methodsFor:'private'!
invalidate
+ self invalidate: nil
+
+ "Created: / 10-09-2021 / 15:37:31 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified: / 18-11-2021 / 12:01:12 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+invalidate: registerOrNil
variables notNil ifTrue: [ variables invalidate ].
- registers notNil ifTrue: [ registers do:[:each | each invalidate ] ].
+ registerOrNil isNil ifTrue: [
+ registers notNil ifTrue: [ registers do:[:each | each invalidate ] ]
+ ] ifFalse: [
+ self assert: registers notNil.
+ self assert:(registers includes: registerOrNil).
+ registerOrNil invalidate.
+ ].
registersChanges notNil ifTrue: [ registersChanges invalidate ].
"/ We also have to invalidate the frame PC because it may have changed
@@ -378,8 +391,7 @@
"/ New PC is lazily refetched in #addr.
addr := nil
- "Created: / 10-09-2021 / 15:37:31 / Jan Vrany <jan.vrany@labware.com>"
- "Modified (comment): / 14-10-2021 / 14:22:49 / Jan Vrany <jan.vrany@labware.com>"
+ "Created: / 18-11-2021 / 12:01:17 / Jan Vrany <jan.vrany@labware.com>"
!
registersChanges
@@ -402,7 +414,7 @@
displayed := self arch registerNumbersToDisplayUsing: self registersFile.
[
result := debugger send: (GDBMI_data_list_changed_registers new arguments: (Array with: '--thread' with: thread id with: '--frame' with: level)).
- changed := result propertyAt: #'changed-registers'.
+ changed := (result propertyAt: #'changed-registers') ? #().
displayed notEmpty ifTrue: [
changed := changed intersect: displayed.
].
@@ -410,9 +422,14 @@
changed := displayed.
].
- changed notEmptyOrNil ifTrue:[
- result := debugger send: (GDBMI_data_list_register_values new arguments: (Array with: '--thread' with: thread id with: '--frame' with: level with: 'r') , changed).
- (result propertyAt: #'register-values') asSet.
+ changed notEmptyOrNil ifTrue:[
+ [
+ result := debugger send: (GDBMI_data_list_register_values new arguments: (Array with: '--thread' with: thread id with: '--frame' with: level with: 'r') , changed).
+ (result propertyAt: #'register-values') asSet.
+ ] on: GDBCommandFailedError do: [:ex |
+ "/ Oops, some error. Thread / frame died meanwhile?
+ #()
+ ].
] ifFalse:[
#()
].
@@ -426,7 +443,7 @@
"Created: / 26-09-2018 / 22:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 22-05-2020 / 14:49:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 13-10-2021 / 18:58:13 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified: / 18-11-2021 / 13:02:09 / Jan Vrany <jan.vrany@labware.com>"
!
registersFile
--- a/GDBRegisterWithValue.st Thu Nov 18 16:03:54 2021 +0000
+++ b/GDBRegisterWithValue.st Thu Nov 18 16:12:07 2021 +0000
@@ -128,16 +128,23 @@
self value isInteger ifFalse: [
self error: 'Compound values not supported'.
].
- debugger send: (GDBMI_data_evaluate_expression arguments: (Array with: '--thread' with: frame thread id with: '--frame' with: frame level with: ('$', register name , ' = ' , (anObject asInteger printString) ))) andWait: false.
- frame invalidate.
+ debugger
+ send: (GDBMI_data_evaluate_expression arguments: (Array with: '--thread' with: frame thread id with: '--frame' with: frame level with: ('$', register name , ' = ' , (anObject asInteger printString) )))
+ andWithResultDo:[ :result |
+ result isDone ifTrue: [
+ frame invalidate: self.
+ changed value: true.
+ ].
+ ].
"Created: / 10-09-2021 / 15:31:35 / Jan Vrany <jan.vrany@labware.com>"
- "Modified: / 14-10-2021 / 01:24:05 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified: / 18-11-2021 / 12:13:34 / Jan Vrany <jan.vrany@labware.com>"
!
valueString
valueString isNil ifTrue: [
| result registers |
+
result := debugger send: (GDBMI_data_list_register_values new arguments: (Array with: '--thread' with: frame thread id with: '--frame' with: frame level with: 'r' with: register number)).
registers := result propertyAt: #'register-values'.
self assert: registers size == 1.
@@ -149,7 +156,7 @@
^ valueString
"Created: / 10-09-2021 / 14:14:14 / Jan Vrany <jan.vrany@labware.com>"
- "Modified: / 10-09-2021 / 15:58:15 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified (format): / 18-11-2021 / 12:44:06 / Jan Vrany <jan.vrany@labware.com>"
! !
!GDBRegisterWithValue methodsFor:'initialization'!
@@ -163,7 +170,8 @@
changes := frame registersChanges.
change := changes detect:[:each | each number = self number ] ifNone:[ nil ].
(change notNil and:[change value ~= valueString]) ifTrue:[
- valueString := change value.
+ valueString := change valueString.
+ value := nil.
true
] ifFalse:[
false
@@ -174,6 +182,7 @@
].
"Created: / 27-09-2018 / 15:11:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 18-11-2021 / 14:04:58 / Jan Vrany <jan.vrany@labware.com>"
!
setFrame: aGDBFrame