This is an archive of the discontinued LLVM Phabricator instance.

Preserve SBValue's that only have an Error state
ClosedPublic

Authored by jingham on Feb 23 2023, 12:00 PM.

Details

Summary

SBValues carry their own errors with them (SBValue::GetError). That means that even if an SBValue was made in a situation where we couldn't actually make a value (e.g. you called lldb.frame.EvaluateExpression while the target is running) the error is still useful. We were using the IsValid check to decide whether to actually return the underlying ValueObject to the SBValue.

This could have been implemented two ways. One is to add "Has an error" to the conditions that would cause IsValid to return true. I chose not to do that because previously you could use IsValid to mean "has a valid Value" and so this would have been a semantic change and could break scripts.

Instead I just add the few "or has error" checks needed to preserve "error only SBValues" in the SBValue interface, and fixed up a couple places in ValueObject printing where we needed to print the error if the ValueObject had no other useful state.

This patch doesn't have a test. I have a follow-on commit which is what motivated this change and the test for that was what necessitated, and will verify, this change.

Diff Detail