[all-commits] [llvm/llvm-project] 9a9fce: [lldb] Fix {break, watch}point command function sto...
Med Ismail Bennani via All-commits
all-commits at lists.llvm.org
Tue Feb 28 11:40:22 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515
https://github.com/llvm/llvm-project/commit/9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515
Author: Med Ismail Bennani <medismail.bennani at gmail.com>
Date: 2023-02-28 (Tue, 28 Feb 2023)
Changed paths:
M lldb/include/lldb/Interpreter/ScriptInterpreter.h
M lldb/source/API/SBBreakpoint.cpp
M lldb/source/API/SBBreakpointLocation.cpp
M lldb/source/API/SBBreakpointName.cpp
M lldb/source/Commands/CommandObjectWatchpointCommand.cpp
M lldb/source/Interpreter/ScriptInterpreter.cpp
M lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
M lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
M lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
M lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
M lldb/test/API/commands/watchpoints/watchpoint_commands/command/main.cpp
M lldb/test/API/commands/watchpoints/watchpoint_commands/command/watchpoint_command.py
Log Message:
-----------
[lldb] Fix {break,watch}point command function stopping behaviour
In order to run a {break,watch}point command, lldb can resolve to the
script interpreter to run an arbitrary piece of code or call into a
user-provided function. To do so, we will generate a wrapping function,
where we first copy lldb's internal dictionary keys into the
interpreter's global dictionary, copied inline the user code before
resetting the global dictionary to its previous state.
However, {break,watch}point commands can optionally return a value that
would tell lldb whether we should stop or not. This feature was
only implemented for breakpoint commands and since we inlined the user
code directly into the wrapping function, introducing an early return,
that caused lldb to let the interpreter global dictionary tinted with the
internal dictionary keys.
This patch fixes that issue while also adding the stopping behaviour to
watchpoint commands.
To do so, this patch refactors the {break,watch}point command creation
method, to let the lldb wrapper function generator know if the user code is
a function call or a arbitrary expression.
Then the wrapper generator, if the user input was a function call, the
wrapper function will call the user function and save the return value into
a variable. If the user input was an arbitrary expression, the wrapper will
inline it into a nested function, call the nested function and save the
return value into the same variable. After resetting the interpreter global
dictionary to its previous state, the generated wrapper function will return
the varible containing the return value.
rdar://105461140
Differential Revision: https://reviews.llvm.org/D144688
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
More information about the All-commits
mailing list