GDBVariableObject.st
changeset 107 7a315f1c9260
parent 106 12c96f17fc53
child 108 f34505ec6a7f
--- a/GDBVariableObject.st	Sun Feb 04 23:37:35 2018 +0000
+++ b/GDBVariableObject.st	Mon Feb 05 21:45:22 2018 +0000
@@ -21,7 +21,7 @@
 "{ NameSpace: Smalltalk }"
 
 GDBDebuggerObject subclass:#GDBVariableObject
-	instanceVariableNames:'parent name exp thread frame value type numchild has_more
+	instanceVariableNames:'parent name exp path thread frame value type numchild has_more
 		children changed inScope'
 	classVariableNames:''
 	poolDictionaries:''
@@ -100,11 +100,31 @@
 
 expression
     "Return the expression in target language to access the value (asDtring)
-     The expression is relative to it's direct parent (if any),"
+     The expression is relative to it's direct parent (if any),
+
+     For example, consider
+
+         typedef struct _point {
+            int x;
+            int y;
+         } point;
+         ...
+         point p1 = { 10, 20 };
+
+     and consider a variable object `o` that represents `y` member of point 
+     `p1`. Then:
+
+        o path '/ -> 'p1.y'
+
+    while
+
+        p expression '/ -> 'y'
+    "
 
     ^ exp
 
     "Created: / 28-01-2018 / 21:36:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 05-02-2018 / 21:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 id
@@ -116,6 +136,44 @@
     "Created: / 28-01-2018 / 21:35:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+parent
+    ^ parent
+!
+
+path
+    "Return (absolute) expression in target language to access the value 
+     (asDtring).
+
+     For example, consider
+
+         typedef struct _point {
+            int x;
+            int y;
+         } point;
+         ...
+         point p1 = { 10, 20 };
+
+     and consider a variable object `o` that represents `y` member of point 
+     `p1`. Then:
+
+        o path '/ -> 'p1.y'
+
+    while
+
+        p expression '/ -> 'y'
+
+    "
+    path isNil ifTrue:[ 
+        | result |
+
+        result := debugger send: (GDBMI_var_info_path_expression arguments: (Array with: name)).
+        path := result propertyAt: #'path_expr'.
+    ].
+    ^ path
+
+    "Created: / 05-02-2018 / 21:16:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 thread
     "
     If a variable object is bound to a specific thread, returns