[Lldb-commits] [lldb] r140221 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h source/Commands/CommandObjectBreakpoint.cpp source/Interpreter/CommandObject.cpp

Johnny Chen johnny.chen at apple.com
Tue Sep 20 18:00:02 PDT 2011


Author: johnny
Date: Tue Sep 20 20:00:02 2011
New Revision: 140221

URL: http://llvm.org/viewvc/llvm-project?rev=140221&view=rev
Log:
A little refactoring of the way to add break IDs or ID ranges as command argument data
to the command argument entry.  Add a static helper function:

    CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg)

to be used from CommandObjectBreakpoint.cpp.  The helper function could also be useful
for commands in the future to manipulate watchpoints.

Modified:
    lldb/trunk/include/lldb/Interpreter/CommandObject.h
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=140221&r1=140220&r2=140221&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Sep 20 20:00:02 2011
@@ -361,6 +361,12 @@
     bool m_is_alias;
     Flags       m_flags;
     std::vector<CommandArgumentEntry> m_arguments;
+
+    // Helper function to populate IDs or ID ranges as the command argument data
+    // to the specified command argument entry.
+    static void
+    AddIDsArgumentData(CommandArgumentEntry &arg);
+
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140221&r1=140220&r2=140221&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Sep 20 20:00:02 2011
@@ -826,22 +826,7 @@
                    NULL)
 {
     CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-    CommandArgumentData bp_id_range_arg;
-
-    // Create the first variant for the first (and only) argument for this command.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatOptional;
-
-    // Create the second variant for the first (and only) argument for this command.
-    bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
-    bp_id_range_arg.arg_repetition = eArgRepeatOptional;
-
-    // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
-    // Push both variants into the entry for the first argument for this command.
-    arg.push_back (bp_id_arg);         
-    arg.push_back (bp_id_range_arg);    
-    
+    CommandObject::AddIDsArgumentData(arg);
     // Add the entry for the first argument for this command to the object's arguments vector.
     m_arguments.push_back (arg);   
 }
@@ -942,22 +927,7 @@
                    NULL)
 {
     CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-    CommandArgumentData bp_id_range_arg;
-
-    // Create the first variant for the first (and only) argument for this command.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatOptional;
-
-    // Create the second variant for the first (and only) argument for this command.
-    bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
-    bp_id_range_arg.arg_repetition = eArgRepeatOptional;
-
-    // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
-    // Push both variants into the entry for the first argument for this command.
-    arg.push_back (bp_id_arg);         
-    arg.push_back (bp_id_range_arg);    
-    
+    CommandObject::AddIDsArgumentData(arg);
     // Add the entry for the first argument for this command to the object's arguments vector.
     m_arguments.push_back (arg);   
 }
@@ -1238,22 +1208,7 @@
                    NULL)
 {
     CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-    CommandArgumentData bp_id_range_arg;
-
-    // Create the first variant for the first (and only) argument for this command.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatOptional;
-
-    // Create the second variant for the first (and only) argument for this command.
-    bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
-    bp_id_range_arg.arg_repetition = eArgRepeatOptional;
-
-    // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
-    // Push both variants into the entry for the first argument for this command.
-    arg.push_back (bp_id_arg);         
-    arg.push_back (bp_id_range_arg);    
-    
+    CommandObject::AddIDsArgumentData(arg);
     // Add the entry for the first argument for this command to the object's arguments vector.
     m_arguments.push_back (arg);   
 }
@@ -1513,22 +1468,7 @@
     m_options (interpreter)
 {
     CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-    CommandArgumentData bp_id_range_arg;
-
-    // Create the first variant for the first (and only) argument for this command.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatPlain;
-
-    // Create the second variant for the first (and only) argument for this command.
-    bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
-    bp_id_range_arg.arg_repetition = eArgRepeatPlain;
-
-    // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
-    // Push both variants into the entry for the first argument for this command.
-    arg.push_back (bp_id_arg);         
-    arg.push_back (bp_id_range_arg);    
-    
+    CommandObject::AddIDsArgumentData(arg);
     // Add the entry for the first argument for this command to the object's arguments vector.
     m_arguments.push_back (arg);   
 }

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140221&r1=140220&r2=140221&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Sep 20 20:00:02 2011
@@ -743,6 +743,26 @@
     " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory).";
 }
 
+void
+CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg)
+{
+    CommandArgumentData id_arg;
+    CommandArgumentData id_range_arg;
+
+    // Create the first variant for the first (and only) argument for this command.
+    id_arg.arg_type = eArgTypeBreakpointID;
+    id_arg.arg_repetition = eArgRepeatOptional;
+
+    // Create the second variant for the first (and only) argument for this command.
+    id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+    id_range_arg.arg_repetition = eArgRepeatOptional;
+
+    // The first (and only) argument for this command could be either a id or a id_range.
+    // Push both variants into the entry for the first argument for this command.
+    arg.push_back(id_arg);
+    arg.push_back(id_range_arg);
+}
+
 const char * 
 CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
 {





More information about the lldb-commits mailing list