SBValue defined vs runtime type

Since a while ago SBValue now returns the real type (The instance) of a value instead of the defined type (ie:

NSObject* val = [[MyObject alloc]init];

returns MyObject * instead of NSObject *

I like this but would also like to know the defined type (NSObject*). How can I get this? (either via SBValue or ValueObject)?

You can call:

my_value.SetPreferDynamicValue(eNoDynamicValues)

before fetching the type or value from an SBValue.

Jim

jingham@apple.com schreef op 2/10/2015 om 10:18 PM:

You can call:

my_value.SetPreferDynamicValue(eNoDynamicValues)

before fetching the type or value from an SBValue.

Won't that make me unable to get the dynamic type afterwrds? The type seems to be cached

jingham@apple.com schreef op 2/10/2015 om 10:18 PM:

You can call:

my_value.SetPreferDynamicValue(eNoDynamicValues)

before fetching the type or value from an SBValue.

Won’t that make me unable to get the dynamic type afterwrds? The type seems to be cached

Not at the SBValue level

The way this works is that you set the SBValue not to prefer the dynamic value - that changes the underlying ValueObject that we ask questions of from the dynamic value to the static value
When you flip the setting, we’ll try asking the dynamic value instead of the static one

Refer to ValueImpl in SBValue.cpp to see how this works


Carlo Kok
RemObjects Software


lldb-dev mailing list
lldb-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone: 27683

As long as the variable we're printing remains in scope, you should be able to change your mind about what you want to fetch and we'll refresh the object. You can see this for instance in the Script interpreter:

print var.GetType()

Dynamic:
FooChild *
Static:
Foo *

print var.SetPreferDynamicValue(lldb.eNoDynamicValues)

None

print var.GetType()

Foo *

print var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)

None

print var.GetType()

Dynamic:
FooChild *
Static:
Foo *

Once the value is no longer alive in the target (e.g. it was a local and you stepped out of that local's frame) then we won't be able to fetch any more information about it and you're stuck with what you asked for.

Jim