[Lldb-commits] [lldb] [lldb] Remove ValueObject::CastPointerType() methods (PR #191032)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 8 17:27:49 PDT 2026
jimingham wrote:
Most of the value object subclasses are pretty straightforward.
**ValueObjectMemory** is a simple "address in the target + type". The truth of its value is whatever happens to be at that memory location in the target program.
**ValueObjectVariable** represents some local or global variable read from debug info, and generally has a thread & stack frame and then an lldb_private::Variable with location information that tells it how to refresh its value on each stop.
**ValueObjectChild** gets its value from some location within another ValueObject. It's used to represent structure members, etc.
**ValueObjectRegister** are also pretty obvious.
**ValueObjectSynthetic** holds some other ValueObject, and provides an alternate view of its children, which it makes up however it likes. You can ask it for its underlying "NonSynthetic" ValueObject if you want to see the "raw" view.
**ValueObjectDynamic** holds another ValueObject, an "offset to top" and a "dynamic type". This is used for instance to re-present a ValueObjectVariable whose type is the base class of the actual object's complete type.
**ValueObjectConstResult** is the outlier. It was originally designed to hold the $<N> results of expression evaluation. When someone does:
(lldb) expr some_var
(int) $0 = 10
Then the ValueObject $0 should retain the value 10, even though the actual some_var is now some other value. So they have to copy the data up from the target and hold it on the lldb side. However, it is made more complicated because people also expect:
(lldb) expr printf("%d\n", $0)
to print "10". Also, if the expression result is a struct, they expect:
(lldb) expr some_struct
(MyStruct) $1 = {a_scalar = 10, a_pointer = 0x12345}
(lldb) expr $1.a_pointer->pointer_member
to gather the same value as:
(lldb) expr some_struct.a_pointer->pointer_member
at least while the StopID of the process hasn't changed since the result was gathered. They also have to have addresses in the target because people also expect:
(lldb) expr structure_pointer_taking_function(&$1)
to work, so they have to have bona-fide addresses in the target. They might also have to implement their existence on the target side out of the expression, for instance in:
(lldb) expr make_me_a_structure()
**ValueObjectConstResultChild** is like ValueObjectChild, except it also has this two-sided existence in the target and in lldb's memory.
That was gnarly enough, but then we started using ValueObjectConstResult in a bunch of places (particularly for making the children that ValueObjectSynthetic hands) where I don't think we are using the more complex properties of ValueObjectConstResult - for instance they get thrown away and remade in Update so we aren't using their Const property.
Disentangling the parts of ValueObjectConstResult that are needed to support expressions and the parts that are needed for the synthetic child providers would probably lead to some nice simplifications, but is likely not trivial.
https://github.com/llvm/llvm-project/pull/191032
More information about the lldb-commits
mailing list