xref: /freebsd-src/contrib/llvm-project/lldb/bindings/interface/SBValueDocstrings.i (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric %feature("docstring",
206c3fb27SDimitry Andric "Represents the value of a variable, a register, or an expression.
306c3fb27SDimitry Andric 
406c3fb27SDimitry Andric SBValue supports iteration through its child, which in turn is represented
506c3fb27SDimitry Andric as an SBValue.  For example, we can get the general purpose registers of a
606c3fb27SDimitry Andric frame as an SBValue, and iterate through all the registers,::
706c3fb27SDimitry Andric 
806c3fb27SDimitry Andric     registerSet = frame.registers # Returns an SBValueList.
906c3fb27SDimitry Andric     for regs in registerSet:
1006c3fb27SDimitry Andric         if 'general purpose registers' in regs.name.lower():
1106c3fb27SDimitry Andric             GPRs = regs
1206c3fb27SDimitry Andric             break
1306c3fb27SDimitry Andric 
1406c3fb27SDimitry Andric     print('%s (number of children = %d):' % (GPRs.name, GPRs.num_children))
1506c3fb27SDimitry Andric     for reg in GPRs:
1606c3fb27SDimitry Andric         print('Name: ', reg.name, ' Value: ', reg.value)
1706c3fb27SDimitry Andric 
1806c3fb27SDimitry Andric produces the output: ::
1906c3fb27SDimitry Andric 
2006c3fb27SDimitry Andric     General Purpose Registers (number of children = 21):
2106c3fb27SDimitry Andric     Name:  rax  Value:  0x0000000100000c5c
2206c3fb27SDimitry Andric     Name:  rbx  Value:  0x0000000000000000
2306c3fb27SDimitry Andric     Name:  rcx  Value:  0x00007fff5fbffec0
2406c3fb27SDimitry Andric     Name:  rdx  Value:  0x00007fff5fbffeb8
2506c3fb27SDimitry Andric     Name:  rdi  Value:  0x0000000000000001
2606c3fb27SDimitry Andric     Name:  rsi  Value:  0x00007fff5fbffea8
2706c3fb27SDimitry Andric     Name:  rbp  Value:  0x00007fff5fbffe80
2806c3fb27SDimitry Andric     Name:  rsp  Value:  0x00007fff5fbffe60
2906c3fb27SDimitry Andric     Name:  r8  Value:  0x0000000008668682
3006c3fb27SDimitry Andric     Name:  r9  Value:  0x0000000000000000
3106c3fb27SDimitry Andric     Name:  r10  Value:  0x0000000000001200
3206c3fb27SDimitry Andric     Name:  r11  Value:  0x0000000000000206
3306c3fb27SDimitry Andric     Name:  r12  Value:  0x0000000000000000
3406c3fb27SDimitry Andric     Name:  r13  Value:  0x0000000000000000
3506c3fb27SDimitry Andric     Name:  r14  Value:  0x0000000000000000
3606c3fb27SDimitry Andric     Name:  r15  Value:  0x0000000000000000
3706c3fb27SDimitry Andric     Name:  rip  Value:  0x0000000100000dae
3806c3fb27SDimitry Andric     Name:  rflags  Value:  0x0000000000000206
3906c3fb27SDimitry Andric     Name:  cs  Value:  0x0000000000000027
4006c3fb27SDimitry Andric     Name:  fs  Value:  0x0000000000000010
4106c3fb27SDimitry Andric     Name:  gs  Value:  0x0000000000000048
4206c3fb27SDimitry Andric 
4306c3fb27SDimitry Andric See also linked_list_iter() for another perspective on how to iterate through an
4406c3fb27SDimitry Andric SBValue instance which interprets the value object as representing the head of a
4506c3fb27SDimitry Andric linked list."
4606c3fb27SDimitry Andric ) lldb::SBValue;
4706c3fb27SDimitry Andric 
4806c3fb27SDimitry Andric %feature("docstring", "
4906c3fb27SDimitry Andric     Get a child value by index from a value.
5006c3fb27SDimitry Andric 
5106c3fb27SDimitry Andric     Structs, unions, classes, arrays and pointers have child
5206c3fb27SDimitry Andric     values that can be access by index.
5306c3fb27SDimitry Andric 
5406c3fb27SDimitry Andric     Structs and unions access child members using a zero based index
5506c3fb27SDimitry Andric     for each child member. For
5606c3fb27SDimitry Andric 
5706c3fb27SDimitry Andric     Classes reserve the first indexes for base classes that have
5806c3fb27SDimitry Andric     members (empty base classes are omitted), and all members of the
5906c3fb27SDimitry Andric     current class will then follow the base classes.
6006c3fb27SDimitry Andric 
6106c3fb27SDimitry Andric     Pointers differ depending on what they point to. If the pointer
6206c3fb27SDimitry Andric     points to a simple type, the child at index zero
6306c3fb27SDimitry Andric     is the only child value available, unless synthetic_allowed
6406c3fb27SDimitry Andric     is true, in which case the pointer will be used as an array
6506c3fb27SDimitry Andric     and can create 'synthetic' child values using positive or
6606c3fb27SDimitry Andric     negative indexes. If the pointer points to an aggregate type
6706c3fb27SDimitry Andric     (an array, class, union, struct), then the pointee is
6806c3fb27SDimitry Andric     transparently skipped and any children are going to be the indexes
6906c3fb27SDimitry Andric     of the child values within the aggregate type. For example if
7006c3fb27SDimitry Andric     we have a 'Point' type and we have a SBValue that contains a
7106c3fb27SDimitry Andric     pointer to a 'Point' type, then the child at index zero will be
7206c3fb27SDimitry Andric     the 'x' member, and the child at index 1 will be the 'y' member
7306c3fb27SDimitry Andric     (the child at index zero won't be a 'Point' instance).
7406c3fb27SDimitry Andric 
7506c3fb27SDimitry Andric     If you actually need an SBValue that represents the type pointed
7606c3fb27SDimitry Andric     to by a SBValue for which GetType().IsPointeeType() returns true,
7706c3fb27SDimitry Andric     regardless of the pointee type, you can do that with the SBValue.Dereference
7806c3fb27SDimitry Andric     method (or the equivalent deref property).
7906c3fb27SDimitry Andric 
8006c3fb27SDimitry Andric     Arrays have a preset number of children that can be accessed by
8106c3fb27SDimitry Andric     index and will returns invalid child values for indexes that are
8206c3fb27SDimitry Andric     out of bounds unless the synthetic_allowed is true. In this
8306c3fb27SDimitry Andric     case the array can create 'synthetic' child values for indexes
8406c3fb27SDimitry Andric     that aren't in the array bounds using positive or negative
8506c3fb27SDimitry Andric     indexes.
8606c3fb27SDimitry Andric 
8706c3fb27SDimitry Andric     @param[in] idx
8806c3fb27SDimitry Andric         The index of the child value to get
8906c3fb27SDimitry Andric 
9006c3fb27SDimitry Andric     @param[in] use_dynamic
9106c3fb27SDimitry Andric         An enumeration that specifies whether to get dynamic values,
9206c3fb27SDimitry Andric         and also if the target can be run to figure out the dynamic
9306c3fb27SDimitry Andric         type of the child value.
9406c3fb27SDimitry Andric 
9506c3fb27SDimitry Andric     @param[in] synthetic_allowed
9606c3fb27SDimitry Andric         If true, then allow child values to be created by index
9706c3fb27SDimitry Andric         for pointers and arrays for indexes that normally wouldn't
9806c3fb27SDimitry Andric         be allowed.
9906c3fb27SDimitry Andric 
10006c3fb27SDimitry Andric     @return
10106c3fb27SDimitry Andric         A new SBValue object that represents the child member value."
10206c3fb27SDimitry Andric ) lldb::SBValue::GetChildAtIndex;
10306c3fb27SDimitry Andric 
10406c3fb27SDimitry Andric %feature("docstring", "
10506c3fb27SDimitry Andric     Returns the child member index.
10606c3fb27SDimitry Andric 
10706c3fb27SDimitry Andric     Matches children of this object only and will match base classes and
10806c3fb27SDimitry Andric     member names if this is a clang typed object.
10906c3fb27SDimitry Andric 
11006c3fb27SDimitry Andric     @param[in] name
11106c3fb27SDimitry Andric         The name of the child value to get
11206c3fb27SDimitry Andric 
11306c3fb27SDimitry Andric     @return
11406c3fb27SDimitry Andric         An index to the child member value."
11506c3fb27SDimitry Andric ) lldb::SBValue::GetIndexOfChildWithName;
11606c3fb27SDimitry Andric 
11706c3fb27SDimitry Andric %feature("docstring", "
11806c3fb27SDimitry Andric     Returns the child member value.
11906c3fb27SDimitry Andric 
12006c3fb27SDimitry Andric     Matches child members of this object and child members of any base
12106c3fb27SDimitry Andric     classes.
12206c3fb27SDimitry Andric 
12306c3fb27SDimitry Andric     @param[in] name
12406c3fb27SDimitry Andric         The name of the child value to get
12506c3fb27SDimitry Andric 
12606c3fb27SDimitry Andric     @param[in] use_dynamic
12706c3fb27SDimitry Andric         An enumeration that specifies whether to get dynamic values,
12806c3fb27SDimitry Andric         and also if the target can be run to figure out the dynamic
12906c3fb27SDimitry Andric         type of the child value.
13006c3fb27SDimitry Andric 
13106c3fb27SDimitry Andric     @return
13206c3fb27SDimitry Andric         A new SBValue object that represents the child member value."
13306c3fb27SDimitry Andric ) lldb::SBValue::GetChildMemberWithName;
13406c3fb27SDimitry Andric 
13506c3fb27SDimitry Andric %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
13606c3fb27SDimitry Andric ) lldb::SBValue::GetValueForExpressionPath;
13706c3fb27SDimitry Andric 
138*0fca6ea1SDimitry Andric %feature("docstring", "
139*0fca6ea1SDimitry Andric       Return the value as an address.  On failure, LLDB_INVALID_ADDRESS
140*0fca6ea1SDimitry Andric       will be returned.  On architectures like AArch64, where the
141*0fca6ea1SDimitry Andric       top (unaddressable) bits can be used for authentication,
142*0fca6ea1SDimitry Andric       memory tagging, or top byte ignore,  this method will return
143*0fca6ea1SDimitry Andric       the value with those top bits cleared.
144*0fca6ea1SDimitry Andric 
145*0fca6ea1SDimitry Andric       GetValueAsUnsigned returns the actual value, with the
146*0fca6ea1SDimitry Andric       authentication/Top Byte Ignore/Memory Tagging Extension bits.
147*0fca6ea1SDimitry Andric 
148*0fca6ea1SDimitry Andric       Calling this on a random value which is not a pointer is
149*0fca6ea1SDimitry Andric       incorrect.  Call GetType().IsPointerType() if in doubt.
150*0fca6ea1SDimitry Andric 
151*0fca6ea1SDimitry Andric       An SB API program may want to show both the literal byte value
152*0fca6ea1SDimitry Andric       and the address it refers to in memory.  These two SBValue
153*0fca6ea1SDimitry Andric       methods allow SB API writers to behave appropriately for their
154*0fca6ea1SDimitry Andric       interface."
155*0fca6ea1SDimitry Andric ) lldb::SBValue::GetValueAsAddress;
156*0fca6ea1SDimitry Andric 
157*0fca6ea1SDimitry Andric 
15806c3fb27SDimitry Andric %feature("doctstring", "
15906c3fb27SDimitry Andric     Returns the number for children.
16006c3fb27SDimitry Andric 
16106c3fb27SDimitry Andric     @param[in] max
16206c3fb27SDimitry Andric         If max is less the lldb.UINT32_MAX, then the returned value is
16306c3fb27SDimitry Andric         capped to max.
16406c3fb27SDimitry Andric 
16506c3fb27SDimitry Andric     @return
16606c3fb27SDimitry Andric         An integer value capped to the argument max."
16706c3fb27SDimitry Andric ) lldb::SBValue::GetNumChildren;
16806c3fb27SDimitry Andric 
16906c3fb27SDimitry Andric %feature("docstring", "
17006c3fb27SDimitry Andric     Find and watch a variable.
17106c3fb27SDimitry Andric     It returns an SBWatchpoint, which may be invalid."
17206c3fb27SDimitry Andric ) lldb::SBValue::Watch;
17306c3fb27SDimitry Andric 
17406c3fb27SDimitry Andric %feature("docstring", "
17506c3fb27SDimitry Andric     Find and watch the location pointed to by a variable.
17606c3fb27SDimitry Andric     It returns an SBWatchpoint, which may be invalid."
17706c3fb27SDimitry Andric ) lldb::SBValue::WatchPointee;
17806c3fb27SDimitry Andric 
17906c3fb27SDimitry Andric %feature("docstring", "
18006c3fb27SDimitry Andric     Get an SBData wrapping what this SBValue points to.
18106c3fb27SDimitry Andric 
18206c3fb27SDimitry Andric     This method will dereference the current SBValue, if its
18306c3fb27SDimitry Andric     data type is a ``T\*`` or ``T[]``, and extract ``item_count`` elements
18406c3fb27SDimitry Andric     of type ``T`` from it, copying their contents in an :py:class:`SBData`.
18506c3fb27SDimitry Andric 
18606c3fb27SDimitry Andric     :param item_idx: The index of the first item to retrieve. For an array
18706c3fb27SDimitry Andric         this is equivalent to array[item_idx], for a pointer
18806c3fb27SDimitry Andric         to ``\*(pointer + item_idx)``. In either case, the measurement
18906c3fb27SDimitry Andric         unit for item_idx is the ``sizeof(T)`` rather than the byte
19006c3fb27SDimitry Andric     :param item_count: How many items should be copied into the output. By default
19106c3fb27SDimitry Andric         only one item is copied, but more can be asked for.
19206c3fb27SDimitry Andric     :return: The contents of the copied items on success. An empty :py:class:`SBData` otherwise.
19306c3fb27SDimitry Andric     :rtype: SBData
19406c3fb27SDimitry Andric     "
19506c3fb27SDimitry Andric ) lldb::SBValue::GetPointeeData;
19606c3fb27SDimitry Andric 
19706c3fb27SDimitry Andric %feature("docstring", "
19806c3fb27SDimitry Andric     Get an SBData wrapping the contents of this SBValue.
19906c3fb27SDimitry Andric 
20006c3fb27SDimitry Andric     This method will read the contents of this object in memory
20106c3fb27SDimitry Andric     and copy them into an SBData for future use.
20206c3fb27SDimitry Andric 
20306c3fb27SDimitry Andric     @return
20406c3fb27SDimitry Andric         An SBData with the contents of this SBValue, on success.
20506c3fb27SDimitry Andric         An empty SBData otherwise."
20606c3fb27SDimitry Andric ) lldb::SBValue::GetData;
20706c3fb27SDimitry Andric 
20806c3fb27SDimitry Andric %feature("docstring", "Returns an expression path for this value."
20906c3fb27SDimitry Andric ) lldb::SBValue::GetExpressionPath;
210