Dynamic types

Hello everyone!
I have an issue with getting dynamic type of variable object. I've got an SBValue from SBFrame::EvaluateExpression. It has some type. But it's id for objc object.
"expr <my_expression>"
shows me both types. static and dynamic. How can I get dynamic type programmatically?
Thanks a lot.

SBFrame::EvaluateExpression has a variant that takes a bool for whether you want the dynamic type or not, so you can request the dynamic value when you make the SBValue. But for some reason we didn't make a binding in SBValue to the ValueObject method GetDynamicValue, so you can't get to the dynamic value after you've made the SBValue. That is most likely just an oversight. If you need it right away, feel free to add the accessor. Otherwise I'll get around to it when I have a free minute.


Thre is currently no way to control this selectively through the SB API, but there is a global switch that is controlled by a target setting which will allow you to always get dynamic values:

settings set target.prefer-dynamic-value no-dynamic-values

settings set target.prefer-dynamic-value run-target

settings set target.prefer-dynamic-value no-run-target

The "no-dynamic-values" will always hand out types as they are in your program. The "run-target" setting tells LLDB that it is ok to run the target when doing dynamic type resolution. This means one mor more threads might get run when trying to determine the dynamic type of a variable. The "no-run-target" tells LLDB to do what it can to determine dynamic types statically without ever running the process we are debugging. The default is "no-dynamic-values", so try excuting one of the above commands before debugging through the command interpreter API and verify you then do get dynamic types.

Greg Clayton

I do pass this flag to EvaluateExpression but still get 'id' as type.

Not sure what is going on, then. I just checked and this works as expected on TOT for me. There are a couple of test cases in:


They were turned off at some point because we hadn't added the use_dynamic variant to EvaluateExpression, but I just turned them back on and checked that in, and they do pass for me. First step is probably to ensure that they pass for you as well. You can run just one test directory by cd'ing into the test directory and doing:

./dotest.py lang/cpp/dynamic-value/TestDynamicValue.py

If that works, then there's something funny going on in the case you are working on.