Variable objects: keep track of frame in which variable object has been created
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 13 Feb 2018 22:13:28 +0000
changeset 108 f34505ec6a7f
parent 107 7a315f1c9260
child 109 f57ce907abf4
Variable objects: keep track of frame in which variable object has been created
GDBMI_stack_info_frame.st
GDBVariable.st
GDBVariableObject.st
tests/GDBDebuggerTestsR.st
--- a/GDBMI_stack_info_frame.st	Mon Feb 05 21:45:22 2018 +0000
+++ b/GDBMI_stack_info_frame.st	Tue Feb 13 22:13:28 2018 +0000
@@ -98,3 +98,10 @@
     "Created: / 19-03-2015 / 08:29:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBMI_stack_info_frame class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/GDBVariable.st	Mon Feb 05 21:45:22 2018 +0000
+++ b/GDBVariable.st	Tue Feb 13 22:13:28 2018 +0000
@@ -106,14 +106,17 @@
         ].
 
         varobj := result value.
-        varobj setDebugger: debugger; setExpression: name.    
+        varobj 
+            setDebugger: debugger; 
+            setExpression: name;
+            setFrame: frame.
         varobj registerForFinalization.
     ].
     ^ varobj
 
     "Created: / 27-02-2015 / 17:18:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 15-01-2018 / 23:10:31 / jv"
-    "Modified: / 28-01-2018 / 23:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-02-2018 / 09:30:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBVariable methodsFor:'initialization'!
--- a/GDBVariableObject.st	Mon Feb 05 21:45:22 2018 +0000
+++ b/GDBVariableObject.st	Tue Feb 13 22:13:28 2018 +0000
@@ -127,6 +127,20 @@
     "Modified (comment): / 05-02-2018 / 21:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+frame
+    "If a variable object is bound to a specific thread and frame,
+     returns that frame (as `GDBFrame`). Otherwise, return `nil`."
+
+    parent notNil ifTrue:[ 
+        self assert: frame isNil.
+        ^ parent frame
+    ].
+    ^ frame.
+
+    "Created: / 13-02-2018 / 21:25:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-02-2018 / 09:30:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 id
     "Returns the GDB ID (name) of the variable object. This is
     used in commands to identify a variable object instance."
@@ -314,12 +328,25 @@
     "Created: / 28-01-2018 / 21:39:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+setFrame: aGDBBrame
+    frame := aGDBBrame
+
+    "Created: / 15-02-2018 / 09:29:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+setFrameId: aString
+    frame := aString
+
+    "Created: / 13-02-2018 / 21:24:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 setParent: variableObjectOrNil
     self assert: (variableObjectOrNil isNil or:[ variableObjectOrNil isKindOf: self class ]).
     self assert: debugger notNil.
+    parent := variableObjectOrNil
 
     "Created: / 27-01-2018 / 22:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-02-2018 / 09:29:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-02-2018 / 22:02:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 thread_id: anInteger
--- a/tests/GDBDebuggerTestsR.st	Mon Feb 05 21:45:22 2018 +0000
+++ b/tests/GDBDebuggerTestsR.st	Tue Feb 13 22:13:28 2018 +0000
@@ -403,7 +403,7 @@
 !
 
 test_variables_01
-    | variables d |
+    | thread frame variables d |
 
     debugger := GDBDebugger new.
     debugger executable: GDBDebuggeesResource current binaryVariables.
@@ -412,11 +412,15 @@
     debugger send: 'r' andWaitFor: GDBStoppedEvent.
     debugger send: 's' andWaitFor: GDBStoppedEvent.
 
-    variables := debugger selectedInferior threads first stack first variables.
+    thread := debugger selectedInferior threads first.
+    frame := thread stack first.
+    variables :=  frame variables.
 
     self assert: variables size = 3. "/ argc, argv, d.
     self assert: variables first name = 'argc'.
     self assert: variables first varobj expression = 'argc'.
+    self assert: variables first varobj thread == thread.
+    self assert: variables first varobj frame == frame.
 
     self assert: variables second name = 'argv'.
     self assert: variables second varobj expression = 'argv'.
@@ -428,10 +432,14 @@
     self assert: d hasChildren.
     self assert: d children size = 3.
 
+    self assert: d children first parent == d.
     self assert: d children first hasChildren not.
     self assert: d children first children = #().
     self assert: d children first expression = 'i'.
     self assert: d children first value = '1'.
+    self assert: d children first thread == thread.
+    self assert: d children first frame == frame.
+    
 
     self assert: d children third hasChildren.
     self assert: d children third children size = 2.
@@ -449,8 +457,7 @@
     debugger send: 'quit' andWait: false.
 
     "Created: / 30-01-2018 / 10:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-
-
+    "Modified: / 13-02-2018 / 22:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 test_variables_02