Question

I am writing C++ on Xcode and the only choice is lldb. I define a variable with the type of

std::list<State> states;

and the Class is a self defined class. I tried to use expr command and frame variable, but they can't help.

The result for expr is

error: Couldn't materialize struct: size of variable states (24) disagrees with the ValueObject's size (0)

and result for frame variable is

(std::__1::list<State, std::__1::allocator<State> >) states = <variable not available>
Was it helpful?

Solution

The variable has been optimized away at this point in your program. The error message from expr/p is a little unfortunate - there's a change in top of tree which should allow the real error to be emitted - but the behavior is correct. The frame variable output is the correct error message.

You can always do

(lldb) image lookup -v -a $pc

to see the locations of all visible variables at a point in your program. They are expressed in the form of a DWARF expression which is usually expressed in terms of the frame base register (DW_OP_fbreg) which is usually rbp on x86_64 for instance.

If a variable is listed with an empty location= field, that means that the variable's value is not available at this pc location.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top