[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 7 14:25:39 PDT 2024
================
@@ -0,0 +1,66 @@
+//===-- RealpathPrefixes.cpp ----------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/RealpathPrefixes.h"
+
+#include "lldb/Target/Statistics.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/FileSpecList.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb_private;
+
+RealpathPrefixes::RealpathPrefixes(const FileSpecList &file_spec_list)
+ : m_fs(llvm::vfs::getRealFileSystem()), m_target(nullptr) {
+ m_prefixes.reserve(file_spec_list.GetSize());
+ for (const FileSpec &file_spec : file_spec_list) {
+ m_prefixes.emplace_back(file_spec.GetPath());
+ }
+}
+
+void RealpathPrefixes::SetFileSystem(
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs) {
+ m_fs = fs;
+}
+
+std::optional<FileSpec>
+RealpathPrefixes::ResolveSymlinks(const FileSpec &file_spec) const {
+ if (m_prefixes.empty())
+ return std::nullopt;
+
+ auto is_prefix = [](llvm::StringRef a, llvm::StringRef b,
+ bool case_sensitive) -> bool {
+ return case_sensitive ? a.consume_front(b) : a.consume_front_insensitive(b);
----------------
jimingham wrote:
I was asking more about the difference between this `is_prefix` and the `is_suffix` that you defined when first figuring out whether one of the real path prefixes are applied to the incoming path.
https://github.com/llvm/llvm-project/pull/102223
More information about the lldb-commits
mailing list