[Lldb-commits] [lldb] [lldb] Fix settings set to accept values starting with dash (PR #176076)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 14 17:57:07 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: MkDev11 (MkDev11)
<details>
<summary>Changes</summary>
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
---
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147
---
Full diff: https://github.com/llvm/llvm-project/pull/176076.diff
1 Files Affected:
- (modified) lldb/source/Commands/CommandObjectSettings.cpp (+15)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/176076
More information about the lldb-commits
mailing list