[Lldb-commits] [PATCH] D70387: [LLDB] [Windows] Allow making subprocesses use the debugger's console with LLDB_INHERIT_CONSOLE=true

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 18 03:59:46 PST 2019


mstorsjo created this revision.
mstorsjo added reviewers: labath, zturner, amccarth, aleksandr.urakov.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

When running the lldb command line debugger in a console, it can be convenient to get the output of the debuggee inline in the same console.

The same behaviour also seems possible to enable by setting the eLaunchFlagDisableSTDIO flag somehow, but I wasn't able to figure out how to set that when calling the normal lldb.exe.

Also extend a nearby getenv() call to check for both "true" and "1".

There seems to be a number of different patterns for using getenv() in lldb; either just check for a variable being set (most common), or check for a number of different values. The check for LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE only used to check for the string "true", while e.g. the newly added check for LLDB_USE_LLDB_SERVER in source/Plugins/Process/Windows/Common/ProcessWindows.cpp checks for any of on/yes/1/true.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D70387

Files:
  lldb/source/Host/windows/ProcessLauncherWindows.cpp


Index: lldb/source/Host/windows/ProcessLauncherWindows.cpp
===================================================================
--- lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -80,7 +80,8 @@
   const char *hide_console_var =
       getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
   if (hide_console_var &&
-      llvm::StringRef(hide_console_var).equals_lower("true")) {
+      (llvm::StringRef(hide_console_var).equals_lower("true") ||
+       llvm::StringRef(hide_console_var).equals_lower("1"))) {
     startupinfo.dwFlags |= STARTF_USESHOWWINDOW;
     startupinfo.wShowWindow = SW_HIDE;
   }
@@ -89,7 +90,11 @@
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
     flags |= DEBUG_ONLY_THIS_PROCESS;
 
-  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO))
+  const char *inherit_console_var = getenv("LLDB_INHERIT_CONSOLE");
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO) ||
+      (inherit_console_var &&
+       (llvm::StringRef(inherit_console_var).equals_lower("true") ||
+        llvm::StringRef(inherit_console_var).equals_lower("1"))))
     flags &= ~CREATE_NEW_CONSOLE;
 
   LPVOID env_block = nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70387.229801.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191118/58448ff2/attachment.bin>


More information about the lldb-commits mailing list