File indexing completed on 2026-05-10 08:42:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_UTILITY_UUID_H
0010 #define LLDB_UTILITY_UUID_H
0011
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/Support/Endian.h"
0015 #include <cstddef>
0016 #include <cstdint>
0017 #include <string>
0018
0019 namespace lldb_private {
0020
0021 class Stream;
0022
0023 class UUID {
0024
0025
0026
0027 public:
0028 UUID() = default;
0029
0030
0031 UUID(llvm::ArrayRef<uint8_t> bytes) : m_bytes(bytes) {
0032 if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; })) {
0033 Clear();
0034 }
0035 }
0036
0037
0038
0039 struct CvRecordPdb70 {
0040 struct {
0041 llvm::support::ulittle32_t Data1;
0042 llvm::support::ulittle16_t Data2;
0043 llvm::support::ulittle16_t Data3;
0044 uint8_t Data4[8];
0045 } Uuid;
0046 llvm::support::ulittle32_t Age;
0047
0048 };
0049
0050
0051 UUID(CvRecordPdb70 debug_info);
0052
0053
0054 UUID(const void *bytes, uint32_t num_bytes) {
0055 if (!bytes)
0056 return;
0057 *this
0058 = UUID(llvm::ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(bytes),
0059 num_bytes));
0060 }
0061
0062 void Clear() { m_bytes.clear(); }
0063
0064 void Dump(Stream &s) const;
0065
0066 llvm::ArrayRef<uint8_t> GetBytes() const { return m_bytes; }
0067
0068 explicit operator bool() const { return IsValid(); }
0069 bool IsValid() const { return !m_bytes.empty(); }
0070
0071 std::string GetAsString(llvm::StringRef separator = "-") const;
0072
0073 bool SetFromStringRef(llvm::StringRef str);
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 static llvm::StringRef
0088 DecodeUUIDBytesFromString(llvm::StringRef str,
0089 llvm::SmallVectorImpl<uint8_t> &uuid_bytes);
0090
0091 private:
0092
0093
0094 llvm::SmallVector<uint8_t, 20> m_bytes;
0095
0096 friend bool operator==(const UUID &LHS, const UUID &RHS) {
0097 return LHS.m_bytes == RHS.m_bytes;
0098 }
0099 friend bool operator!=(const UUID &LHS, const UUID &RHS) {
0100 return !(LHS == RHS);
0101 }
0102 friend bool operator<(const UUID &LHS, const UUID &RHS) {
0103 return LHS.m_bytes < RHS.m_bytes;
0104 }
0105 friend bool operator<=(const UUID &LHS, const UUID &RHS) {
0106 return !(RHS < LHS);
0107 }
0108 friend bool operator>(const UUID &LHS, const UUID &RHS) { return RHS < LHS; }
0109 friend bool operator>=(const UUID &LHS, const UUID &RHS) {
0110 return !(LHS < RHS);
0111 }
0112 };
0113 }
0114
0115 #endif