[Lldb-commits] [lldb] r139524 - in /lldb/trunk/source: Commands/CommandObjectFrame.cpp Interpreter/OptionGroupWatchpoint.cpp

Johnny Chen johnny.chen at apple.com
Mon Sep 12 12:12:06 PDT 2011


Author: johnny
Date: Mon Sep 12 14:12:06 2011
New Revision: 139524

URL: http://llvm.org/viewvc/llvm-project?rev=139524&view=rev
Log:
Fix a bug in OptionGroupWatchpoint.cpp where the '-w' option arg parsing result was not checked
to effect an early error return.

Plus add logic to 'frame variable' command object to check that when watchpoint option is on,
only one variable with exact name (no regex) is specified as the sole command arg.

Modified:
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139524&r1=139523&r2=139524&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 12 14:12:06 2011
@@ -414,6 +414,22 @@
             
             if (variable_list)
             {
+                // If watching a variable, there are certain restrictions to be followed.
+                if (m_option_watchpoint.watch_variable)
+                {
+                    if (command.GetArgumentCount() != 1) {
+                        result.GetErrorStream().Printf("error: specify exactly one variable when using the '-w' option\n");
+                        result.SetStatus(eReturnStatusFailed);
+                        return false;
+                    } else if (m_option_variable.use_regex) {
+                        result.GetErrorStream().Printf("error: specify your variable name exactly (no regex) when using the '-w' option\n");
+                        result.SetStatus(eReturnStatusFailed);
+                        return false;
+                    }
+
+                    // Things have checked out ok...
+                    // m_option_watchpoint.watch_mode specifies the mode for watching.
+                }
                 if (command.GetArgumentCount() > 0)
                 {
                     VariableList regex_var_list;

Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=139524&r1=139523&r2=139524&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Mon Sep 12 14:12:06 2011
@@ -55,9 +55,10 @@
     switch (short_option)
     {
         case 'w': {
-            watch_variable = false;
             OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
             watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable);
+            if (!watch_variable)
+                error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg);
             break;
         }
         default:





More information about the lldb-commits mailing list