[Lldb-commits] [lldb] be2a421 - [lldb] Fix SocketTest.DomainGetConnectURI on macOS by stripping more zeroes from getpeername result

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 27 08:35:00 PDT 2021


Author: Raphael Isemann
Date: 2021-09-27T17:34:45+02:00
New Revision: be2a4216fc5664ae465ec3dcc32fc3d40cecfdcd

URL: https://github.com/llvm/llvm-project/commit/be2a4216fc5664ae465ec3dcc32fc3d40cecfdcd
DIFF: https://github.com/llvm/llvm-project/commit/be2a4216fc5664ae465ec3dcc32fc3d40cecfdcd.diff

LOG: [lldb] Fix SocketTest.DomainGetConnectURI on macOS by stripping more zeroes from getpeername result

Apparently macOS is padding the name result with several padding zeroes at
the end. Just strip them all to pretend it's a C-string.

Thanks to Pavel for suggesting this fix.

Added: 
    

Modified: 
    lldb/source/Host/posix/DomainSocket.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 790458ee13d0..8138b6ff1dc4 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -143,8 +143,7 @@ std::string DomainSocket::GetSocketName() const {
   llvm::StringRef name(saddr_un.sun_path + GetNameOffset(),
                        sock_addr_len - offsetof(struct sockaddr_un, sun_path) -
                            GetNameOffset());
-  if (name.back() == '\0')
-    name = name.drop_back();
+  name = name.drop_while([](char c) { return c == '\0'; });
 
   return name.str();
 }


        


More information about the lldb-commits mailing list