[Lldb-commits] [lldb] Add the ability for Script based commands to specify their "repeat command" (PR #94823)

via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 7 17:46:52 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 435dd9746107e13c2ad019be3bd34815f7d2360d c2fea75364a0017be5e59020467d661bd00122ba -- lldb/include/lldb/Interpreter/CommandObject.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Commands/CommandObjectThread.cpp lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index 727ea0d963..d48dbcdd5a 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -296,7 +296,7 @@ public:
   ///
   /// \param[in] current_command_args
   ///    The command arguments.
-  ///    
+  ///
   /// \param[in] index
   ///    This is for internal use - it is how the completion request is tracked
   ///    in CommandObjectMultiword, and should otherwise be ignored.
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 934fd1837f..ff3306b853 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -480,9 +480,10 @@ public:
       const lldb_private::ExecutionContext &exe_ctx) {
     return false;
   }
-  
-  virtual std::optional<std::string> GetRepeatCommandForScriptedCommand(
-      StructuredData::GenericSP impl_obj_sp, Args &args) {
+
+  virtual std::optional<std::string>
+  GetRepeatCommandForScriptedCommand(StructuredData::GenericSP impl_obj_sp,
+                                     Args &args) {
     return std::nullopt;
   }
 
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 4144876c07..c63445b7c8 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1142,11 +1142,12 @@ public:
 
   ScriptedCommandSynchronicity GetSynchronicity() { return m_synchro; }
 
-  std::optional<std::string> GetRepeatCommand(Args &args, uint32_t index) override {
+  std::optional<std::string> GetRepeatCommand(Args &args,
+                                              uint32_t index) override {
     ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
     if (!scripter)
       return std::nullopt;
-      
+
     return scripter->GetRepeatCommandForScriptedCommand(m_cmd_obj_sp, args);
   }
 
@@ -1596,9 +1597,9 @@ private:
       options.ForEach(add_element);
       return error;
     }
-    
+
     size_t GetNumOptions() { return m_num_options; }
-    
+
   private:
     struct EnumValueStorage {
       EnumValueStorage() {
@@ -1837,14 +1838,15 @@ public:
 
   ScriptedCommandSynchronicity GetSynchronicity() { return m_synchro; }
 
-  std::optional<std::string> GetRepeatCommand(Args &args, uint32_t index) override {
+  std::optional<std::string> GetRepeatCommand(Args &args,
+                                              uint32_t index) override {
     ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
     if (!scripter)
       return std::nullopt;
-      
+
     return scripter->GetRepeatCommandForScriptedCommand(m_cmd_obj_sp, args);
   }
-  
+
   llvm::StringRef GetHelp() override {
     if (m_fetched_help_short)
       return CommandObjectParsed::GetHelp();
@@ -1875,16 +1877,15 @@ public:
       SetHelpLong(docstring);
     return CommandObjectParsed::GetHelpLong();
   }
-  
+
   Options *GetOptions() override {
     // CommandObjectParsed requires that a command with no options return
     // nullptr.
     if (m_options.GetNumOptions() == 0)
       return nullptr;
-    return &m_options; 
+    return &m_options;
   }
 
-
 protected:
   void DoExecute(Args &args,
                  CommandReturnObject &result) override {
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index c94fa7d82a..7ee5dc5b04 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -219,10 +219,10 @@ public:
                                   StructuredDataImpl &args_impl,
                                   lldb_private::CommandReturnObject &cmd_retobj,
                                   lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-  
+
   static std::optional<std::string>
   LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor,
-                                                 std::string &command);  
+                                                   std::string &command);
 
   static bool LLDBSwigPythonCallModuleInit(const char *python_module_name,
                                            const char *session_dictionary_name,
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index c621ee8381..bedb7c4189 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -2818,8 +2818,9 @@ bool ScriptInterpreterPythonImpl::RunScriptBasedParsedCommand(
   return ret_val;
 }
 
-std::optional<std::string> ScriptInterpreterPythonImpl::GetRepeatCommandForScriptedCommand(
-      StructuredData::GenericSP impl_obj_sp, Args &args) {
+std::optional<std::string>
+ScriptInterpreterPythonImpl::GetRepeatCommandForScriptedCommand(
+    StructuredData::GenericSP impl_obj_sp, Args &args) {
   if (!impl_obj_sp || !impl_obj_sp->IsValid())
     return std::nullopt;
 
@@ -2829,7 +2830,7 @@ std::optional<std::string> ScriptInterpreterPythonImpl::GetRepeatCommandForScrip
     return std::nullopt;
 
   std::optional<std::string> ret_val;
-  
+
   {
     Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
                    Locker::FreeLock);
@@ -2843,7 +2844,6 @@ std::optional<std::string> ScriptInterpreterPythonImpl::GetRepeatCommandForScrip
         static_cast<PyObject *>(impl_obj_sp->GetValue()), command);
   }
   return ret_val;
-      
 }
 
 /// In Python, a special attribute __doc__ contains the docstring for an object
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index f8c4873faf..0185a1a042 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -183,14 +183,15 @@ public:
       const lldb_private::ExecutionContext &exe_ctx) override;
 
   bool RunScriptBasedParsedCommand(
-    StructuredData::GenericSP impl_obj_sp, Args& args,
-    ScriptedCommandSynchronicity synchronicity,
-    lldb_private::CommandReturnObject &cmd_retobj, Status &error,
-    const lldb_private::ExecutionContext &exe_ctx) override;
-
-  std::optional<std::string> GetRepeatCommandForScriptedCommand(
-      StructuredData::GenericSP impl_obj_sp, Args &args) override;
-  
+      StructuredData::GenericSP impl_obj_sp, Args &args,
+      ScriptedCommandSynchronicity synchronicity,
+      lldb_private::CommandReturnObject &cmd_retobj, Status &error,
+      const lldb_private::ExecutionContext &exe_ctx) override;
+
+  std::optional<std::string>
+  GetRepeatCommandForScriptedCommand(StructuredData::GenericSP impl_obj_sp,
+                                     Args &args) override;
+
   Status GenerateFunction(const char *signature, const StringList &input,
                           bool is_callback) override;
 
diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index 03eb08af81..dce86accf9 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -212,7 +212,7 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
 
 std::optional<std::string>
 LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor,
-                                               std::string &command) {
+                                                 std::string &command) {
   return std::nullopt;
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/94823


More information about the lldb-commits mailing list