GDBVariable.st
changeset 178 71baafd9bbcb
parent 177 e7bd05df3d6b
child 201 d7057fccacfd
--- a/GDBVariable.st	Mon Feb 25 17:55:20 2019 +0000
+++ b/GDBVariable.st	Tue Feb 26 09:27:50 2019 +0000
@@ -110,13 +110,29 @@
 !
 
 value
+    "Retun an up-to-date pretty-printed string representation of this variable's value."
+
     | vobj |
 
+    "/ The code below tries to avoid creating an varobj if 
+    "/ possible since creation of varobj might be costly.
+    "/ 
+    "/ THerefore we check whether `value` instvar (cached
+    "/ string representation) is not nil and varobj is nil
+    "/ (i.e., has not yet been created). If so, return
+    "/ cached `value` without creating varobj. Otherwise,
+    "/ create varobj and ask it for a value.
+
+    varobj == VarobjUnavailable ifTrue:[ ^ value ].
+    (varobj isNil and: [value notNil])  ifTrue:[ ^ value ].
+
     vobj := self varobj.
-    ^ vobj notNil ifTrue:[ vobj value ] ifFalse: [ value ].
+    vobj notNil ifTrue:[ ^ vobj value ].
+
+    ^ self class classResources string:'<could not read value>'
 
     "Created: / 27-02-2015 / 23:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 05-07-2018 / 12:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-02-2019 / 16:58:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 visualizer: aString