LLDB mainline
ProcessLauncherWindows.cpp File Reference
#include "lldb/Host/windows/ProcessLauncherWindows.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/ProcessLaunchInfo.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/WindowsError.h"
#include <string>
#include <vector>

Go to the source code of this file.

Functions

static std::vector< wchar_t > CreateEnvironmentBufferW (const Environment &env)
 Create a UTF-16 environment block to use with CreateProcessW.
static llvm::ErrorOr< std::wstring > GetFlattenedWindowsCommandStringW (Args args)
 Flattens an Args object into a Windows command-line wide string.

Function Documentation

◆ CreateEnvironmentBufferW()

std::vector< wchar_t > CreateEnvironmentBufferW ( const Environment & env)
static

Create a UTF-16 environment block to use with CreateProcessW.

The buffer is a sequence of null-terminated UTF-16 strings, followed by an extra L'\0' (two bytes of 0). An empty environment must have one empty string, followed by an extra L'\0'.

The keys are sorted to comply with the CreateProcess API calling convention.

Ensure that the resulting buffer is used in conjunction with CreateProcessW and be sure that dwCreationFlags includes CREATE_UNICODE_ENVIRONMENT.

Parameters
envThe Environment object to convert.
Returns
The sorted sequence of environment variables and their values, separated by null terminators. The vector is guaranteed to never be empty.

Definition at line 40 of file ProcessLauncherWindows.cpp.

References lldb_private::Environment::compose().

Referenced by lldb_private::ProcessLauncherWindows::LaunchProcess().

◆ GetFlattenedWindowsCommandStringW()

llvm::ErrorOr< std::wstring > GetFlattenedWindowsCommandStringW ( Args args)
static

Flattens an Args object into a Windows command-line wide string.

Returns an empty string if args is empty.

Parameters
argsThe Args object to flatten.
Returns
A wide string containing the flattened command line.

Definition at line 73 of file ProcessLauncherWindows.cpp.

References lldb_private::Args::empty(), and lldb_private::Args::entries().

Referenced by lldb_private::ProcessLauncherWindows::LaunchProcess().