LLDB mainline
PythonRuntimeLoaderPosix.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Host/Config.h"
10
11#if LLDB_ENABLE_PYTHON
12
14#include "llvm/ADT/STLFunctionalExtras.h"
15
16namespace lldb_private {
17
19 llvm::function_ref<bool(const char *)> callback) {
20 // Bare names rely on the dynamic linker's search (LD_LIBRARY_PATH,
21 // ldconfig cache/hints, default paths). libpython3.so usually comes with a
22 // development package; the versioned SONAMEs cover runtime-only installs.
23 // The 3.8 floor matches Python's Stable ABI baseline. Darwin has its own
24 // framework-aware implementation; this covers every other POSIX host.
25 static constexpr const char *kCandidates[] = {
26 "libpython3.so", "libpython3.13.so.1.0", "libpython3.12.so.1.0",
27 "libpython3.11.so.1.0", "libpython3.10.so.1.0", "libpython3.9.so.1.0",
28 "libpython3.8.so.1.0",
29 };
30 for (const char *candidate : kCandidates) {
31 if (callback(candidate))
32 return;
33 }
34}
35
36} // namespace lldb_private
37
38#endif // LLDB_ENABLE_PYTHON
A class that represents a running process on the host machine.
void ForEachPythonRuntimeCandidate(llvm::function_ref< bool(const char *)> callback)
Visits candidate Python runtime paths in priority order, stopping at the first call that returns true...