9#include "lldb/Host/Config.h"
14#include "llvm/ADT/STLFunctionalExtras.h"
15#include "llvm/ADT/SmallString.h"
16#include "llvm/ADT/StringRef.h"
17#include "llvm/ADT/Twine.h"
18#include "llvm/Support/FileSystem.h"
19#include "llvm/Support/Path.h"
29constexpr llvm::StringLiteral kFrameworks[] = {
30 "Python3.framework/Versions/Current/Python3",
31 "Python.framework/Versions/Current/Python",
36constexpr llvm::StringLiteral kLLDBRelativeDirs[] = {
37 "../../../../../Developer/Library/Frameworks",
38 "../../../../Developer/Library/Frameworks",
39 "../../../../Frameworks",
41 "../../../../../../AppleInternal/Library/Frameworks",
46bool TryFrameworks(llvm::function_ref<
bool(
const char *)> callback,
47 const llvm::Twine &dir) {
48 for (llvm::StringRef framework : kFrameworks) {
49 llvm::SmallString<256> path;
50 llvm::sys::path::append(path, dir, framework);
51 if (llvm::sys::fs::exists(path) && callback(path.c_str()))
60 llvm::function_ref<
bool(
const char *)> callback) {
68 llvm::StringRef lldb_dir = llvm::sys::path::parent_path(info.dli_fname);
69 for (llvm::StringRef dir : kLLDBRelativeDirs)
70 if (TryFrameworks(callback, lldb_dir +
"/" + dir))
75 if (TryFrameworks(callback,
"/Library/Frameworks"))
79 callback(
"libpython3.dylib");
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...