aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-02-28 09:24:46 -0800
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-02-28 11:39:58 -0800
commit9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515 (patch)
tree89d1c4a0563930d69e8427b0bf84a32f6caffa51 /lldb/source/Commands/CommandObjectWatchpointCommand.cpp
parentec7154fe70284a51b7b246c7e5aebabd33a7e2d4 (diff)
downloadllvm-9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515.zip
llvm-9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515.tar.gz
llvm-9a9fce1fed6d2af3fb6d1d7073c4a0b3e00bc515.tar.bz2
[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@gmail.com>
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpointCommand.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index b33f403..37052dd 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -415,17 +415,18 @@ protected:
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
script_interp->SetWatchpointCommandCallback(
- wp_options, m_options.m_one_liner.c_str());
+ wp_options, m_options.m_one_liner.c_str(),
+ /*is_callback=*/false);
}
// Special handling for using a Python function by name instead of
// extending the watchpoint callback data structures, we just
// automatize what the user would do manually: make their watchpoint
// command be a function call
else if (!m_options.m_function_name.empty()) {
- std::string oneliner(m_options.m_function_name);
- oneliner += "(frame, wp, internal_dict)";
+ std::string function_signature = m_options.m_function_name;
+ function_signature += "(frame, wp, internal_dict)";
script_interp->SetWatchpointCommandCallback(
- wp_options, oneliner.c_str());
+ wp_options, function_signature.c_str(), /*is_callback=*/true);
} else {
script_interp->CollectDataForWatchpointCommandCallback(wp_options,
result);