LLDB mainline
PythonPathSetup.cpp File Reference
#include "lldb/Host/windows/PythonPathSetup/PythonPathSetup.h"
#include "lldb/Host/windows/windows.h"
#include "llvm/Support/Windows/WindowsSupport.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include <pathcch.h>

Go to the source code of this file.

Functions

static std::string GetModulePath (HMODULE module)
static std::string GetPathToExecutable ()
 Returns the full path to the lldb.exe executable.
llvm::Expected< std::string > SetupPythonRuntimeLibrary ()
 Attempts to setup the DLL search path for the Python runtime library.

Function Documentation

◆ GetModulePath()

std::string GetModulePath ( HMODULE module)
static

Definition at line 22 of file PythonPathSetup.cpp.

Referenced by GetPathToExecutable().

◆ GetPathToExecutable()

std::string GetPathToExecutable ( )
static

Returns the full path to the lldb.exe executable.

Definition at line 41 of file PythonPathSetup.cpp.

References GetModulePath().

◆ SetupPythonRuntimeLibrary()

llvm::Expected< std::string > SetupPythonRuntimeLibrary ( )

Attempts to setup the DLL search path for the Python runtime library.

In the following paragraphs, python3xx.dll refers to the Python runtime library name which is defined by LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME, e.g. python311.dll for Python 3.11.

The setup flow depends on which macros are defined:

  • If only LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is defined, checks whether python3xx.dll can be loaded. Returns an error if it cannot.
  • If only LLDB_PYTHON_DLL_RELATIVE_PATH is defined, attempts to resolve the relative path and add it to the DLL search path. Returns an error if this fails. Note that this may succeed even if python3xx.dll is not present in the added search path.
  • If both LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME and LLDB_PYTHON_DLL_RELATIVE_PATH are defined, first checks if python3xx.dll can be loaded. If successful, returns immediately. Otherwise, attempts to resolve the relative path and add it to the DLL search path, then checks again if python3xx.dll can be loaded.
Returns
If LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is defined, return the absolute path of the Python shared library which was resolved or an error if it could not be found. If LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME and LLDB_PYTHON_DLL_RELATIVE_PATH are not defined, return an empty string.

Definition at line 81 of file PythonPathSetup.cpp.

References createStringError().