SBValue#

class lldb.SBValue(*args)#

Represents the value of a variable, a register, or an expression.

SBValue supports iteration through its child, which in turn is represented as an SBValue. For example, we can get the general purpose registers of a frame as an SBValue, and iterate through all the registers,:

registerSet = frame.registers # Returns an SBValueList.
for regs in registerSet:
    if 'general purpose registers' in regs.name.lower():
        GPRs = regs
        break

print('%s (number of children = %d):' % (GPRs.name, GPRs.num_children))
for reg in GPRs:
    print('Name: ', reg.name, ' Value: ', reg.value)

produces the output:

General Purpose Registers (number of children = 21):
Name:  rax  Value:  0x0000000100000c5c
Name:  rbx  Value:  0x0000000000000000
Name:  rcx  Value:  0x00007fff5fbffec0
Name:  rdx  Value:  0x00007fff5fbffeb8
Name:  rdi  Value:  0x0000000000000001
Name:  rsi  Value:  0x00007fff5fbffea8
Name:  rbp  Value:  0x00007fff5fbffe80
Name:  rsp  Value:  0x00007fff5fbffe60
Name:  r8  Value:  0x0000000008668682
Name:  r9  Value:  0x0000000000000000
Name:  r10  Value:  0x0000000000001200
Name:  r11  Value:  0x0000000000000206
Name:  r12  Value:  0x0000000000000000
Name:  r13  Value:  0x0000000000000000
Name:  r14  Value:  0x0000000000000000
Name:  r15  Value:  0x0000000000000000
Name:  rip  Value:  0x0000000100000dae
Name:  rflags  Value:  0x0000000000000206
Name:  cs  Value:  0x0000000000000027
Name:  fs  Value:  0x0000000000000010
Name:  gs  Value:  0x0000000000000048

See also linked_list_iter() for another perspective on how to iterate through an SBValue instance which interprets the value object as representing the head of a linked list.

Attributes Summary

addr

A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.

address_of

A read only property that returns an lldb.SBValue that represents the address-of this value.

changed

A read only property that returns a boolean value that indicates if this value has changed since it was last updated.

child

A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).

children

A read only property that returns a list() of lldb.SBValue objects for the children of the value.

data

A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.

deref

A read only property that returns an lldb.SBValue that is created by dereferencing this value.

description

A read only property that returns the language-specific description of this value as a string

dynamic

A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.

error

A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.

format

A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value.

frame

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.

is_in_scope

A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.

load_addr

A read only property that returns the load address of this value as an integer.

location

A read only property that returns the location of this value as a string.

name

A read only property that returns the name of this value as a string.

num_children

A read only property that returns the number of child lldb.SBValues that this value has.

path

A read only property that returns the expression path that one can use to reach this value in an expression.

process

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.

signed

A read only property that returns the value of this SBValue as a signed integer.

size

A read only property that returns the size in bytes of this value.

summary

A read only property that returns the summary for this value as a string

target

A read only property that returns the lldb.SBTarget that this value is associated with.

thread

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.

type

A read only property that returns a lldb.SBType object that represents the type for this value.

unsigned

A read only property that returns the value of this SBValue as an usigned integer.

value

A read/write property that gets/sets value from a string.

value_type

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.).

Methods Summary

AddressOf(SBValue self)

Cast(SBValue self, SBType type)

Clear(SBValue self)

Clone(SBValue self, char const * new_name)

CreateChildAtOffset(SBValue self, ...)

CreateValueFromAddress(SBValue self, ...)

CreateValueFromData(SBValue self, ...)

CreateValueFromExpression(-> SBValue)

Dereference(SBValue self)

EvaluateExpression(-> SBValue -> SBValue)

GetAddress(SBValue self)

GetByteSize(SBValue self)

GetChildAtIndex(-> SBValue)

Get a child value by index from a value.

GetChildMemberWithName(-> SBValue)

Returns the child member value.

GetData(SBValue self)

Get an SBData wrapping the contents of this SBValue.

GetDeclaration(SBValue self)

GetDescription(SBValue self, ...)

GetDisplayTypeName(SBValue self)

GetDynamicValue(SBValue self, lldb)

GetError(SBValue self)

GetExpressionPath(-> bool)

Returns an expression path for this value.

GetFormat(SBValue self)

GetFrame(SBValue self)

GetID(SBValue self)

GetIndexOfChildWithName(SBValue self, ...)

Returns the child member index.

GetLoadAddress(SBValue self)

GetLocation(SBValue self)

GetName(SBValue self)

GetNonSyntheticValue(SBValue self)

GetNumChildren(-> uint32_t)

GetObjectDescription(SBValue self)

GetOpaqueType(SBValue self)

GetPointeeData(SBValue self, ...)

Get an SBData wrapping what this SBValue points to.

GetPreferDynamicValue(SBValue self)

GetPreferSyntheticValue(SBValue self)

GetProcess(SBValue self)

GetStaticValue(SBValue self)

GetSummary(-> char const)

GetTarget(SBValue self)

GetThread(SBValue self)

GetType(SBValue self)

GetTypeFilter(SBValue self)

GetTypeFormat(SBValue self)

GetTypeName(SBValue self)

GetTypeSummary(SBValue self)

GetTypeSynthetic(SBValue self)

GetVTable(SBValue self)

GetValue(SBValue self)

GetValueAsSigned(-> int64_t)

GetValueAsUnsigned(-> uint64_t)

GetValueDidChange(SBValue self)

GetValueForExpressionPath(SBValue self, ...)

Expands nested expressions like .a->b[0].c[1]->d.

GetValueType(SBValue self)

IsDynamic(SBValue self)

IsInScope(SBValue self)

IsRuntimeSupportValue(SBValue self)

IsSynthetic(SBValue self)

IsSyntheticChildrenGenerated(SBValue self)

IsValid(SBValue self)

MightHaveChildren(SBValue self)

Persist(SBValue self)

SetData(SBValue self, SBData data, SBError error)

SetFormat(SBValue self, lldb)

SetPreferDynamicValue(SBValue self, lldb)

SetPreferSyntheticValue(SBValue self, ...)

SetSyntheticChildrenGenerated(SBValue self, ...)

SetValueFromCString(-> bool)

TypeIsPointerType(SBValue self)

Watch(-> SBWatchpoint)

Find and watch a variable.

WatchPointee(SBValue self, ...)

Find and watch the location pointed to by a variable.

get_child_access_object()

An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.

get_expr_path()

get_value_child_list()

An accessor function that returns a list() that contains all children in a lldb.SBValue object.

linked_list_iter(next_item_name[, ...])

Generator adaptor to support iteration for SBValue as a linked list.

synthetic_child_from_address(name, addr, type)

synthetic_child_from_data(name, data, type)

synthetic_child_from_expression(name, expr)

Attributes Documentation

addr#

A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.

address_of#

A read only property that returns an lldb.SBValue that represents the address-of this value.

changed#

A read only property that returns a boolean value that indicates if this value has changed since it was last updated.

child#

A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).

children#

A read only property that returns a list() of lldb.SBValue objects for the children of the value.

data#

A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.

deref#

A read only property that returns an lldb.SBValue that is created by dereferencing this value.

description#

A read only property that returns the language-specific description of this value as a string

dynamic#

A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.

error#

A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.

format#

A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with “lldb.eFormat”.

frame#

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.

is_in_scope#

A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.

load_addr#

A read only property that returns the load address of this value as an integer.

location#

A read only property that returns the location of this value as a string.

name#

A read only property that returns the name of this value as a string.

num_children#

A read only property that returns the number of child lldb.SBValues that this value has.

path#

A read only property that returns the expression path that one can use to reach this value in an expression.

process#

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.

signed#

A read only property that returns the value of this SBValue as a signed integer.

size#

A read only property that returns the size in bytes of this value.

summary#

A read only property that returns the summary for this value as a string

target#

A read only property that returns the lldb.SBTarget that this value is associated with.

thread#

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.

type#

A read only property that returns a lldb.SBType object that represents the type for this value.

unsigned#

A read only property that returns the value of this SBValue as an usigned integer.

value#

A read/write property that gets/sets value from a string.

value_type#

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.).

Methods Documentation

AddressOf(SBValue self) SBValue#
Cast(SBValue self, SBType type) SBValue#
Clear(SBValue self)#
Clone(SBValue self, char const * new_name) SBValue#
CreateChildAtOffset(SBValue self, char const * name, uint32_t offset, SBType type) SBValue#
CreateValueFromAddress(SBValue self, char const * name, lldb::addr_t address, SBType type) SBValue#
CreateValueFromData(SBValue self, char const * name, SBData data, SBType type) SBValue#
CreateValueFromExpression(SBValue self, char const * name, char const * expression) SBValue#
CreateValueFromExpression(SBValue self, char const * name, char const * expression, SBExpressionOptions options) SBValue
Dereference(SBValue self) SBValue#
EvaluateExpression(SBValue self, char const * expr) SBValue#
EvaluateExpression(SBValue self, char const * expr, SBExpressionOptions options) SBValue
EvaluateExpression(SBValue self, char const * expr, SBExpressionOptions options, char const * name) SBValue
GetAddress(SBValue self) SBAddress#
GetByteSize(SBValue self) size_t#
GetChildAtIndex(SBValue self, uint32_t idx) SBValue#
GetChildAtIndex(SBValue self, uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic) SBValue

Get a child value by index from a value.

Structs, unions, classes, arrays and pointers have child values that can be access by index.

Structs and unions access child members using a zero based index for each child member. For

Classes reserve the first indexes for base classes that have members (empty base classes are omitted), and all members of the current class will then follow the base classes.

Pointers differ depending on what they point to. If the pointer points to a simple type, the child at index zero is the only child value available, unless synthetic_allowed is true, in which case the pointer will be used as an array and can create ‘synthetic’ child values using positive or negative indexes. If the pointer points to an aggregate type (an array, class, union, struct), then the pointee is transparently skipped and any children are going to be the indexes of the child values within the aggregate type. For example if we have a ‘Point’ type and we have a SBValue that contains a pointer to a ‘Point’ type, then the child at index zero will be the ‘x’ member, and the child at index 1 will be the ‘y’ member (the child at index zero won’t be a ‘Point’ instance).

If you actually need an SBValue that represents the type pointed to by a SBValue for which GetType().IsPointeeType() returns true, regardless of the pointee type, you can do that with the SBValue.Dereference method (or the equivalent deref property).

Arrays have a preset number of children that can be accessed by index and will returns invalid child values for indexes that are out of bounds unless the synthetic_allowed is true. In this case the array can create ‘synthetic’ child values for indexes that aren’t in the array bounds using positive or negative indexes.

@param[in] idx

The index of the child value to get

@param[in] use_dynamic

An enumeration that specifies whether to get dynamic values, and also if the target can be run to figure out the dynamic type of the child value.

@param[in] synthetic_allowed

If true, then allow child values to be created by index for pointers and arrays for indexes that normally wouldn’t be allowed.

@return

A new SBValue object that represents the child member value.

GetChildMemberWithName(SBValue self, char const * name) SBValue#
GetChildMemberWithName(SBValue self, char const * name, lldb::DynamicValueType use_dynamic) SBValue

Returns the child member value.

Matches child members of this object and child members of any base classes.

@param[in] name

The name of the child value to get

@param[in] use_dynamic

An enumeration that specifies whether to get dynamic values, and also if the target can be run to figure out the dynamic type of the child value.

@return

A new SBValue object that represents the child member value.

GetData(SBValue self) SBData#

Get an SBData wrapping the contents of this SBValue.

This method will read the contents of this object in memory and copy them into an SBData for future use.

@return

An SBData with the contents of this SBValue, on success. An empty SBData otherwise.

GetDeclaration(SBValue self) SBDeclaration#
GetDescription(SBValue self, SBStream description) bool#
GetDisplayTypeName(SBValue self) char const *#
GetDynamicValue(SBValue self, lldb::DynamicValueType use_dynamic) SBValue#
GetError(SBValue self) SBError#
GetExpressionPath(SBValue self, SBStream description) bool#
GetExpressionPath(SBValue self, SBStream description, bool qualify_cxx_base_classes) bool

Returns an expression path for this value.

GetFormat(SBValue self) lldb::Format#
GetFrame(SBValue self) SBFrame#
GetID(SBValue self) lldb::user_id_t#
GetIndexOfChildWithName(SBValue self, char const * name) uint32_t#

Returns the child member index.

Matches children of this object only and will match base classes and member names if this is a clang typed object.

@param[in] name

The name of the child value to get

@return

An index to the child member value.

GetLoadAddress(SBValue self) lldb::addr_t#
GetLocation(SBValue self) char const *#
GetName(SBValue self) char const *#
GetNonSyntheticValue(SBValue self) SBValue#
GetNumChildren(SBValue self) uint32_t#
GetNumChildren(SBValue self, uint32_t max) uint32_t
GetObjectDescription(SBValue self) char const *#
GetOpaqueType(SBValue self) void *#
GetPointeeData(SBValue self, uint32_t item_idx=0, uint32_t item_count=1) SBData#

Get an SBData wrapping what this SBValue points to.

This method will dereference the current SBValue, if its data type is a T\* or T[], and extract item_count elements of type T from it, copying their contents in an SBData.

Parameters:
  • item_idx – The index of the first item to retrieve. For an array this is equivalent to array[item_idx], for a pointer to \*(pointer + item_idx). In either case, the measurement unit for item_idx is the sizeof(T) rather than the byte

  • item_count – How many items should be copied into the output. By default only one item is copied, but more can be asked for.

Returns:

The contents of the copied items on success. An empty SBData otherwise.

Return type:

SBData

GetPreferDynamicValue(SBValue self) lldb::DynamicValueType#
GetPreferSyntheticValue(SBValue self) bool#
GetProcess(SBValue self) SBProcess#
GetStaticValue(SBValue self) SBValue#
GetSummary(SBValue self) char const#
GetSummary(SBValue self, SBStream stream, SBTypeSummaryOptions options) char const *
GetTarget(SBValue self) SBTarget#
GetThread(SBValue self) SBThread#
GetType(SBValue self) SBType#
GetTypeFilter(SBValue self) SBTypeFilter#
GetTypeFormat(SBValue self) SBTypeFormat#
GetTypeName(SBValue self) char const *#
GetTypeSummary(SBValue self) SBTypeSummary#
GetTypeSynthetic(SBValue self) SBTypeSynthetic#
GetVTable(SBValue self) SBValue#
GetValue(SBValue self) char const *#
GetValueAsSigned(SBValue self, SBError error, int64_t fail_value=0) int64_t#
GetValueAsSigned(SBValue self, int64_t fail_value=0) int64_t
GetValueAsUnsigned(SBValue self, SBError error, uint64_t fail_value=0) uint64_t#
GetValueAsUnsigned(SBValue self, uint64_t fail_value=0) uint64_t
GetValueDidChange(SBValue self) bool#
GetValueForExpressionPath(SBValue self, char const * expr_path) SBValue#

Expands nested expressions like .a->b[0].c[1]->d.

GetValueType(SBValue self) lldb::ValueType#
IsDynamic(SBValue self) bool#
IsInScope(SBValue self) bool#
IsRuntimeSupportValue(SBValue self) bool#
IsSynthetic(SBValue self) bool#
IsSyntheticChildrenGenerated(SBValue self) bool#
IsValid(SBValue self) bool#
MightHaveChildren(SBValue self) bool#
Persist(SBValue self) SBValue#
SetData(SBValue self, SBData data, SBError error) bool#
SetFormat(SBValue self, lldb::Format format)#
SetPreferDynamicValue(SBValue self, lldb::DynamicValueType use_dynamic)#
SetPreferSyntheticValue(SBValue self, bool use_synthetic)#
SetSyntheticChildrenGenerated(SBValue self, bool arg2)#
SetValueFromCString(SBValue self, char const * value_str) bool#
SetValueFromCString(SBValue self, char const * value_str, SBError error) bool
TypeIsPointerType(SBValue self) bool#
Watch(SBValue self, bool resolve_location, bool read, bool write, SBError error) SBWatchpoint#
Watch(SBValue self, bool resolve_location, bool read, bool write) SBWatchpoint

Find and watch a variable. It returns an SBWatchpoint, which may be invalid.

WatchPointee(SBValue self, bool resolve_location, bool read, bool write, SBError error) SBWatchpoint#

Find and watch the location pointed to by a variable. It returns an SBWatchpoint, which may be invalid.

get_child_access_object()#

An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.

get_expr_path()#
get_value_child_list()#

An accessor function that returns a list() that contains all children in a lldb.SBValue object.

linked_list_iter(next_item_name, end_of_list_test=<function SBValue.__eol_test>)#

Generator adaptor to support iteration for SBValue as a linked list.

linked_list_iter() is a special purpose iterator to treat the SBValue as the head of a list data structure, where you specify the child member name which points to the next item on the list and you specify the end-of-list test function which takes an SBValue for an item and returns True if EOL is reached and False if not.

linked_list_iter() also detects infinite loop and bails out early.

The end_of_list_test arg, if omitted, defaults to the __eol_test function above.

For example,

# Get Frame #0.

# Get variable ‘task_head’.

task_head = frame0.FindVariable(‘task_head’) …

for t in task_head.linked_list_iter(‘next’):

print t

synthetic_child_from_address(name, addr, type)#
synthetic_child_from_data(name, data, type)#
synthetic_child_from_expression(name, expr, options=None)#