Refine the 'watchpoint set' command to now require either the '-v' option (for watching of a variable) or
the '-e' option (for watching of an address) to be present.

Update some existing test cases with the required option and add some more test cases.

Since the '-v' option takes <variable-name> and the '-e' option takes <expr> as the command arg,
the existing infrastructure for generating the option usage can produce confusing help message,
like:

  watchpoint set -e [-w <watch-type>] [-x <byte-size>] <variable-name | expr>
  watchpoint set -v [-w <watch-type>] [-x <byte-size>] <variable-name | expr>

The solution adopted is to provide an extra member field to the struct CommandArgumentData called
(uint32_t)arg_opt_set_association, whose purpose is to link this particular argument data with some
option set(s).  Also modify the signature of CommandObject::GetFormattedCommandArguments() to:

  GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask = LLDB_OPT_SET_ALL)

it now takes an additional opt_set_mask which can be used to generate a filtered formatted command
args for help message.

Options::GenerateOptionUsage() impl is modified to call the GetFormattedCommandArguments() appropriately.
So that the help message now looks like:

  watchpoint set -e [-w <watch-type>] [-x <byte-size>] <expr>
  watchpoint set -v [-w <watch-type>] [-x <byte-size>] <variable-name>

rdar://problem/10703256


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150032 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 7624e86..5618b6c 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -535,15 +535,30 @@
     return false;
 }
 
+static CommandObject::CommandArgumentEntry
+OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry)
+{
+    CommandObject::CommandArgumentEntry ret_val;
+    for (unsigned i = 0; i < cmd_arg_entry.size(); ++i)
+        if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association)
+            ret_val.push_back(cmd_arg_entry[i]);
+    return ret_val;
+}
+
+// Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take
+// all the argument data into account.  On rare cases where some argument sticks
+// with certain option sets, this function returns the option set filtered args.
 void
-CommandObject::GetFormattedCommandArguments (Stream &str)
+CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask)
 {
     int num_args = m_arguments.size();
     for (int i = 0; i < num_args; ++i)
     {
         if (i > 0)
             str.Printf (" ");
-        CommandArgumentEntry arg_entry = m_arguments[i];
+        CommandArgumentEntry arg_entry =
+            opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i]
+                                             : OptSetFiltered(opt_set_mask, m_arguments[i]);
         int num_alternatives = arg_entry.size();
 
         if ((num_alternatives == 2)
diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp
index 159d00e..4a6afb4 100644
--- a/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -40,8 +40,8 @@
 static OptionDefinition
 g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a variable; or, with -x option, its pointee."},
-    { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch the pointee."}
+    { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Specify the type of watching to perform."},
+    { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a region."}
 };
 
 
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index 09b17a8..daf631f 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -437,6 +437,10 @@
             strm.Printf ("\n");
         strm.Indent (name);
 
+        // Different option sets may require different args.
+        StreamString args_str;
+        cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
+
         // First go through and print all options that take no arguments as
         // a single string. If a command has "-a" "-b" and "-c", this will show
         // up as [-abc]
@@ -556,12 +560,12 @@
             }
         }
         
-        if (arguments_str.GetSize() > 0)
+        if (args_str.GetSize() > 0)
         {
             if (cmd->WantsRawCommandString())
                 strm.Printf(" --");
             
-            strm.Printf (" %s", arguments_str.GetData());
+            strm.Printf (" %s", args_str.GetData());
         }
     }