LLDB mainline
RealpathPrefixes.h
Go to the documentation of this file.
1//===-- RealpathPrefixes.h --------------------------------------*- C++ -*-===//
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#ifndef LLDB_UTILITY_REALPATHPREFIXES_H
10#define LLDB_UTILITY_REALPATHPREFIXES_H
11
12#include "lldb/lldb-forward.h"
13#include "llvm/ADT/IntrusiveRefCntPtr.h"
14#include "llvm/Support/VirtualFileSystem.h"
15
16#include <optional>
17#include <string>
18#include <vector>
19
20namespace lldb_private {
21
23public:
24 /// \param[in] file_spec_list
25 /// Prefixes are obtained from FileSpecList, through FileSpec::GetPath(),
26 /// which ensures that the paths are normalized. For example:
27 /// "./foo/.." -> ""
28 /// "./foo/../bar" -> "bar"
29 ///
30 /// \param[in] fs
31 /// An optional filesystem to use for realpath'ing. If not set, the real
32 /// filesystem will be used.
33 explicit RealpathPrefixes(const FileSpecList &file_spec_list,
34 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs =
35 llvm::vfs::getRealFileSystem());
36
37 std::optional<FileSpec> ResolveSymlinks(const FileSpec &file_spec);
38
39 // If/when Statistics.h/cpp is moved into Utility, we can remove these
40 // methods, hold a (weak) pointer to `TargetStats` and directly increment
41 // on that object.
44 }
47 }
50 }
53 }
54
55private:
56 // Paths that start with one of the prefixes in this list will be realpath'ed
57 // to resolve any symlinks.
58 //
59 // Wildcard prefixes:
60 // - "" (empty string) will match all paths.
61 // - "/" will match all absolute paths.
62 std::vector<std::string> m_prefixes;
63
64 // The filesystem to use for realpath'ing.
65 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
66
67 // The optional Target instance to gather statistics.
69
70 // Statistics that we temprarily hold here, to be gathered into TargetStats
73};
74
75} // namespace lldb_private
76
77#endif // LLDB_UTILITY_REALPATHPREFIXES_H
A file collection class.
Definition: FileSpecList.h:91
A file utility class.
Definition: FileSpec.h:56
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > m_fs
std::optional< FileSpec > ResolveSymlinks(const FileSpec &file_spec)
std::vector< std::string > m_prefixes
uint32_t GetSourceRealpathAttemptCount() const
uint32_t GetSourceRealpathCompatibleCount() const
A class that represents a running process on the host machine.
std::weak_ptr< lldb_private::Target > TargetWP
Definition: lldb-forward.h:449