This is an archive of the discontinued LLVM Phabricator instance.

When a ValueObjectDynamicValue fails to update, return a not valid ValueObject so the static one is used instead
ClosedPublic

Authored by jingham on Mar 8 2023, 4:29 PM.

Details

Summary

When we can't find a valid type for a dynamic value (for instance we just have a void * and can't compute anything for it) we used to try to hand out a dynamic value that "behaves like the static value". That mostly works, but getting something to behave like ValueObjectConstResult without being it didn't work - for instance AddressOf fails for this DynamicValue.

The comment before this section of code mentions that we might should return an invalid dynamic value instead, so that the static one would get used. I switched over to that, and I just needed to fix up a few cases where we were handing out a dynamic value w/o making sure it was valid first. That ends up being much simpler than trying to get this ValueObjectDynamicValue to be "just like" ValueObjectConstResult.

Diff Detail

Event Timeline

jingham created this revision.Mar 8 2023, 4:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2023, 4:29 PM
jingham requested review of this revision.Mar 8 2023, 4:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2023, 4:29 PM
mib accepted this revision.Mar 8 2023, 4:58 PM

LGTM with a comment.

lldb/source/Core/ValueObject.cpp
1862

It would be nice if ValueObjectDynamicValue had a IsValid method that returned the result of its Status attribute. Without reading the commit message, GetError doesn't tell us much about what we're trying to achieve here.

lldb/source/Core/ValueObjectConstResult.cpp
290

ditto

This revision is now accepted and ready to land.Mar 8 2023, 4:58 PM
jingham added inline comments.Mar 9 2023, 9:50 AM
lldb/source/Core/ValueObject.cpp
1862

IsValid is less restrictive than having an error. IsValid is true if the value has a variable in it, even if, for instance, we couldn't currently read the memory underlying the value. I want "was there any error at all", so checking the Error is more appropriate here.