1 STRING_EXTENSION_OUTSIDE
(SBValue
)
2 %extend lldb
::SBValue
{
5 def __get_dynamic__
(self
):
6 '''Helper function for the
"SBValue.dynamic" property.'''
7 return self.GetDynamicValue
(eDynamicCanRunTarget
)
9 class children_access
(object
):
10 '''A helper object that will lazily hand out thread for a process when supplied an index.'''
12 def __init__
(self
, sbvalue
):
13 self.sbvalue
= sbvalue
17 return int
(self.sbvalue.GetNumChildren
())
20 def __getitem__
(self
, key
):
21 if isinstance
(key
, int
):
23 if
-count
<= key
< count
:
25 return self.sbvalue.GetChildAtIndex
(key
)
28 def get_child_access_object
(self
):
29 '''An accessor function that returns a children_access
() object which allows lazy member variable access from a lldb.SBValue object.'''
30 return self.children_access
(self
)
32 def get_value_child_list
(self
):
33 '''An accessor function that returns a list
() that contains all children in a lldb.SBValue object.'''
35 accessor
= self.get_child_access_object
()
36 for idx in range
(len
(accessor
)):
37 children.append
(accessor
[idx
])
41 return self.GetAddress
()
44 '''Iterate over all child values of a lldb.SBValue object.'''
45 return lldb_iter
(self
, 'GetNumChildren'
, 'GetChildAtIndex'
)
48 '''Return the number of child values of a lldb.SBValue object.'''
49 return self.GetNumChildren
()
51 children
= property
(get_value_child_list
, None
, doc
='''A read only property that returns a list
() of lldb.SBValue objects for the children of the value.'''
)
52 child
= property
(get_child_access_object
, None
, doc
='''A read only property that returns an object that can access children of a variable by index
(child_value
= value.children
[12]).'''
)
53 name
= property
(GetName
, None
, doc
='''A read only property that returns the name of this value as a string.'''
)
54 type
= property
(GetType
, None
, doc
='''A read only property that returns a lldb.SBType object that represents the type for this value.'''
)
55 size
= property
(GetByteSize
, None
, doc
='''A read only property that returns the size in bytes of this value.'''
)
56 is_in_scope
= property
(IsInScope
, None
, doc
='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.'''
)
57 format
= property
(GetName
, SetFormat
, doc
='''A read
/write property that gets
/sets the format used for lldb.SBValue
().GetValue
() for this value. See enumerations that start with
"lldb.eFormat".'''
)
58 value
= property
(GetValue
, SetValueFromCString
, doc
='''A read
/write property that gets
/sets value from a string.'''
)
59 value_type
= property
(GetValueType
, None
, doc
='''A read only property that returns an lldb enumeration value
(see enumerations that start with
"lldb.eValueType") that represents the type of this value
(local
, argument
, global
, register
, etc.
).'''
)
60 changed
= property
(GetValueDidChange
, None
, doc
='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.'''
)
61 data
= property
(GetData
, None
, doc
='''A read only property that returns an lldb object
(lldb.SBData
) that represents the bytes that make up the value for this object.'''
)
62 load_addr
= property
(GetLoadAddress
, None
, doc
='''A read only property that returns the load address of this value as an integer.'''
)
63 addr
= property
(GetAddress
, None
, doc
='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.'''
)
64 deref
= property
(Dereference
, None
, doc
='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.'''
)
65 address_of
= property
(AddressOf
, None
, doc
='''A read only property that returns an lldb.SBValue that represents the address-of this value.'''
)
66 error
= property
(GetError
, None
, doc
='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.'''
)
67 summary
= property
(GetSummary
, None
, doc
='''A read only property that returns the summary for this value as a string'''
)
68 description
= property
(GetObjectDescription
, None
, doc
='''A read only property that returns the language-specific description of this value as a string'''
)
69 dynamic
= property
(__get_dynamic__
, None
, doc
='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.'''
)
70 location
= property
(GetLocation
, None
, doc
='''A read only property that returns the location of this value as a string.'''
)
71 target
= property
(GetTarget
, None
, doc
='''A read only property that returns the lldb.SBTarget that this value is associated with.'''
)
72 process
= property
(GetProcess
, None
, doc
='''A read only property that returns the lldb.SBProcess that this value is associated with
, the returned value might be invalid and should be tested.'''
)
73 thread
= property
(GetThread
, None
, doc
='''A read only property that returns the lldb.SBThread that this value is associated with
, the returned value might be invalid and should be tested.'''
)
74 frame
= property
(GetFrame
, None
, doc
='''A read only property that returns the lldb.SBFrame that this value is associated with
, the returned value might be invalid and should be tested.'''
)
75 num_children
= property
(GetNumChildren
, None
, doc
='''A read only property that returns the number of child lldb.SBValues that this value has.'''
)
76 unsigned
= property
(GetValueAsUnsigned
, None
, doc
='''A read only property that returns the value of this SBValue as an usigned integer.'''
)
77 signed
= property
(GetValueAsSigned
, None
, doc
='''A read only property that returns the value of this SBValue as a signed integer.'''
)
79 def get_expr_path
(self
):
81 self.GetExpressionPath
(s
)
84 path
= property
(get_expr_path
, None
, doc
='''A read only property that returns the expression path that one can use to reach this value in an expression.'''
)
86 def synthetic_child_from_expression
(self
, name
, expr
, options
=None
):
87 if options is None
: options
= lldb.SBExpressionOptions
()
88 child
= self.CreateValueFromExpression
(name
, expr
, options
)
89 child.SetSyntheticChildrenGenerated
(True
)
92 def synthetic_child_from_data
(self
, name
, data
, type
):
93 child
= self.CreateValueFromData
(name
, data
, type
)
94 child.SetSyntheticChildrenGenerated
(True
)
97 def synthetic_child_from_address
(self
, name
, addr
, type
):
98 child
= self.CreateValueFromAddress
(name
, addr
, type
)
99 child.SetSyntheticChildrenGenerated
(True
)
103 """Default function for end of list test takes an SBValue object.
105 Return True if val is invalid or it corresponds to a null pointer.
106 Otherwise, return False.
108 if not val or val.GetValueAsUnsigned
() == 0:
113 #
==================================================
114 # Iterator for lldb.SBValue treated as a linked list
115 #
==================================================
116 def linked_list_iter
(self
, next_item_name
, end_of_list_test
=__eol_test
):
117 """Generator adaptor to support iteration for SBValue as a linked list.
119 linked_list_iter() is a special purpose iterator to treat the SBValue as
120 the head of a list data structure, where you specify the child member
121 name which points to the next item on the list and you specify the
122 end-of-list test function which takes an SBValue for an item and returns
123 True if EOL is reached and False if not.
125 linked_list_iter() also detects infinite loop and bails out early.
127 The end_of_list_test arg, if omitted, defaults to the __eol_test
135 # Get variable 'task_head'.
136 task_head = frame0.FindVariable('task_head')
139 for t in task_head.linked_list_iter('next'):
142 if end_of_list_test
(self
):
147 while not end_of_list_test
(item
) and not item.GetValueAsUnsigned
() in visited
:
148 visited.add
(item.GetValueAsUnsigned
())
150 # Prepare for the next iteration.
151 item
= item.GetChildMemberWithName
(next_item_name
)
153 # Exception occurred. Stop the generator.