[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](230e465617/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.
This commit is contained in:
Michael Buch 2026-03-11 15:37:07 +00:00 committed by GitHub
parent a9006ada05
commit f58cffb273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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<CallbackLogHandler>(log_callback, baton);

View File

@ -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