LLDB mainline
SupportFile.h
Go to the documentation of this file.
1//===-- SupportFile.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_SUPPORTFILE_H
10#define LLDB_UTILITY_SUPPORTFILE_H
11
15
16namespace lldb_private {
17
18/// Wraps a FileSpec and an optional Checksum. The FileSpec represents either a
19/// path to a file or a source file whose contents is known (for example because
20/// it can be reconstructed from debug info), but that hasn't been written to a
21/// file yet.
23public:
25 SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {}
26 SupportFile(const FileSpec &spec, const Checksum &checksum)
27 : m_file_spec(spec), m_checksum(checksum) {}
28
29 SupportFile(const SupportFile &other) = delete;
30 SupportFile(SupportFile &&other) = default;
31
32 virtual ~SupportFile() = default;
33
41
42 bool Equal(const SupportFile &other,
44 assert(!(equality & eEqualChecksum & eEqualChecksumIfSet) &&
45 "eEqualChecksum and eEqualChecksumIfSet are mutually exclusive");
46
47 if (equality & eEqualFileSpec) {
48 if (m_file_spec != other.m_file_spec)
49 return false;
50 }
51
52 if (equality & eEqualChecksum) {
53 if (m_checksum != other.m_checksum)
54 return false;
55 }
56
57 if (equality & eEqualChecksumIfSet) {
58 if (m_checksum && other.m_checksum)
59 if (m_checksum != other.m_checksum)
60 return false;
61 }
62
63 return true;
64 }
65
66 /// Return the file name only. Useful for resolving breakpoints by file name.
67 const FileSpec &GetSpecOnly() const { return m_file_spec; };
68
69 /// Return the checksum or all zeros if there is none.
70 const Checksum &GetChecksum() const { return m_checksum; };
71
72 /// Materialize the file to disk and return the path to that temporary file.
73 virtual const FileSpec &Materialize() { return m_file_spec; }
74
75protected:
78};
79
81
82} // namespace lldb_private
83
84#endif // LLDB_UTILITY_SUPPORTFILE_H
A file utility class.
Definition FileSpec.h:57
A non-nullable shared pointer that always holds a valid object.
const Checksum m_checksum
Definition SupportFile.h:77
SupportFile(const SupportFile &other)=delete
virtual ~SupportFile()=default
SupportFile(const FileSpec &spec, const Checksum &checksum)
Definition SupportFile.h:26
SupportFile(SupportFile &&other)=default
const FileSpec & GetSpecOnly() const
Return the file name only. Useful for resolving breakpoints by file name.
Definition SupportFile.h:67
bool Equal(const SupportFile &other, SupportFileEquality equality=eEqualFileSpecAndChecksum) const
Definition SupportFile.h:42
const FileSpec m_file_spec
Definition SupportFile.h:76
virtual const FileSpec & Materialize()
Materialize the file to disk and return the path to that temporary file.
Definition SupportFile.h:73
const Checksum & GetChecksum() const
Return the checksum or all zeros if there is none.
Definition SupportFile.h:70
SupportFile(const FileSpec &spec)
Definition SupportFile.h:25
A class that represents a running process on the host machine.
NonNullSharedPtr< lldb_private::SupportFile > SupportFileNSP
Definition SupportFile.h:80