From f58cffb27399c2e90958bbc15c14fed841ae4174 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 11 Mar 2026 15:37:07 +0000 Subject: [PATCH] [lldb][Debugger] Register 'testing.XXX' settings with Debugger (#185897) The `testing.XXX` settings (added in https://github.com/llvm/llvm-project/pull/177279 and currently just `testing.inject-variable-location-error`) are supposed to only exist in asserts builds. However, we never added it as a global property to the `Debugger`, so the setting wasn't actually usable, in any build. The one test that did use it [skipped the test on error](https://github.com/llvm/llvm-project/blob/230e4656170e3764db28b54d91153a1117290171/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py#L286-L288) as a way to mimick "only run test in asserts mode". However, this just meant the test never ran. This patch registers the property and adds a test that ensures an asserts-LLDB does allow access to it from the CLI. --- lldb/source/Core/Debugger.cpp | 6 ++++++ lldb/test/Shell/Settings/TestTestingSettings.test | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 lldb/test/Shell/Settings/TestTestingSettings.test diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 05c2ed13374a..1dad6983eecd 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1015,6 +1015,12 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) "Settings specify to the debugger's command interpreter.", true, m_command_interpreter_up->GetValueProperties()); } +#ifndef NDEBUG + m_collection_sp->AppendProperty( + "testing", "Testing-only settings.", /*is_global=*/true, + TestingProperties::GetGlobalTestingProperties().GetValueProperties()); +#endif + if (log_callback) m_callback_handler_sp = std::make_shared(log_callback, baton); diff --git a/lldb/test/Shell/Settings/TestTestingSettings.test b/lldb/test/Shell/Settings/TestTestingSettings.test new file mode 100644 index 000000000000..f8fab476b46a --- /dev/null +++ b/lldb/test/Shell/Settings/TestTestingSettings.test @@ -0,0 +1,7 @@ +# REQUIRES: asserts +# +# Tests that the global 'testing.XXX' settings are available when building with asserts. +# +# RUN: %lldb -o 'settings show testing.inject-variable-location-error' -b | FileCheck %s +# +# CHECK: testing.inject-variable-location-error (boolean) = false