aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces
diff options
context:
space:
mode:
authorAman LaChapelle <aman.lachapelle@gmail.com>2026-01-29 21:24:17 -0800
committerGitHub <noreply@github.com>2026-01-29 21:24:17 -0800
commit10f2611c2173783efae8aebc32d1515013271b64 (patch)
treec0cabd091b9acaab0633a496ba9e507882970e7d /lldb/source/Plugins/ScriptInterpreter/Python/Interfaces
parent120b482375b29db5822f0907bd3e47d958549580 (diff)
downloadllvm-10f2611c2173783efae8aebc32d1515013271b64.tar.gz
llvm-10f2611c2173783efae8aebc32d1515013271b64.tar.bz2
llvm-10f2611c2173783efae8aebc32d1515013271b64.zip
[lldb] Add support for ScriptedFrame to provide values/variables. (#178575)
This patch adds plumbing to support the implementations of StackFrame::Get{*}Variable{*} on ScriptedFrame. The major pieces required are: - A modification to ScriptedFrameInterface, so that we can actually call the python methods. - A corresponding update to the python implementation to call the python methods. - An implementation in ScriptedFrame that can get the variable list on construction inside ScriptedFrame::Create, and pass that list into the ScriptedFrame so it can get those values on request. There is a major caveat, which is that if the values from the python side don't have variables attached, right now, they won't be passed into the scripted frame to be stored in the variable list. Future discussions around adding support for 'extended variables' when printing frame variables may create a reason to change the VariableListSP into a ValueObjectListSP, and generate the VariableListSP on the fly, but that should be addressed at a later time. This patch also adds tests to the frame provider test suite to prove these changes all plumb together correctly. Related radar: rdar://165708771
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp28
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp
index 20ca7a2c0135..9cc7b04fc9db 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp
@@ -154,4 +154,32 @@ std::optional<std::string> ScriptedFramePythonInterface::GetRegisterContext() {
return obj->GetAsString()->GetValue().str();
}
+lldb::ValueObjectListSP ScriptedFramePythonInterface::GetVariables() {
+ Status error;
+ auto vals = Dispatch<lldb::ValueObjectListSP>("get_variables", error);
+
+ if (error.Fail()) {
+ return ErrorWithMessage<lldb::ValueObjectListSP>(LLVM_PRETTY_FUNCTION,
+ error.AsCString(), error);
+ }
+
+ return vals;
+}
+
+lldb::ValueObjectSP
+ScriptedFramePythonInterface::GetValueObjectForVariableExpression(
+ llvm::StringRef expr, uint32_t options, Status &status) {
+ Status dispatch_error;
+ auto val = Dispatch<lldb::ValueObjectSP>("get_value_for_variable_expression",
+ dispatch_error, expr.data(), options,
+ status);
+
+ if (dispatch_error.Fail()) {
+ return ErrorWithMessage<lldb::ValueObjectSP>(
+ LLVM_PRETTY_FUNCTION, dispatch_error.AsCString(), dispatch_error);
+ }
+
+ return val;
+}
+
#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h
index 3aff237ae65d..d8ac093106bb 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h
@@ -52,6 +52,12 @@ public:
StructuredData::DictionarySP GetRegisterInfo() override;
std::optional<std::string> GetRegisterContext() override;
+
+ lldb::ValueObjectListSP GetVariables() override;
+
+ lldb::ValueObjectSP
+ GetValueObjectForVariableExpression(llvm::StringRef expr, uint32_t options,
+ Status &status) override;
};
} // namespace lldb_private