[Lldb-commits] [lldb] r287259 - Convert Platform, Process, and Connection functions to StringRef.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 17 13:15:14 PST 2016


Author: zturner
Date: Thu Nov 17 15:15:14 2016
New Revision: 287259

URL: http://llvm.org/viewvc/llvm-project?rev=287259&view=rev
Log:
Convert Platform, Process, and Connection functions to StringRef.

All tests pass on Linux and Windows.

Modified:
    lldb/trunk/include/lldb/Core/Connection.h
    lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h
    lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
    lldb/trunk/include/lldb/Host/windows/ConnectionGenericFileWindows.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Core/ConnectionSharedMemory.cpp
    lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
    lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
    lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
    lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/Connection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Connection.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Connection.h (original)
+++ lldb/trunk/include/lldb/Core/Connection.h Thu Nov 17 15:15:14 2016
@@ -66,7 +66,8 @@ public:
   ///
   /// @see Error& Communication::GetError ();
   //------------------------------------------------------------------
-  virtual lldb::ConnectionStatus Connect(const char *url, Error *error_ptr) = 0;
+  virtual lldb::ConnectionStatus Connect(llvm::StringRef url,
+                                         Error *error_ptr) = 0;
 
   //------------------------------------------------------------------
   /// Disconnect the communications connection if one is currently

Modified: lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h Thu Nov 17 15:15:14 2016
@@ -32,7 +32,7 @@ public:
   virtual lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec,
                                                 Error *error_ptr);
 
-  lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
+  lldb::ConnectionStatus Connect(llvm::StringRef s, Error *error_ptr) override;
 
   lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
 

Modified: lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h (original)
+++ lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h Thu Nov 17 15:15:14 2016
@@ -53,7 +53,7 @@ public:
 
   bool IsConnected() const override;
 
-  lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
+  lldb::ConnectionStatus Connect(llvm::StringRef s, Error *error_ptr) override;
 
   lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
 
@@ -82,21 +82,21 @@ protected:
 
   void CloseCommandPipe();
 
-  lldb::ConnectionStatus SocketListenAndAccept(const char *host_and_port,
+  lldb::ConnectionStatus SocketListenAndAccept(llvm::StringRef host_and_port,
                                                Error *error_ptr);
 
-  lldb::ConnectionStatus ConnectTCP(const char *host_and_port,
+  lldb::ConnectionStatus ConnectTCP(llvm::StringRef host_and_port,
                                     Error *error_ptr);
 
-  lldb::ConnectionStatus ConnectUDP(const char *args, Error *error_ptr);
+  lldb::ConnectionStatus ConnectUDP(llvm::StringRef args, Error *error_ptr);
 
-  lldb::ConnectionStatus NamedSocketConnect(const char *socket_name,
+  lldb::ConnectionStatus NamedSocketConnect(llvm::StringRef socket_name,
                                             Error *error_ptr);
 
-  lldb::ConnectionStatus NamedSocketAccept(const char *socket_name,
+  lldb::ConnectionStatus NamedSocketAccept(llvm::StringRef socket_name,
                                            Error *error_ptr);
 
-  lldb::ConnectionStatus UnixAbstractSocketConnect(const char *socket_name,
+  lldb::ConnectionStatus UnixAbstractSocketConnect(llvm::StringRef socket_name,
                                                    Error *error_ptr);
 
   lldb::IOObjectSP m_read_sp;

Modified: lldb/trunk/include/lldb/Host/windows/ConnectionGenericFileWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/ConnectionGenericFileWindows.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/windows/ConnectionGenericFileWindows.h (original)
+++ lldb/trunk/include/lldb/Host/windows/ConnectionGenericFileWindows.h Thu Nov 17 15:15:14 2016
@@ -28,7 +28,7 @@ public:
 
   bool IsConnected() const override;
 
-  lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
+  lldb::ConnectionStatus Connect(llvm::StringRef s, Error *error_ptr) override;
 
   lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
 

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Thu Nov 17 15:15:14 2016
@@ -413,8 +413,8 @@ public:
                                // target, else use existing one
                Error &error);
 
-  virtual lldb::ProcessSP ConnectProcess(const char *connect_url,
-                                         const char *plugin_name,
+  virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+                                         llvm::StringRef plugin_name,
                                          lldb_private::Debugger &debugger,
                                          lldb_private::Target *target,
                                          lldb_private::Error &error);

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Nov 17 15:15:14 2016
@@ -691,7 +691,7 @@ public:
   /// @see Process::CanDebug ()
   //------------------------------------------------------------------
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
-                                    const char *plugin_name,
+                                    llvm::StringRef plugin_name,
                                     lldb::ListenerSP listener_sp,
                                     const FileSpec *crash_file_path);
 
@@ -882,7 +882,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error ConnectRemote(Stream *strm, const char *remote_url);
+  virtual Error ConnectRemote(Stream *strm, llvm::StringRef remote_url);
 
   bool GetShouldDetach() const { return m_should_detach; }
 
@@ -1107,7 +1107,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error DoConnectRemote(Stream *strm, const char *remote_url) {
+  virtual Error DoConnectRemote(Stream *strm, llvm::StringRef remote_url) {
     Error error;
     error.SetErrorString("remote connections are not supported");
     return error;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Nov 17 15:15:14 2016
@@ -512,7 +512,7 @@ public:
   void Dump(Stream *s, lldb::DescriptionLevel description_level);
 
   const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener,
-                                       const char *plugin_name,
+                                       llvm::StringRef plugin_name,
                                        const FileSpec *crash_file);
 
   const lldb::ProcessSP &GetProcessSP() const;

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Nov 17 15:15:14 2016
@@ -186,7 +186,7 @@ SBProcess SBTarget::LoadCore(const char
   if (target_sp) {
     FileSpec filespec(core_file, true);
     ProcessSP process_sp(target_sp->CreateProcess(
-        target_sp->GetDebugger().GetListener(), NULL, &filespec));
+        target_sp->GetDebugger().GetListener(), "", &filespec));
     if (process_sp) {
       process_sp->LoadCore();
       sb_process.SetSP(process_sp);

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Nov 17 15:15:14 2016
@@ -377,7 +377,7 @@ protected:
             target_sp->GetExecutableSearchPaths().Append(core_file_dir);
 
             ProcessSP process_sp(target_sp->CreateProcess(
-                m_interpreter.GetDebugger().GetListener(), nullptr,
+                m_interpreter.GetDebugger().GetListener(), llvm::StringRef(),
                 &core_file));
 
             if (process_sp) {

Modified: lldb/trunk/source/Core/ConnectionSharedMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionSharedMemory.cpp (original)
+++ lldb/trunk/source/Core/ConnectionSharedMemory.cpp Thu Nov 17 15:15:14 2016
@@ -44,7 +44,7 @@ ConnectionSharedMemory::~ConnectionShare
 
 bool ConnectionSharedMemory::IsConnected() const { return m_fd >= 0; }
 
-ConnectionStatus ConnectionSharedMemory::Connect(const char *s,
+ConnectionStatus ConnectionSharedMemory::Connect(llvm::StringRef s,
                                                  Error *error_ptr) {
   //    if (s && s[0])
   //    {

Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp Thu Nov 17 15:15:14 2016
@@ -68,12 +68,13 @@ const char *ConnectionFileDescriptor::FI
 
 namespace {
 
-const char *GetURLAddress(const char *url, const char *scheme) {
-  const auto prefix = std::string(scheme) + "://";
-  if (strstr(url, prefix.c_str()) != url)
-    return nullptr;
-
-  return url + prefix.size();
+llvm::Optional<llvm::StringRef> GetURLAddress(llvm::StringRef url,
+                                              llvm::StringRef scheme) {
+  if (!url.consume_front(scheme))
+    return llvm::None;
+  if (!url.consume_front("://"))
+    return llvm::None;
+  return url;
 }
 }
 
@@ -153,48 +154,47 @@ bool ConnectionFileDescriptor::IsConnect
          (m_write_sp && m_write_sp->IsValid());
 }
 
-ConnectionStatus ConnectionFileDescriptor::Connect(const char *s,
+ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
                                                    Error *error_ptr) {
   std::lock_guard<std::recursive_mutex> guard(m_mutex);
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
   if (log)
     log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')",
-                static_cast<void *>(this), s);
+                static_cast<void *>(this), path.str().c_str());
 
   OpenCommandPipe();
 
-  if (s && s[0]) {
-    const char *addr = nullptr;
-    if ((addr = GetURLAddress(s, LISTEN_SCHEME))) {
+  if (!path.empty()) {
+    llvm::Optional<llvm::StringRef> addr;
+    if ((addr = GetURLAddress(path, LISTEN_SCHEME))) {
       // listen://HOST:PORT
-      return SocketListenAndAccept(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, ACCEPT_SCHEME))) {
+      return SocketListenAndAccept(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, ACCEPT_SCHEME))) {
       // unix://SOCKNAME
-      return NamedSocketAccept(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, UNIX_ACCEPT_SCHEME))) {
+      return NamedSocketAccept(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, UNIX_ACCEPT_SCHEME))) {
       // unix://SOCKNAME
-      return NamedSocketAccept(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, CONNECT_SCHEME))) {
-      return ConnectTCP(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, TCP_CONNECT_SCHEME))) {
-      return ConnectTCP(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, UDP_SCHEME))) {
-      return ConnectUDP(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, UNIX_CONNECT_SCHEME))) {
+      return NamedSocketAccept(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, CONNECT_SCHEME))) {
+      return ConnectTCP(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, TCP_CONNECT_SCHEME))) {
+      return ConnectTCP(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, UDP_SCHEME))) {
+      return ConnectUDP(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, UNIX_CONNECT_SCHEME))) {
       // unix-connect://SOCKNAME
-      return NamedSocketConnect(addr, error_ptr);
-    } else if ((addr = GetURLAddress(s, UNIX_ABSTRACT_CONNECT_SCHEME))) {
+      return NamedSocketConnect(*addr, error_ptr);
+    } else if ((addr = GetURLAddress(path, UNIX_ABSTRACT_CONNECT_SCHEME))) {
       // unix-abstract-connect://SOCKNAME
-      return UnixAbstractSocketConnect(addr, error_ptr);
+      return UnixAbstractSocketConnect(*addr, error_ptr);
     }
 #ifndef LLDB_DISABLE_POSIX
-    else if ((addr = GetURLAddress(s, FD_SCHEME))) {
+    else if ((addr = GetURLAddress(path, FD_SCHEME))) {
       // Just passing a native file descriptor within this current process
       // that is already opened (possibly from a service or other source).
-      bool success = false;
-      int fd = StringConvert::ToSInt32(addr, -1, 0, &success);
+      int fd = -1;
 
-      if (success) {
+      if (!addr->getAsInteger(0, fd)) {
         // We have what looks to be a valid file descriptor, but we
         // should make sure it is. We currently are doing this by trying to
         // get the flags from the file descriptor and making sure it
@@ -203,7 +203,8 @@ ConnectionStatus ConnectionFileDescripto
         int flags = ::fcntl(fd, F_GETFL, 0);
         if (flags == -1 || errno == EBADF) {
           if (error_ptr)
-            error_ptr->SetErrorStringWithFormat("stale file descriptor: %s", s);
+            error_ptr->SetErrorStringWithFormat("stale file descriptor: %s",
+                                                path.str().c_str());
           m_read_sp.reset();
           m_write_sp.reset();
           return eConnectionStatusError;
@@ -232,23 +233,23 @@ ConnectionStatus ConnectionFileDescripto
             m_read_sp.reset(new File(fd, false));
             m_write_sp.reset(new File(fd, false));
           }
-          m_uri.assign(addr);
+          m_uri = *addr;
           return eConnectionStatusSuccess;
         }
       }
 
       if (error_ptr)
         error_ptr->SetErrorStringWithFormat("invalid file descriptor: \"%s\"",
-                                            s);
+                                            path.str().c_str());
       m_read_sp.reset();
       m_write_sp.reset();
       return eConnectionStatusError;
-    } else if ((addr = GetURLAddress(s, FILE_SCHEME))) {
+    } else if ((addr = GetURLAddress(path, FILE_SCHEME))) {
+      std::string addr_str = addr->str();
       // file:///PATH
-      const char *path = addr;
       int fd = -1;
       do {
-        fd = ::open(path, O_RDWR);
+        fd = ::open(addr_str.c_str(), O_RDWR);
       } while (fd == -1 && errno == EINTR);
 
       if (fd == -1) {
@@ -290,7 +291,7 @@ ConnectionStatus ConnectionFileDescripto
 #endif
     if (error_ptr)
       error_ptr->SetErrorStringWithFormat("unsupported connection URL: '%s'",
-                                          s);
+                                          path.str().c_str());
     return eConnectionStatusError;
   }
   if (error_ptr)
@@ -655,7 +656,7 @@ ConnectionStatus ConnectionFileDescripto
 }
 
 ConnectionStatus
-ConnectionFileDescriptor::NamedSocketAccept(const char *socket_name,
+ConnectionFileDescriptor::NamedSocketAccept(llvm::StringRef socket_name,
                                             Error *error_ptr) {
   Socket *socket = nullptr;
   Error error =
@@ -672,7 +673,7 @@ ConnectionFileDescriptor::NamedSocketAcc
 }
 
 ConnectionStatus
-ConnectionFileDescriptor::NamedSocketConnect(const char *socket_name,
+ConnectionFileDescriptor::NamedSocketConnect(llvm::StringRef socket_name,
                                              Error *error_ptr) {
   Socket *socket = nullptr;
   Error error =
@@ -689,7 +690,7 @@ ConnectionFileDescriptor::NamedSocketCon
 }
 
 lldb::ConnectionStatus
-ConnectionFileDescriptor::UnixAbstractSocketConnect(const char *socket_name,
+ConnectionFileDescriptor::UnixAbstractSocketConnect(llvm::StringRef socket_name,
                                                     Error *error_ptr) {
   Socket *socket = nullptr;
   Error error = Socket::UnixAbstractConnect(socket_name,
@@ -706,7 +707,7 @@ ConnectionFileDescriptor::UnixAbstractSo
 }
 
 ConnectionStatus
-ConnectionFileDescriptor::SocketListenAndAccept(const char *s,
+ConnectionFileDescriptor::SocketListenAndAccept(llvm::StringRef s,
                                                 Error *error_ptr) {
   m_port_predicate.SetValue(0, eBroadcastNever);
 
@@ -734,7 +735,7 @@ ConnectionFileDescriptor::SocketListenAn
   return eConnectionStatusSuccess;
 }
 
-ConnectionStatus ConnectionFileDescriptor::ConnectTCP(const char *s,
+ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s,
                                                       Error *error_ptr) {
   Socket *socket = nullptr;
   Error error = Socket::TcpConnect(s, m_child_processes_inherit, socket);
@@ -749,7 +750,7 @@ ConnectionStatus ConnectionFileDescripto
   return eConnectionStatusSuccess;
 }
 
-ConnectionStatus ConnectionFileDescriptor::ConnectUDP(const char *s,
+ConnectionStatus ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s,
                                                       Error *error_ptr) {
   Socket *send_socket = nullptr;
   Socket *recv_socket = nullptr;

Modified: lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp Thu Nov 17 15:15:14 2016
@@ -92,17 +92,17 @@ bool ConnectionGenericFile::IsConnected(
   return m_file && (m_file != INVALID_HANDLE_VALUE);
 }
 
-lldb::ConnectionStatus ConnectionGenericFile::Connect(const char *s,
+lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path,
                                                       Error *error_ptr) {
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
   if (log)
     log->Printf("%p ConnectionGenericFile::Connect (url = '%s')",
-                static_cast<void *>(this), s);
+                static_cast<void *>(this), path.str().c_str());
 
-  if (strstr(s, "file://") != s) {
+  if (!path.consume_front("file://")) {
     if (error_ptr)
       error_ptr->SetErrorStringWithFormat("unsupported connection URL: '%s'",
-                                          s);
+                                          path.str().c_str());
     return eConnectionStatusError;
   }
 
@@ -112,13 +112,10 @@ lldb::ConnectionStatus ConnectionGeneric
       return status;
   }
 
-  // file://PATH
-  const char *path = s + strlen("file://");
   // Open the file for overlapped access.  If it does not exist, create it.  We
-  // open it overlapped
-  // so that we can issue asynchronous reads and then use WaitForMultipleObjects
-  // to allow the read
-  // to be interrupted by an event object.
+  // open it overlapped so that we can issue asynchronous reads and then use
+  // WaitForMultipleObjects to allow the read to be interrupted by an event
+  // object.
   std::wstring wpath;
   if (!llvm::ConvertUTF8toWide(path, wpath)) {
     if (error_ptr)
@@ -135,7 +132,7 @@ lldb::ConnectionStatus ConnectionGeneric
   }
 
   m_owns_file = true;
-  m_uri.assign(s);
+  m_uri.assign(path);
   return eConnectionStatusSuccess;
 }
 

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp Thu Nov 17 15:15:14 2016
@@ -203,7 +203,7 @@ Error PlatformAndroidRemoteGDBServer::Ma
 }
 
 lldb::ProcessSP PlatformAndroidRemoteGDBServer::ConnectProcess(
-    const char *connect_url, const char *plugin_name,
+    llvm::StringRef connect_url, llvm::StringRef plugin_name,
     lldb_private::Debugger &debugger, lldb_private::Target *target,
     lldb_private::Error &error) {
   // We don't have the pid of the remote gdbserver when it isn't started by us
@@ -216,7 +216,8 @@ lldb::ProcessSP PlatformAndroidRemoteGDB
   int remote_port;
   llvm::StringRef scheme, host, path;
   if (!UriParser::Parse(connect_url, scheme, host, remote_port, path)) {
-    error.SetErrorStringWithFormat("Invalid URL: %s", connect_url);
+    error.SetErrorStringWithFormat("Invalid URL: %s",
+                                   connect_url.str().c_str());
     return nullptr;
   }
 
@@ -227,6 +228,6 @@ lldb::ProcessSP PlatformAndroidRemoteGDB
   if (error.Fail())
     return nullptr;
 
-  return PlatformRemoteGDBServer::ConnectProcess(
-      new_connect_url.c_str(), plugin_name, debugger, target, error);
+  return PlatformRemoteGDBServer::ConnectProcess(new_connect_url, plugin_name,
+                                                 debugger, target, error);
 }

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h Thu Nov 17 15:15:14 2016
@@ -37,8 +37,8 @@ public:
 
   Error DisconnectRemote() override;
 
-  lldb::ProcessSP ConnectProcess(const char *connect_url,
-                                 const char *plugin_name,
+  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+                                 llvm::StringRef plugin_name,
                                  lldb_private::Debugger &debugger,
                                  lldb_private::Target *target,
                                  lldb_private::Error &error) override;

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Thu Nov 17 15:15:14 2016
@@ -836,8 +836,8 @@ Error PlatformPOSIX::UnloadImage(lldb_pr
   return Error();
 }
 
-lldb::ProcessSP PlatformPOSIX::ConnectProcess(const char *connect_url,
-                                              const char *plugin_name,
+lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url,
+                                              llvm::StringRef plugin_name,
                                               lldb_private::Debugger &debugger,
                                               lldb_private::Target *target,
                                               lldb_private::Error &error) {

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h Thu Nov 17 15:15:14 2016
@@ -156,8 +156,8 @@ public:
   lldb_private::Error UnloadImage(lldb_private::Process *process,
                                   uint32_t image_token) override;
 
-  lldb::ProcessSP ConnectProcess(const char *connect_url,
-                                 const char *plugin_name,
+  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+                                 llvm::StringRef plugin_name,
                                  lldb_private::Debugger &debugger,
                                  lldb_private::Target *target,
                                  lldb_private::Error &error) override;

Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Thu Nov 17 15:15:14 2016
@@ -852,7 +852,7 @@ std::string PlatformRemoteGDBServer::Mak
 }
 
 lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
-    const char *connect_url, const char *plugin_name,
+    llvm::StringRef connect_url, llvm::StringRef plugin_name,
     lldb_private::Debugger &debugger, lldb_private::Target *target,
     lldb_private::Error &error) {
   if (!IsRemote() || !IsConnected()) {
@@ -869,8 +869,7 @@ size_t PlatformRemoteGDBServer::ConnectT
   GetPendingGdbServerList(connection_urls);
 
   for (size_t i = 0; i < connection_urls.size(); ++i) {
-    ConnectProcess(connection_urls[i].c_str(), nullptr, debugger, nullptr,
-                   error);
+    ConnectProcess(connection_urls[i].c_str(), "", debugger, nullptr, error);
     if (error.Fail())
       return i; // We already connected to i process succsessfully
   }

Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Thu Nov 17 15:15:14 2016
@@ -162,8 +162,8 @@ public:
 
   const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
 
-  lldb::ProcessSP ConnectProcess(const char *connect_url,
-                                 const char *plugin_name,
+  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+                                 llvm::StringRef plugin_name,
                                  lldb_private::Debugger &debugger,
                                  lldb_private::Target *target,
                                  lldb_private::Error &error) override;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Nov 17 15:15:14 2016
@@ -651,7 +651,8 @@ Error ProcessGDBRemote::WillAttachToProc
   return WillLaunchOrAttach();
 }
 
-Error ProcessGDBRemote::DoConnectRemote(Stream *strm, const char *remote_url) {
+Error ProcessGDBRemote::DoConnectRemote(Stream *strm,
+                                        llvm::StringRef remote_url) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
   Error error(WillLaunchOrAttach());
 
@@ -695,15 +696,15 @@ Error ProcessGDBRemote::DoConnectRemote(
       if (state != eStateInvalid) {
         SetPrivateState(state);
       } else
-        error.SetErrorStringWithFormat("Process %" PRIu64
-                                       " was reported after connecting to "
-                                       "'%s', but state was not stopped: %s",
-                                       pid, remote_url, StateAsCString(state));
+        error.SetErrorStringWithFormat(
+            "Process %" PRIu64 " was reported after connecting to "
+            "'%s', but state was not stopped: %s",
+            pid, remote_url.str().c_str(), StateAsCString(state));
     } else
       error.SetErrorStringWithFormat("Process %" PRIu64
                                      " was reported after connecting to '%s', "
                                      "but no stop reply packet was received",
-                                     pid, remote_url);
+                                     pid, remote_url.str().c_str());
   }
 
   if (log)
@@ -963,15 +964,15 @@ Error ProcessGDBRemote::DoLaunch(Module
   return error;
 }
 
-Error ProcessGDBRemote::ConnectToDebugserver(const char *connect_url) {
+Error ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
   Error error;
   // Only connect if we have a valid connect URL
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
-  if (connect_url && connect_url[0]) {
+  if (!connect_url.empty()) {
     if (log)
       log->Printf("ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
-                  connect_url);
+                  connect_url.str().c_str());
     std::unique_ptr<ConnectionFileDescriptor> conn_ap(
         new ConnectionFileDescriptor());
     if (conn_ap.get()) {
@@ -3353,7 +3354,7 @@ Error ProcessGDBRemote::LaunchAndConnect
     if (m_gdb_comm.IsConnected()) {
       // Finish the connection process by doing the handshake without connecting
       // (send NULL URL)
-      ConnectToDebugserver(NULL);
+      ConnectToDebugserver("");
     } else {
       error.SetErrorString("connection failed");
     }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Thu Nov 17 15:15:14 2016
@@ -89,7 +89,7 @@ public:
   Error WillAttachToProcessWithName(const char *process_name,
                                     bool wait_for_launch) override;
 
-  Error DoConnectRemote(Stream *strm, const char *remote_url) override;
+  Error DoConnectRemote(Stream *strm, llvm::StringRef remote_url) override;
 
   Error WillLaunchOrAttach();
 
@@ -379,7 +379,7 @@ protected:
 
   void DidLaunchOrAttach(ArchSpec &process_arch);
 
-  Error ConnectToDebugserver(const char *host_port);
+  Error ConnectToDebugserver(llvm::StringRef host_port);
 
   const char *GetDispatchQueueNameForThread(lldb::addr_t thread_dispatch_qaddr,
                                             std::string &dispatch_queue_name);

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Thu Nov 17 15:15:14 2016
@@ -1758,8 +1758,8 @@ Error Platform::UnloadImage(lldb_private
   return Error("UnloadImage is not supported on the current platform");
 }
 
-lldb::ProcessSP Platform::ConnectProcess(const char *connect_url,
-                                         const char *plugin_name,
+lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
+                                         llvm::StringRef plugin_name,
                                          lldb_private::Debugger &debugger,
                                          lldb_private::Target *target,
                                          lldb_private::Error &error) {

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Nov 17 15:15:14 2016
@@ -662,14 +662,15 @@ void ProcessInstanceInfoMatch::Clear() {
   m_match_all_users = false;
 }
 
-ProcessSP Process::FindPlugin(lldb::TargetSP target_sp, const char *plugin_name,
+ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
+                              llvm::StringRef plugin_name,
                               ListenerSP listener_sp,
                               const FileSpec *crash_file_path) {
   static uint32_t g_process_unique_id = 0;
 
   ProcessSP process_sp;
   ProcessCreateInstance create_callback = nullptr;
-  if (plugin_name) {
+  if (!plugin_name.empty()) {
     ConstString const_plugin_name(plugin_name);
     create_callback =
         PluginManager::GetProcessCreateCallbackForPluginName(const_plugin_name);
@@ -3245,13 +3246,12 @@ void Process::CompleteAttach() {
   m_stop_info_override_callback = process_arch.GetStopInfoOverrideCallback();
 }
 
-Error Process::ConnectRemote(Stream *strm, const char *remote_url) {
+Error Process::ConnectRemote(Stream *strm, llvm::StringRef remote_url) {
   m_abi_sp.reset();
   m_process_input_reader.reset();
 
   // Find the process and its architecture.  Make sure it matches the
-  // architecture
-  // of the current Target, and if not adjust it.
+  // architecture of the current Target, and if not adjust it.
 
   Error error(DoConnectRemote(strm, remote_url));
   if (error.Success()) {

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=287259&r1=287258&r2=287259&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Nov 17 15:15:14 2016
@@ -170,7 +170,7 @@ void Target::DeleteCurrentProcess() {
 }
 
 const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp,
-                                             const char *plugin_name,
+                                             llvm::StringRef plugin_name,
                                              const FileSpec *crash_file) {
   DeleteCurrentProcess();
   m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name,




More information about the lldb-commits mailing list