diff options
author | jimingham <jingham@apple.com> | 2025-03-25 09:56:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-25 09:56:58 -0700 |
commit | 870463519bab45acf8590d41d9f2a161c37f26d5 (patch) | |
tree | 06f1b3d286b19b811bb22d3da8ff3c88ebb5d9a8 /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | 0919ab3cb64668d771540c83fe439da8796b9ada (diff) | |
download | llvm-870463519bab45acf8590d41d9f2a161c37f26d5.zip llvm-870463519bab45acf8590d41d9f2a161c37f26d5.tar.gz llvm-870463519bab45acf8590d41d9f2a161c37f26d5.tar.bz2 |
Fix the managing of the session dictionary when you have nested wrappers (#132846)
Since the inner wrapper call might have removed one of the entries from
the global dict that the outer wrapper ALSO was going to delete, make
sure that we check that the key is still in the global dict before
trying to act on it.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 00d0198..4b7694d 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1267,6 +1267,8 @@ Status ScriptInterpreterPythonImpl::ExportFunctionDefinitionToInterpreter( StringList &function_def) { // Convert StringList to one long, newline delimited, const char *. std::string function_def_string(function_def.CopyList()); + LLDB_LOG(GetLog(LLDBLog::Script), "Added Function:\n%s\n", + function_def_string.c_str()); Status error = ExecuteMultipleLines( function_def_string.c_str(), ExecuteScriptOptions().SetEnableIO(false)); @@ -1336,13 +1338,15 @@ Status ScriptInterpreterPythonImpl::GenerateFunction(const char *signature, " for key in new_keys:"); // Iterate over all the keys from session // dict auto_generated_function.AppendString( - " internal_dict[key] = global_dict[key]"); // Update session dict - // values + " if key in old_keys:"); // If key was originally in + // global dict auto_generated_function.AppendString( - " if key not in old_keys:"); // If key was not originally in - // global dict + " internal_dict[key] = global_dict[key]"); // Update it auto_generated_function.AppendString( - " del global_dict[key]"); // ...then remove key/value from + " elif key in global_dict:"); // Then if it is still in the + // global dict + auto_generated_function.AppendString( + " del global_dict[key]"); // remove key/value from the // global dict auto_generated_function.AppendString( " return __return_val"); // Return the user callback return value. |