GDBVariableObject.st
changeset 122 c939f8a4c3cd
parent 112 a8138ced2f5e
child 123 1e2c548b0cde
equal deleted inserted replaced
121:c99479329a46 122:c939f8a4c3cd
    22 
    22 
    23 "{ NameSpace: Smalltalk }"
    23 "{ NameSpace: Smalltalk }"
    24 
    24 
    25 GDBDebuggerObject subclass:#GDBVariableObject
    25 GDBDebuggerObject subclass:#GDBVariableObject
    26 	instanceVariableNames:'parent name exp path thread frame value type numchild has_more
    26 	instanceVariableNames:'parent name exp path thread frame value type numchild has_more
    27 		children changed inScope visualizer'
    27 		children changed inScope visualizer dynamic'
    28 	classVariableNames:''
    28 	classVariableNames:''
    29 	poolDictionaries:''
    29 	poolDictionaries:''
    30 	category:'GDB-Core'
    30 	category:'GDB-Core'
    31 !
    31 !
    32 
    32 
    82 !GDBVariableObject methodsFor:'accessing'!
    82 !GDBVariableObject methodsFor:'accessing'!
    83 
    83 
    84 children
    84 children
    85     self isValid ifFalse:[ ^ #() ].
    85     self isValid ifFalse:[ ^ #() ].
    86     children isNil ifTrue:[ 
    86     children isNil ifTrue:[ 
    87         (self isValid and:[numchild isNil or:[numchild > 0]]) ifTrue:[
    87         (self isValid and:[has_more or:[ numchild isNil or:[numchild > 0]]]) ifTrue:[
    88             | result |
    88             | result |
    89 
    89 
    90             result := debugger send: (GDBMI_var_list_children arguments: (Array with: '--all-values' with: name)).
    90             result := debugger send: (GDBMI_var_list_children arguments: (Array with: '--all-values' with: name)).
    91             children := result propertyAt: #children.   
    91             children := (result propertyAt: #children) ? #().
    92             children do:[:each | each setDebugger: debugger; setParent: self ].
    92             children do:[:each | each setDebugger: debugger; setParent: self ].
    93             numchild := children size.
    93             numchild := children size.
    94         ] ifFalse:[ 
    94         ] ifFalse:[ 
    95             children := #().
    95             children := #().
    96         ].
    96         ].
    97     ].
    97     ].
    98     ^ children
    98     ^ children
    99 
    99 
   100     "Created: / 27-01-2018 / 22:53:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   100     "Created: / 27-01-2018 / 22:53:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   101     "Modified: / 19-02-2018 / 15:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   101     "Modified: / 04-06-2018 / 10:57:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   102 !
   102 !
   103 
   103 
   104 expression
   104 expression
   105     "Return the expression in target language to access the value (asDtring)
   105     "Return the expression in target language to access the value (asDtring)
   106      The expression is relative to it's direct parent (if any),
   106      The expression is relative to it's direct parent (if any),
   178     while
   178     while
   179 
   179 
   180         p expression '/ -> 'y'
   180         p expression '/ -> 'y'
   181 
   181 
   182     "
   182     "
       
   183 
       
   184     "/ Raise an error early when #path is requested for a child of dynamic
       
   185     "/ varobj. Thie is not supported by GDB.
       
   186     "/ 
       
   187     "/ Although GDB should report an error [1], dur to a bug it report
       
   188     "/ either wrong (nonsense) value or crashes. A patch has been send
       
   189     "/ to the upstream [2], but meanwhile, check here as well in case someone
       
   190     "/ uses this with older / not yet patches version of GDB.
       
   191     "/ 
       
   192     "/ [1]: https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
       
   193     "/ [2]: https://sourceware.org/ml/gdb-patches/2018-06/msg00058.html
       
   194     "/ 
       
   195     (parent notNil and:[parent isDynamic]) ifTrue:[ 
       
   196         GDBError raiseErrorString: 'Invalid varobj, #path is not supported for children of a dynamic varobjs'.
       
   197         ^ self
       
   198     ].
       
   199 
   183     path isNil ifTrue:[ 
   200     path isNil ifTrue:[ 
   184         | result |
   201         | result |
   185 
   202 
   186         result := debugger send: (GDBMI_var_info_path_expression arguments: (Array with: name)).
   203         result := debugger send: (GDBMI_var_info_path_expression arguments: (Array with: name)).
   187         path := result propertyAt: #'path_expr'.
   204         path := result propertyAt: #'path_expr'.
   188     ].
   205     ].
   189     ^ path
   206     ^ path
   190 
   207 
   191     "Created: / 05-02-2018 / 21:16:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   208     "Created: / 05-02-2018 / 21:16:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   209     "Modified: / 01-06-2018 / 16:31:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   210     "Modified (comment): / 04-06-2018 / 14:19:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   192 !
   211 !
   193 
   212 
   194 thread
   213 thread
   195     "
   214     "
   196     If a variable object is bound to a specific thread, returns
   215     If a variable object is bound to a specific thread, returns
   321 
   340 
   322 !GDBVariableObject methodsFor:'copying'!
   341 !GDBVariableObject methodsFor:'copying'!
   323 
   342 
   324 duplicate
   343 duplicate
   325     "Create and returns a duplicate of the receiver, representing
   344     "Create and returns a duplicate of the receiver, representing
   326      the same value. Other than thatm the eturned duplicate is completely 
   345      the same value. Other than that the returned duplicate is completely 
   327      independent"
   346      independent"
       
   347 
   328     ^ debugger evaluate: self path in: self frame
   348     ^ debugger evaluate: self path in: self frame
   329 
   349 
   330     "Created: / 13-02-2018 / 22:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   350     "Created: / 13-02-2018 / 22:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   351     "Modified (format): / 04-06-2018 / 14:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   331 ! !
   352 ! !
   332 
   353 
   333 !GDBVariableObject methodsFor:'displaying'!
   354 !GDBVariableObject methodsFor:'displaying'!
   334 
   355 
   335 displayOn: aStream
   356 displayOn: aStream
   378 initialize
   399 initialize
   379     "Invoked when a new instance is created."
   400     "Invoked when a new instance is created."
   380 
   401 
   381     super initialize.
   402     super initialize.
   382     inScope := true.
   403     inScope := true.
   383 
   404     dynamic := false.
   384     "Modified: / 13-02-2018 / 23:51:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   405     has_more := true.
       
   406 
       
   407     "Modified: / 04-06-2018 / 10:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   385 !
   408 !
   386 
   409 
   387 release
   410 release
   388     "Releases the variable object and all its children. Once released, 
   411     "Releases the variable object and all its children. Once released, 
   389      the variable object is invalid (i.e., `#isValid` would return `false`) 
   412      the variable object is invalid (i.e., `#isValid` would return `false`) 
   510 inScope
   533 inScope
   511    changed value. "/ to force update if necessary
   534    changed value. "/ to force update if necessary
   512     ^ inScope
   535     ^ inScope
   513 
   536 
   514     "Created: / 12-02-2018 / 21:56:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   537     "Created: / 12-02-2018 / 21:56:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   538 !
       
   539 
       
   540 isDynamic
       
   541     "Return true, if this varobj is a dynamic varobj, false otherwise"
       
   542 
       
   543     ^ dynamic
       
   544 
       
   545     "Created: / 01-06-2018 / 16:29:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   515 !
   546 !
   516 
   547 
   517 isValid
   548 isValid
   518     changed value. "/ to force update if necessary
   549     changed value. "/ to force update if necessary
   519     ^ debugger notNil
   550     ^ debugger notNil