werat added a comment. In D98370#2705741 <https://reviews.llvm.org/D98370#2705741>, @jingham wrote:
> Sure. But but when I was poking around at it a little bit, it seems like the > other use cases already work, and the only one that was failing was the case > where you call persist on a persistent variable. If that is really true, > then maybe we should fix the failing case directly. Right now `Persist()` doesn't really work for values created via `CreateValueFromData`. You can read them, but can't modify: >>> data = lldb.SBData.CreateDataFromUInt64Array(lldb.process.GetByteOrder(), lldb.process.GetAddressByteSize(), [42]) >>> v = lldb.target.CreateValueFromData('v', data, lldb.target.GetBasicType(lldb.eBasicTypeUnsignedLong)) >>> v.value '42' >>> vp = v.Persist() >>> vp.name '$3' >>> lldb.frame.EvaluateExpression('$3').value '42' >>> lldb.frame.EvaluateExpression('++$3 + 1').value >>> lldb.frame.EvaluateExpression('++$3 + 1').error.GetCString() "error: supposed to interpret, but failed: Interpreter couldn't read from memory\n" However I realized my patch doesn't completely fixes it either: >>> data = lldb.SBData.CreateDataFromUInt64Array(lldb.process.GetByteOrder(), lldb.process.GetAddressByteSize(), [42]) >>> v = lldb.target.CreateValueFromData('v', data, lldb.target.GetBasicType(lldb.eBasicTypeUnsignedLong)) >>> vp = v.Persist() >>> vp.name '$0' >>> lldb.frame.EvaluateExpression('$0').value '42' >>> lldb.frame.EvaluateExpression('++$0').value '43' >>> lldb.frame.EvaluateExpression('++$0').value '44' >>> vp.value '42' In D98370#2705741 <https://reviews.llvm.org/D98370#2705741>, @jingham wrote: > Not sure why? The API is a request: "I made a variable somehow, and I would > like you to make it persist so I can use its value later on even if the > underlying data has changed." Why do you care whether you get a copy of an > already persistent or just a shared value? You're right, I got confused by something else. I don't care if I get a new name/copy, as long as I can use it by the returned name it's fine. However I want to point out that the current API does generate a new name every time (but the it points to the same data): >>> x = lldb.frame.FindVariable('x') >>> x.value '1' >>> xp1 = x.Persist() >>> xp1.name '$0' >>> xp2 = x.Persist() >>> xp2.name '$1' >>> lldb.frame.EvaluateExpression('++$0 + ++$1').value '3' >>> xp1.value '3' >>> xp2.value '3' Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98370/new/ https://reviews.llvm.org/D98370 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits