[Lldb-commits] [lldb] [lldb] Fix settings set to accept values starting with dash (PR #176076)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 19 02:22:38 PST 2026
https://github.com/MkDev11 updated https://github.com/llvm/llvm-project/pull/176076
>From fb668aeb47ba86dce5e49aefd63158e57d9bfc6a Mon Sep 17 00:00:00 2001
From: mkdev11 <jaysmth689 at gmail.com>
Date: Thu, 15 Jan 2026 03:47:57 +0200
Subject: [PATCH] [lldb] Fix settings set to accept values starting with dash
The 'settings set' command was rejecting values that start with a dash
(e.g., 'settings set target.run-args -foo bar') because the option
parser was interpreting them as unknown options.
This fix inserts '--' before the variable name to terminate option
parsing, allowing values like '-foo' to be passed correctly.
Fixes #171493
---
lldb/source/Commands/CommandObjectSettings.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 126f57c738115..fb09a45582126 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -173,6 +173,21 @@ insert-before or insert-after.");
CommandReturnObject &result) override {
Args cmd_args(command);
+ // Find the index of the first non-option argument (the variable name).
+ // Insert "--" before it to prevent values like "-foo" from being
+ // interpreted as options.
+ size_t var_name_idx = 0;
+ for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i) {
+ const char *arg = cmd_args.GetArgumentAtIndex(i);
+ if (arg && arg[0] != '-') {
+ var_name_idx = i;
+ break;
+ }
+ }
+ // Insert "--" to terminate option parsing before the variable name and
+ // its values.
+ cmd_args.InsertArgumentAtIndex(var_name_idx, "--");
+
// Process possible options.
if (!ParseOptions(cmd_args, result))
return;
More information about the lldb-commits
mailing list