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
14
15namespace lldb_private {
16
17/// Wraps either a FileSpec that represents a local file or a source
18/// file whose contents is known (for example because it can be
19/// reconstructed from debug info), but that hasn't been written to a
20/// file yet. This also stores an optional checksum of the on-disk content.
22public:
24 SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {}
25 SupportFile(const FileSpec &spec, const Checksum &checksum)
26 : m_file_spec(spec), m_checksum(checksum) {}
27
28 SupportFile(const SupportFile &other) = delete;
29 SupportFile(SupportFile &&other) = default;
30
31 virtual ~SupportFile() = default;
32
33 bool operator==(const SupportFile &other) const {
34 return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
35 }
36
37 bool operator!=(const SupportFile &other) const { return !(*this == other); }
38
39 /// Return the file name only. Useful for resolving breakpoints by file name.
40 const FileSpec &GetSpecOnly() const { return m_file_spec; };
41
42 /// Return the checksum or all zeros if there is none.
43 const Checksum &GetChecksum() const { return m_checksum; };
44
45 /// Materialize the file to disk and return the path to that temporary file.
46 virtual const FileSpec &Materialize() { return m_file_spec; }
47
48 /// Change the file name.
49 void Update(const FileSpec &file_spec) { m_file_spec = file_spec; }
50
51protected:
54};
55
56} // namespace lldb_private
57
58#endif // LLDB_UTILITY_SUPPORTFILE_H
A file utility class.
Definition: FileSpec.h:56
Wraps either a FileSpec that represents a local file or a source file whose contents is known (for ex...
Definition: SupportFile.h:21
bool operator==(const SupportFile &other) const
Definition: SupportFile.h:33
SupportFile(const SupportFile &other)=delete
virtual ~SupportFile()=default
SupportFile(const FileSpec &spec, const Checksum &checksum)
Definition: SupportFile.h:25
bool operator!=(const SupportFile &other) const
Definition: SupportFile.h:37
SupportFile(SupportFile &&other)=default
const FileSpec & GetSpecOnly() const
Return the file name only. Useful for resolving breakpoints by file name.
Definition: SupportFile.h:40
void Update(const FileSpec &file_spec)
Change the file name.
Definition: SupportFile.h:49
virtual const FileSpec & Materialize()
Materialize the file to disk and return the path to that temporary file.
Definition: SupportFile.h:46
const Checksum & GetChecksum() const
Return the checksum or all zeros if there is none.
Definition: SupportFile.h:43
SupportFile(const FileSpec &spec)
Definition: SupportFile.h:24
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14