[Lldb-commits] [PATCH] D58648: Improve process launch comments for Windows

Adrian McCarthy via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 25 15:15:21 PST 2019

amccarth created this revision.
amccarth added a reviewer: zturner.

The existing comment about over-allocating the command line was incorrect.  The contents of the command line may be changed, but it's not necessary to over allocate.  The changes will be limited to the existing contents of the string (e.g., by replacing spaces with L'\0' to tokenize the command line).

Also added a comment explaining a possible cause of failure to save the next programmer some time when they try to debug a 64-bit process from a 32-bit LLDB.



Index: lldb/source/Host/windows/ProcessLauncherWindows.cpp
--- lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -104,17 +104,21 @@
   llvm::ConvertUTF8toWide(commandLine, wcommandLine);
+  // If the command line is empty, it's best to pass a null pointer to tell
+  // CreateProcessW to use the executable name as the command line.  If the
+  // command line is not empty, its contents may be modified by CreateProcessW.
+  WCHAR *pwcommandLine = wcommandLine.empty() ? nullptr : &wcommandLine[0];
-  wcommandLine.resize(PATH_MAX); // Needs to be over-allocated because
-                                 // CreateProcessW can modify it
   BOOL result = ::CreateProcessW(
-      wexecutable.c_str(), &wcommandLine[0], NULL, NULL, TRUE, flags, env_block,
+      wexecutable.c_str(), pwcommandLine, NULL, NULL, TRUE, flags, env_block,
       wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(),
       &startupinfo, &pi);
   if (!result) {
     // Call GetLastError before we make any other system calls.
     error.SetError(::GetLastError(), eErrorTypeWin32);
+    // Note that error 50 ("The request is not supported") will occur if you
+    // try debug a 64-bit inferior from a 32-bit LLDB.
   if (result) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58648.188259.patch
Type: text/x-patch
Size: 1485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190225/e2a4abb0/attachment.bin>

More information about the lldb-commits mailing list