[Lldb-commits] [lldb] r337395 - [windows] Use a well-known path for ComSpec if we fail to retrieve it

Stella Stamenova via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 18 08:21:54 PDT 2018

Author: stella.stamenova
Date: Wed Jul 18 08:21:54 2018
New Revision: 337395

URL: http://llvm.org/viewvc/llvm-project?rev=337395&view=rev
[windows] Use a well-known path for ComSpec if we fail to retrieve it

Summary: Right now we always try to retrieve ComSpec and if we fail, we give up. This rarely fails, but we can update the logic so that we fail even less frequently. Since there is a well-known path (albeit not always correct), try the path when we failed to retrieve it. Note that on other platforms, we generally just return a well-known path without any checking.

Reviewers: asmith, zturner, labath

Reviewed By: zturner, labath

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D49451


Modified: lldb/trunk/source/Host/windows/HostInfoWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostInfoWindows.cpp?rev=337395&r1=337394&r2=337395&view=diff
--- lldb/trunk/source/Host/windows/HostInfoWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/HostInfoWindows.cpp Wed Jul 18 08:21:54 2018
@@ -98,9 +98,14 @@ FileSpec HostInfoWindows::GetProgramFile
 FileSpec HostInfoWindows::GetDefaultShell() {
+  // Try to retrieve ComSpec from the environment. On the rare occasion
+  // that it fails, try a well-known path for ComSpec instead.
   std::string shell;
-  GetEnvironmentVar("ComSpec", shell);
-  return FileSpec(shell, false);
+  if (GetEnvironmentVar("ComSpec", shell))
+    return FileSpec(shell, false);
+  return FileSpec("C:\\Windows\\system32\\cmd.exe", false);
 bool HostInfoWindows::GetEnvironmentVar(const std::string &var_name,

More information about the lldb-commits mailing list