This is an archive of the discontinued LLVM Phabricator instance.

Handle trailing spaces on "settings set" command more correctly
ClosedPublic

Authored by labath on Feb 12 2015, 8:31 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 19835.Feb 12 2015, 8:31 AM
labath retitled this revision from to Handle trailing spaces on "settings set" command more correctly.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: clayborg, zturner.
labath added a subscriber: Unknown Object (MLST).
clayborg requested changes to this revision.Feb 12 2015, 10:01 AM
clayborg edited edge metadata.

See inline code comments.

Overall good patch, we should not switch just one (StringToBoolean) over to use llvm::StringRef unless we plan to change all of them. I would be happy, possibly in another patch to see:

OptionValue::SetValueFromCString(const char *s, ...)

be switched over to:

OptionValue::SetValueFromString(llvm::StringRef str, ...)

include/lldb/Interpreter/Args.h
21 ↗(On Diff #19835)

Remove this if you agree with my comments on line 385.

385 ↗(On Diff #19835)

Unless we are going to change all StringTo calls with llvm::StringRef, I would leave this as a "const char *" and just make a local llvm::StringRef inside StringToBoolean.

source/Interpreter/Args.cpp
871 ↗(On Diff #19835)

We should use "const char *" for this arg unless we plan to switch all StringTo functions over to use llvm::StringRef and just make a local llvm::StringRef.

874–877 ↗(On Diff #19835)

We should use equals_lower(...) instead of compare_lower here.

884–887 ↗(On Diff #19835)

We should use equals_lower(...) instead of compare_lower here.

This revision now requires changes to proceed.Feb 12 2015, 10:01 AM
labath updated this revision to Diff 19876.Feb 13 2015, 2:39 AM
labath edited edge metadata.

Address review comments.

I will follow this up with a SetValueFromCString -> StringRef patch

clayborg accepted this revision.Feb 13 2015, 9:40 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Feb 13 2015, 9:40 AM
This revision was automatically updated to reflect the committed changes.