Skip to content

Commit 8e08c94

Browse files
committed
"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. (cherry picked from commit c1885d2)
1 parent f8c4926 commit 8e08c94

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lldb/source/Core/Debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
213213

214214
TargetSP target_sp;
215215
LoadScriptFromSymFile load_script_old_value = eLoadScriptFromSymFileFalse;
216-
if (is_load_script && exe_ctx->GetTargetSP()) {
216+
if (is_load_script && exe_ctx && exe_ctx->GetTargetSP()) {
217217
target_sp = exe_ctx->GetTargetSP();
218218
load_script_old_value =
219219
target_sp->TargetProperties::GetLoadScriptFromSymbolFile();

lldb/test/API/commands/settings/TestSettings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,3 +971,11 @@ def test_settings_api(self):
971971

972972
# Test OptionValueLanguage
973973
self.verify_setting_value_json("repl-lang", "c++")
974+
975+
def test_global_option(self):
976+
# This command used to crash the settings because -g was signaled by a
977+
# NULL execution context (not one with an empty Target...) and in the
978+
# special handling for load-script-from-symbol-file this wasn't checked.
979+
self.runCmd("settings set -g target.load-script-from-symbol-file true")
980+
981+

0 commit comments

Comments
 (0)