Handle trailing spaces on "settings set" command more correctly
Summary:
Currently we have some settings which treat "\ " on settings set commands specially. E.g., it is
a valid way of specifying an argument of " " to a target. However, this fails if "\ " is the last
argument as CommandObjectSettingsSet strips trailing whitespace. This resulted in a surprising
argument of "\" to the target.
This patch disables the training whitespace removal at a global
level. Instead, for each argument type we locally determine whether whitespace stripping makes
sense. Currently, I strip whitespace for all simple object type except of regex and
format-string, with the rationale that these two object types do their own complex parsing and we
want to interfere with them as least as possible. Specifically, stripping the whitespace of a
regex "\ " will result in a (surprising?) error "trailing backslash". Furthermore, the default
value of dissasembly-format setting already contains a trailing space and there is no way for the
user to type this in manually if we strip whitespace.
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D7592
llvm-svn: 229382
diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py
index c0670b7..2cb57da 100644
--- a/lldb/test/settings/TestSettings.py
+++ b/lldb/test/settings/TestSettings.py
@@ -396,6 +396,13 @@
'[0]: "3"',
'[1]: "4"',
'[2]: "5"' ])
+ self.runCmd ("settings set target.run-args 1 2 3") # Set to known value
+ self.runCmd ("settings set target.run-args 3 \ \ ") # Set to new value with trailing whitespaces
+ self.expect ("settings show target.run-args", SETTING_MSG("target.run-args"),
+ substrs = [ 'target.run-args (arguments) =',
+ '[0]: "3"',
+ '[1]: " "',
+ '[2]: " "' ])
self.runCmd("settings clear target.run-args", check=False)
# dictionaries
self.runCmd ("settings clear target.env-vars") # Set to known value
@@ -405,6 +412,20 @@
'A=B',
'C=D'])
self.runCmd("settings clear target.env-vars", check=False)
+ # regex
+ self.runCmd ("settings clear target.process.thread.step-avoid-regexp") # Set to known value
+ self.runCmd ("settings set target.process.thread.step-avoid-regexp foo\\ ") # Set to new value with trailing whitespaces
+ self.expect ("settings show target.process.thread.step-avoid-regexp",
+ SETTING_MSG("target.process.thread.step-avoid-regexp"),
+ substrs = [ 'target.process.thread.step-avoid-regexp (regex) = foo\\ '])
+ self.runCmd("settings clear target.process.thread.step-avoid-regexp", check=False)
+ # format-string
+ self.runCmd ("settings clear disassembly-format") # Set to known value
+ self.runCmd ("settings set disassembly-format foo ") # Set to new value with trailing whitespaces
+ self.expect ("settings show disassembly-format",
+ SETTING_MSG("disassembly-format"),
+ substrs = [ 'disassembly-format (format-string) = "foo "'])
+ self.runCmd("settings clear disassembly-format", check=False)
def test_all_settings_exist (self):
self.expect ("settings show",