[Lldb-commits] [PATCH] Fix check for options in "command alias"

Ted Woodward ted.woodward at codeaurora.org
Mon Apr 6 10:16:07 PDT 2015


Hi clayborg,

"command alias" can add invalid options to the command. "command alias start process launch -s" will add an extra argument, "<no-argument>" to the alias, so it runs "process launch -s <no-argument>", which launches the process with args that include "<no-argument>".

This patch changes the text compare of the variable value with "<OptionParser::eNoArgument>" to a compare of variable value_type with OptionParser::eNoArgument. It also moves the previous test inside the if, so it won't add a trailing space if there is no argument.

http://reviews.llvm.org/D8844

Files:
  source/Interpreter/CommandInterpreter.cpp

Index: source/Interpreter/CommandInterpreter.cpp
===================================================================
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -1457,10 +1457,10 @@
                 else
                 {
                     result_str.Printf (" %s", option.c_str());
-                    if (value_type != OptionParser::eOptionalArgument)
-                        result_str.Printf (" ");
-                    if (value.compare ("<OptionParser::eNoArgument>") != 0)
+                    if (value_type != OptionParser::eNoArgument)
                     {
+                        if (value_type != OptionParser::eOptionalArgument)
+                            result_str.Printf (" ");
                         int index = GetOptionArgumentPosition (value.c_str());
                         if (index == 0)
                             result_str.Printf ("%s", value.c_str());

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8844.23281.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150406/ac625bc1/attachment.bin>


More information about the lldb-commits mailing list