aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
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/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
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/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 98a05d8..b3568e6 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -188,16 +188,17 @@ public:
lldb_private::CommandReturnObject &cmd_retobj, Status &error,
const lldb_private::ExecutionContext &exe_ctx) override;
- Status GenerateFunction(const char *signature,
- const StringList &input) override;
+ Status GenerateFunction(const char *signature, const StringList &input,
+ const bool is_callback) override;
- Status GenerateBreakpointCommandCallbackData(
- StringList &input,
- std::string &output,
- bool has_extra_args) override;
+ Status GenerateBreakpointCommandCallbackData(StringList &input,
+ std::string &output,
+ bool has_extra_args,
+ const bool is_callback) override;
bool GenerateWatchpointCommandCallbackData(StringList &input,
- std::string &output) override;
+ std::string &output,
+ const bool is_callback) override;
bool GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj,
StructuredData::ObjectSP &callee_wrapper_sp,
@@ -260,7 +261,8 @@ public:
/// Set the callback body text into the callback for the breakpoint.
Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
- const char *callback_body) override;
+ const char *callback_body,
+ const bool is_callback) override;
Status SetBreakpointCommandCallbackFunction(
BreakpointOptions &bp_options, const char *function_name,
@@ -274,11 +276,13 @@ public:
Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
const char *command_body_text,
StructuredData::ObjectSP extra_args_sp,
- bool uses_extra_args);
+ bool uses_extra_args,
+ const bool is_callback);
/// Set a one-liner as the callback for the watchpoint.
void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
- const char *oneliner) override;
+ const char *user_input,
+ const bool is_callback) override;
const char *GetDictionaryName() { return m_dictionary_name.c_str(); }