[Lldb-commits] [lldb] r107736 - in /lldb/trunk: include/lldb/Interpreter/CommandInterpreter.h include/lldb/Interpreter/CommandObject.h source/Commands/CommandObjectSourceFile.h source/Interpreter/CommandInterpreter.cpp

Jim Ingham jingham at apple.com
Tue Jul 6 16:48:33 PDT 2010


Author: jingham
Date: Tue Jul  6 18:48:33 2010
New Revision: 107736

URL: http://llvm.org/viewvc/llvm-project?rev=107736&view=rev
Log:
Added a "GetRepeatCommand" to the command object.  The Interpreter uses this
instead of the last history item to provide a command for the "empty" command.
Use this in the source-file command to make <RETURN> continue the listing rather
than relist the first listing...

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

Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=107736&r1=107735&r2=107736&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Jul  6 18:48:33 2010
@@ -260,6 +260,7 @@
     VariableMap m_variables;
     OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias.
     std::vector<std::string> m_command_history;
+    std::string m_repeat_command;  // Stores the command that will be executed for an empty command string.
 };
 
 

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=107736&r1=107735&r2=107736&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Jul  6 18:48:33 2010
@@ -252,6 +252,21 @@
     //------------------------------------------------------------------
     const Flags&
     GetFlags() const;
+    
+    //------------------------------------------------------------------
+    /// Get the command that appropriate for a "repeat" of the current command.
+    ///
+    /// @param[in] current_command_line
+    ///    The complete current command line.
+    ///
+    /// @return
+    ///     NULL if the command is not to be repeated.
+    ///     Otherwise a pointer to the command to be repeated.    
+    //------------------------------------------------------------------
+    virtual const char *GetRepeatCommand (const char *current_command_line)
+    {
+        return current_command_line;
+    }
 
 protected:
     std::string m_cmd_name;

Modified: lldb/trunk/source/Commands/CommandObjectSourceFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSourceFile.h?rev=107736&r1=107735&r2=107736&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSourceFile.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSourceFile.h Tue Jul  6 18:48:33 2010
@@ -69,6 +69,13 @@
     virtual
     Options *
     GetOptions ();
+    
+    virtual const char *GetRepeatCommand (const char *current_command_line)
+    {
+        printf("\nReturning: \"%s\"\n", m_cmd_name.c_str());
+        return m_cmd_name.c_str();
+    }
+
 
 protected:
     CommandOptions m_options;

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=107736&r1=107735&r2=107736&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Jul  6 18:48:33 2010
@@ -627,7 +627,13 @@
         }
         else
         {
-            command_line = m_command_history.back().c_str();
+            command_line = m_repeat_command.c_str();
+            if (m_repeat_command.empty())
+            {
+                result.AppendError("");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
         }
         add_to_history = false;
     }
@@ -653,6 +659,18 @@
                         return false;
                 }
 
+                if (add_to_history)
+                {
+                    const char *repeat_command = command_obj->GetRepeatCommand(command_line);
+                    if (repeat_command)
+                        m_repeat_command.assign(repeat_command);
+                    else
+                        m_repeat_command.clear();
+                        
+                    m_command_history.push_back (command_line);
+                }
+
+
                 if (command_obj->WantsRawCommandString())
                 {
                     const char *stripped_command = ::strstr (command_line, command_cstr);
@@ -666,9 +684,6 @@
                 }
                 else
                 {
-                    if (add_to_history)
-                        m_command_history.push_back (command_line);
-
                     // Remove the command from the args.
                     command_args.Shift();
                     command_obj->ExecuteWithOptions (*this, command_args, result);





More information about the lldb-commits mailing list