--- a/GDBVariableObject.st Mon Jun 04 14:34:44 2018 +0100
+++ b/GDBVariableObject.st Mon Jun 04 15:12:54 2018 +0100
@@ -25,7 +25,7 @@
GDBDebuggerObject subclass:#GDBVariableObject
instanceVariableNames:'parent name exp path thread frame value type numchild has_more
children changed inScope visualizer dynamic'
- classVariableNames:''
+ classVariableNames:'GdbDefaultVisualizer'
poolDictionaries:''
category:'GDB-Core'
!
@@ -53,6 +53,16 @@
"
! !
+!GDBVariableObject class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ GdbDefaultVisualizer := 'gdb.default_visualizer'
+
+ "Modified: / 04-06-2018 / 15:48:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!GDBVariableObject class methodsFor:'instance creation'!
new
@@ -153,6 +163,16 @@
"Created: / 28-01-2018 / 21:35:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+index
+ "Return the index of receiver within parent's children
+ or `nil` if receiver is not a child varobj."
+
+ parent isNil ifTrue:[ ^ nil ].
+ ^ parent children indexOf: self.
+
+ "Created: / 04-06-2018 / 15:01:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
parent
^ parent
!
@@ -297,11 +317,12 @@
^ 'None'
].
visualizer isNil ifTrue:[
- ^ 'gdb.default_visualizer' "/default visualizer
+ ^ GdbDefaultVisualizer
].
^ visualizer
"Created: / 13-02-2018 / 23:18:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-06-2018 / 15:48:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visualizer: aString
@@ -345,10 +366,34 @@
the same value. Other than that the returned duplicate is completely
independent"
- ^ debugger evaluate: self path in: self frame
+ | dup |
+
+ "/ For children of non-dynamic varobjs duplication is done
+ "/ by evaluating its "path" (a fully rooted expression) and
+ "/ returning the new varobj.
+ "/
+ "/ For children of **dynamic** varobjs, this is however more tricky.
+ "/ They have no "path". Thus, we first duplicate the parent and then
+ "/ return child of the just duplicated parent at corresponding index.
+ (self parent isNil or:[ self parent isDynamic not ]) ifTrue:[
+ "/ Easy, evaluate path expression...
+ dup := debugger evaluate: self path in: self frame
+ ] ifFalse:[
+ | dupParent |
+
+ dupParent := self parent duplicate.
+ dup := dupParent children at: self index.
+ ].
+ "/ Make sure the duplicate has the same visualizer
+ debugger isPrettyPrintingEnabled ifTrue:[
+ self visualizer ~= GdbDefaultVisualizer ifTrue:[
+ dup visualizer: self visualizer
+ ].
+ ].
+ ^ dup
"Created: / 13-02-2018 / 22:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 04-06-2018 / 14:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-06-2018 / 15:50:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBVariableObject methodsFor:'displaying'!
@@ -615,3 +660,5 @@
^ '$Changeset: <not expanded> $'
! !
+
+GDBVariableObject initialize!