[lldb] Improve corefile saving ergonomics
authorMed Ismail Bennani <ismail@bennani.ma>
Tue, 13 Jun 2023 18:21:08 +0000 (11:21 -0700)
committerMed Ismail Bennani <ismail@bennani.ma>
Tue, 13 Jun 2023 20:44:51 +0000 (13:44 -0700)
This patch improves the way the user can save the process state into a
corefile by adding completion handler that would provide tab completion
for the corefile path and also resolves the corefile path to expand
relative path.

Differential Revision: https://reviews.llvm.org/D152842

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
lldb/source/API/SBProcess.cpp
lldb/source/Commands/CommandObjectProcess.cpp

index a5491c6fa6997c1f4312cecf3ff8d69a572c0316..6050628a2e1f34ba94abb8c9c48fbdac89fe2a61 100644 (file)
@@ -1183,6 +1183,7 @@ lldb::SBError SBProcess::SaveCore(const char *file_name,
   }
 
   FileSpec core_file(file_name);
+  FileSystem::Instance().Resolve(core_file);
   error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style,
                                         flavor);
 
index 82d11687d377a629fa75e26d142b3535a761e435..ab047ee926c992000054c1ed455bb69ca346631c 100644 (file)
@@ -1306,6 +1306,13 @@ public:
 
   Options *GetOptions() override { return &m_options; }
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
+  }
+
   class CommandOptions : public Options {
   public:
     CommandOptions() = default;
@@ -1354,6 +1361,7 @@ protected:
     if (process_sp) {
       if (command.GetArgumentCount() == 1) {
         FileSpec output_file(command.GetArgumentAtIndex(0));
+        FileSystem::Instance().Resolve(output_file);
         SaveCoreStyle corefile_style = m_options.m_requested_save_core_style;
         Status error =
             PluginManager::SaveCore(process_sp, output_file, corefile_style,