Author: Jim Ingham Date: 2023-07-10T14:40:18-07:00 New Revision: c1885d2dfa950d0f78978546f92be15bc6cca474
URL: https://github.com/llvm/llvm-project/commit/c1885d2dfa950d0f78978546f92be15bc6cca474 DIFF: https://github.com/llvm/llvm-project/commit/c1885d2dfa950d0f78978546f92be15bc6cca474.diff LOG: "settings set -g target.load-script-from-symbol-file" shouldn't crash. -g is specified by passing in nullptr ExecutionContext, but in some load-script-from-symbol-file specific code, the ExecutionContext was asked for its Target w/o checking whether the pointer was null. Fix that and add a test. Added: Modified: lldb/source/Core/Debugger.cpp lldb/test/API/commands/settings/TestSettings.py Removed: ################################################################################ diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 3e92c125aa4ee6..4f06ed07274914 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -212,7 +212,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, TargetSP target_sp; LoadScriptFromSymFile load_script_old_value = eLoadScriptFromSymFileFalse; - if (is_load_script && exe_ctx->GetTargetSP()) { + if (is_load_script && exe_ctx && exe_ctx->GetTargetSP()) { target_sp = exe_ctx->GetTargetSP(); load_script_old_value = target_sp->TargetProperties::GetLoadScriptFromSymbolFile(); diff --git a/lldb/test/API/commands/settings/TestSettings.py b/lldb/test/API/commands/settings/TestSettings.py index 5c37264281c88b..7c90ef4ba2a446 100644 --- a/lldb/test/API/commands/settings/TestSettings.py +++ b/lldb/test/API/commands/settings/TestSettings.py @@ -971,3 +971,11 @@ def test_settings_api(self): # Test OptionValueLanguage self.verify_setting_value_json("repl-lang", "c++") + + def test_global_option(self): + # This command used to crash the settings because -g was signaled by a + # NULL execution context (not one with an empty Target...) and in the + # special handling for load-script-from-symbol-file this wasn't checked. + self.runCmd("settings set -g target.load-script-from-symbol-file true") + + _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits