Hello! I was putzing around with the new {Scripted/Synthetic}FrameProvider support and came across the get_variables callback in the ScriptedFrame example. I was wondering how much y’all are allowed to talk about how far along this is/how it’s doing.
For context, I have a local assembly/interpreter register machine thing I use for playing around, and I want to be able to debug it (because why not). I’m sure there are other people who also want to debug interpreted languages ![]()
I have a patch that I’ve been working on locally that allowed me to use a subclass of ScriptedFrame to list variables (caveat: 1), as well as run expressions, which is how I read the current interpreter state and print things like registers. Running expressions is a little interesting, but it’s nice to have the ability for my custom frame to have complete control over the expressions so I can filter a little bit.
For now, the major changes are (in increasing order of controversy/feedback required):
- Adding SBValueList to swig
- Allowing SBInterpreter to get a ValueObjectSP from an SBValue and associated conversions to/from python for ValueObjectSP and ValueObjectListSP
- Adding
std::optional<lldb::ValueObjectListSP> GetVariables() override;andlldb::ValueObjectSP GetValueObjectForExpression(llvm::StringRef expr, Status &status) override;to ScriptedFramePythonInterface - Adding implementations for GetVariableList, GetInScopeVariableList, GetValueObjectForFrameVariable, and GetValueForVariableExpressionPath to ScriptedFrame
- Adding a patch to CommandObjectDWIMPrint that essentially delegates printing frame variables to the synthetic frame (if we have a frame, and it’s synthetic).
I would be more than happy to contribute these changes, and if y’all have thoughts/advice/comments happy to go through that as well. Basically, I want to make sure I’m not stepping on any toes, or if y’all are close to having something ready then I can just use that
I don’t have a PR yet, but I can put one up if y’all are interested.
I was also thinking a little about how to support synthetic frame variables (like fr v on synthetic frames) and wasn’t really sure - something like an SBVariable could be interesting, but then it really would need to be a separate command that the scripted interface completely handles. Another thing that I’m also trying to avoid is too much reliance on Python - for reasons I am going to try and port this over to C++ when I have time, so I don’t want to end up with something that only works through the python API.
(1) The caveat is that it looks like it has to be a C++ variable object, because GetVariableList requires VariableSP, which is hard to construct synthetically. It’d be really cool to make that easier, but not strictly necessary as long as the caveat is documented somewhere.
cc:
@JDevlieghere @jingham and @mib