[all-commits] [llvm/llvm-project] d28da7: [lldb] Make ScriptedPythonInterface::Dispatch retu...
Med Ismail Bennani via All-commits
all-commits at lists.llvm.org
Mon Sep 21 18:10:55 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d28da7e5238e8bd81c609ef19170dc6b73ee48ac
https://github.com/llvm/llvm-project/commit/d28da7e5238e8bd81c609ef19170dc6b73ee48ac
Author: Med Ismail Bennani <ismail at bennani.ma>
Date: 2026-09-22 (Tue, 22 Sep 2026)
Changed paths:
M lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
M lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedCommandPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFrameProviderPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedFramePythonInterface.h
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedHookPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStackFrameRecognizerPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStringSummaryPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedSyntheticChildrenPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedSyntheticChildrenPythonInterface.h
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
M lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
M lldb/source/Target/ScriptedThreadPlan.cpp
M lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
M lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
Log Message:
-----------
[lldb] Make ScriptedPythonInterface::Dispatch return llvm::Expected<T> (#224988)
Until now, `Dispatch` returned the extracted value and reported failure
through a `Status &` out-parameter, which leaves the two outcomes
indistinguishable at the value level: a Python method that returns
`None` and one that raises both hand back a default-constructed `T`.
Only `error` told them apart, and because the signature advertises the
value, call sites reached for the value and dropped the error.
Three real instances of that:
- `ScriptedHookPythonInterface::HandleStop` returned `true` whenever the
object was null, discarding the backtrace of a raising `handle_stop`
(fixed separately).
- `GetStatusFromMethod` discarded `Dispatch<Status>`'s return value, so
the `SBError` returned by `ScriptedProcess.launch/attach/resume` and the
three `ScriptedPlatform` entry points was ignored entirely: a `launch()`
returning `SBError("no such file")` reported success.
- `GetThreadPlanMetadataForStepType` string-matched the exception text
to guess whether the method existed, with a FIXME asking for exactly
this.
This switches `Dispatch`, `CallStaticMethod` and
`ExtractValueFromPythonObject` to `llvm::Expected<T>` and drop the
out-parameter. `CheckStructuredDataObject` becomes dead and is removed.
An absent method now yields `UnimplementedError`. Three helpers let each
call site state its intent: `DispatchToOptional` for optional methods a
script may legitimately omit, which reports an unimplemented method as
`std::nullopt` and lets every other failure propagate; `LogAndDefault`
for entry points whose return type cannot express failure, which logs
the error and falls back to a default-constructed value instead of
discarding it; and `LogAndError`, which builds and logs the errors
`Dispatch` returns itself.
Widening the `LogAndDefault` entry points to `Expected` touches every
caller in ScriptedThread/ScriptedProcess/ScriptedFrame and is left as
follow-up.
This patch stops at the interface layer deliberately: it is about
surfacing the error and the Python exception out of `Dispatch` and into
the scripted interface classes. That has to happen to all of them at
once, because they share the same dispatch entry point, which is why
this touches every interface class together. Carrying those exceptions
the rest of the way to the user is per-extension work, and lands as a
follow-up PR for each extension.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list