summaryrefslogtreecommitdiff
path: root/source/Host/common/HostInfoBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/common/HostInfoBase.cpp')
-rw-r--r--source/Host/common/HostInfoBase.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index 34c362efc9e0..130f0eb8ac8d 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -1,9 +1,8 @@
//===-- HostInfoBase.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,13 +31,11 @@ using namespace lldb;
using namespace lldb_private;
namespace {
-//----------------------------------------------------------------------
// The HostInfoBaseFields is a work around for windows not supporting static
// variables correctly in a thread safe way. Really each of the variables in
// HostInfoBaseFields should live in the functions in which they are used and
// each one should be static, but the work around is in place to avoid this
// restriction. Ick.
-//----------------------------------------------------------------------
struct HostInfoBaseFields {
~HostInfoBaseFields() {
@@ -215,6 +212,38 @@ ArchSpec HostInfoBase::GetAugmentedArchSpec(llvm::StringRef triple) {
return ArchSpec(normalized_triple);
}
+bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec,
+ llvm::StringRef dir) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
+ return false;
+
+ std::string raw_path = lldb_file_spec.GetPath();
+ if (log)
+ log->Printf("HostInfo::%s() attempting to "
+ "derive the path %s relative to liblldb install path: %s",
+ __FUNCTION__, dir.data(), raw_path.c_str());
+
+ // Drop bin (windows) or lib
+ llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
+ if (parent_path.empty()) {
+ if (log)
+ log->Printf("HostInfo::%s() failed to find liblldb within the shared "
+ "lib path",
+ __FUNCTION__);
+ return false;
+ }
+
+ raw_path = (parent_path + dir).str();
+ if (log)
+ log->Printf("HostInfo::%s() derived the path as: %s", __FUNCTION__,
+ raw_path.c_str());
+ file_spec.GetDirectory().SetString(raw_path);
+ return (bool)file_spec.GetDirectory();
+}
+
bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
// To get paths related to LLDB we get the path to the executable that
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB".