[Lldb-commits] [lldb] r228859 - Make PipeWindows::CreateWithUniqueName() use GUIDs on Windows.

Zachary Turner zturner at google.com
Wed Feb 11 10:21:28 PST 2015


Author: zturner
Date: Wed Feb 11 12:21:28 2015
New Revision: 228859

URL: http://llvm.org/viewvc/llvm-project?rev=228859&view=rev
Log:
Make PipeWindows::CreateWithUniqueName() use GUIDs on Windows.

Patch by Adrian McCarthy
Differential Revision: http://reviews.llvm.org/D7509

Modified:
    lldb/trunk/cmake/LLDBDependencies.cmake
    lldb/trunk/source/Host/windows/PipeWindows.cpp

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=228859&r1=228858&r2=228859&view=diff
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Wed Feb 11 12:21:28 2015
@@ -69,6 +69,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows"
     lldbPluginProcessElfCore
     lldbPluginJITLoaderGDB
     Ws2_32
+    Rpcrt4
     )
 endif ()
 

Modified: lldb/trunk/source/Host/windows/PipeWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/PipeWindows.cpp?rev=228859&r1=228858&r2=228859&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/PipeWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/PipeWindows.cpp Wed Feb 11 12:21:28 2015
@@ -15,6 +15,7 @@
 
 #include <fcntl.h>
 #include <io.h>
+#include <rpc.h>
 
 #include <atomic>
 #include <string>
@@ -96,14 +97,23 @@ PipeWindows::CreateWithUniqueName(llvm::
 {
     llvm::SmallString<128> pipe_name;
     Error error;
-    do {
+    ::UUID unique_id;
+    RPC_CSTR unique_string;
+    RPC_STATUS status = ::UuidCreate(&unique_id);
+    if (status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY)
+        status = ::UuidToStringA(&unique_id, &unique_string);
+    if (status == RPC_S_OK)
+    {
         pipe_name = prefix;
         pipe_name += "-";
-        for (unsigned i = 0; i < 6; i++) {
-            pipe_name += "0123456789abcdef"[llvm::sys::Process::GetRandomNumber() & 15];
-        }
-        Error error = CreateNew(pipe_name, child_process_inherit);
-    } while (error.GetError() == ERROR_ALREADY_EXISTS);
+        pipe_name += reinterpret_cast<char *>(unique_string);
+        ::RpcStringFreeA(&unique_string);
+        error = CreateNew(pipe_name, child_process_inherit);
+    }
+    else
+    {
+        error.SetError(status, eErrorTypeWin32);
+    }
     if (error.Success())
         name = pipe_name;
     return error;





More information about the lldb-commits mailing list