[Lldb-commits] [PATCH] D106553: [LLDB][GUI] Resolve paths in file/directory fields

Omar Emara via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 22 08:09:51 PDT 2021


OmarEmaraDev created this revision.
OmarEmaraDev added a reviewer: clayborg.
Herald added a reviewer: teemperor.
OmarEmaraDev requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch resolves the paths in the file/directory fields before
performing checks. Those checks are applied on the file system if
m_need_to_exist is true, so remote files can set this to false to avoid
performing host-side file system checks. Additionally, methods to get
a resolved and a direct file specs were added to be used by client code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106553

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1297,8 +1297,11 @@
     if (!IsSpecified())
       return;
 
-    FileSpec file(GetPath());
-    if (m_need_to_exist && !FileSystem::Instance().Exists(file)) {
+    if (!m_need_to_exist)
+      return;
+
+    FileSpec file = GetResolvedFileSpec();
+    if (!FileSystem::Instance().Exists(file)) {
       SetError("File doesn't exist!");
       return;
     }
@@ -1308,7 +1311,17 @@
     }
   }
 
-  // Returns the path of the file.
+  FileSpec GetFileSpec() {
+    FileSpec file_spec(GetPath());
+    return file_spec;
+  }
+
+  FileSpec GetResolvedFileSpec() {
+    FileSpec file_spec(GetPath());
+    FileSystem::Instance().Resolve(file_spec);
+    return file_spec;
+  }
+
   const std::string &GetPath() { return m_content; }
 
 protected:
@@ -1327,8 +1340,11 @@
     if (!IsSpecified())
       return;
 
-    FileSpec file(GetPath());
-    if (m_need_to_exist && !FileSystem::Instance().Exists(file)) {
+    if (!m_need_to_exist)
+      return;
+
+    FileSpec file = GetResolvedFileSpec();
+    if (!FileSystem::Instance().Exists(file)) {
       SetError("Directory doesn't exist!");
       return;
     }
@@ -1338,7 +1354,17 @@
     }
   }
 
-  // Returns the path of the file.
+  FileSpec GetFileSpec() {
+    FileSpec file_spec(GetPath());
+    return file_spec;
+  }
+
+  FileSpec GetResolvedFileSpec() {
+    FileSpec file_spec(GetPath());
+    FileSystem::Instance().Resolve(file_spec);
+    return file_spec;
+  }
+
   const std::string &GetPath() { return m_content; }
 
 protected:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106553.360820.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210722/0e07c3ee/attachment.bin>


More information about the lldb-commits mailing list