Index: lldb/include/lldb/API/SBCommandInterpreter.h =================================================================== --- lldb/include/lldb/API/SBCommandInterpreter.h +++ lldb/include/lldb/API/SBCommandInterpreter.h @@ -235,6 +235,9 @@ /// and aliases. If successful, result->GetOutput has the full expansion. void ResolveCommand(const char *command_line, SBCommandReturnObject &result); + /// Return the module path for the script interpreter, if one is registered. + lldb::SBFileSpec GetScriptModuleDirectory() const; + protected: lldb_private::CommandInterpreter &ref(); Index: lldb/include/lldb/API/SBHostOS.h =================================================================== --- lldb/include/lldb/API/SBHostOS.h +++ lldb/include/lldb/API/SBHostOS.h @@ -18,6 +18,7 @@ public: static lldb::SBFileSpec GetProgramFileSpec(); + // Deprecated. Use SBCommandInpterpreter::GetScriptModuleDirectory instead. static lldb::SBFileSpec GetLLDBPythonPath(); static lldb::SBFileSpec GetLLDBPath(lldb::PathType path_type); Index: lldb/include/lldb/Interpreter/ScriptInterpreter.h =================================================================== --- lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -470,6 +470,8 @@ lldb::ScriptLanguage GetLanguage() { return m_script_lang; } + virtual FileSpec GetModuleDirectory() { return {}; }; + protected: CommandInterpreter &m_interpreter; lldb::ScriptLanguage m_script_lang; Index: lldb/source/API/SBCommandInterpreter.cpp =================================================================== --- lldb/source/API/SBCommandInterpreter.cpp +++ lldb/source/API/SBCommandInterpreter.cpp @@ -248,6 +248,18 @@ : nullptr); } +lldb::SBFileSpec SBCommandInterpreter::GetScriptModuleDirectory() const { + if (!IsValid()) + return {}; + + ScriptInterpreter *script_interpreter = + m_opaque_ptr->GetScriptInterpreter(true); + if (!script_interpreter) + return {}; + + return SBFileSpec(script_interpreter->GetModuleDirectory()); +} + lldb::ReturnStatus SBCommandInterpreter::HandleCommand(const char *command_line, SBCommandReturnObject &result, Index: lldb/source/API/SBHostOS.cpp =================================================================== --- lldb/source/API/SBHostOS.cpp +++ lldb/source/API/SBHostOS.cpp @@ -60,9 +60,7 @@ fspec = HostInfo::GetHeaderDir(); break; case ePathTypePythonDir: -#ifndef LLDB_DISABLE_PYTHON - fspec = ScriptInterpreterPython::GetPythonDir(); -#endif + // Deprecated. Use SBCommandInpterpreter::GetScriptModuleDirectory instead. break; case ePathTypeLLDBSystemPlugins: fspec = HostInfo::GetSystemPluginDir(); Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h @@ -46,6 +46,8 @@ static const char *GetPluginDescriptionStatic(); static FileSpec GetPythonDir(); + virtual FileSpec GetModuleDirectory() { return GetPythonDir(); }; + protected: static void ComputePythonDirForApple(llvm::SmallVectorImpl &path); static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path); Index: lldb/tools/driver/Driver.cpp =================================================================== --- lldb/tools/driver/Driver.cpp +++ lldb/tools/driver/Driver.cpp @@ -453,7 +453,8 @@ } if (m_option_data.m_print_python_path) { - SBFileSpec python_file_spec = SBHostOS::GetLLDBPythonPath(); + SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter(); + SBFileSpec python_file_spec = sb_interpreter.GetScriptModuleDirectory(); if (python_file_spec.IsValid()) { char python_path[PATH_MAX]; size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);