1 //===-- CFBasicHash.h -------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
12 #include "lldb/Target/Process.h"
13 #include "lldb/Target/Target.h"
15 namespace lldb_private
{
19 enum class HashType
{ set
= 0, dict
};
21 CFBasicHash() = default;
22 ~CFBasicHash() = default;
24 bool Update(lldb::addr_t addr
, ExecutionContextRef exe_ctx_rf
);
28 bool IsMutable() const { return m_mutable
; };
29 bool IsMultiVariant() const { return m_multi
; }
30 HashType
GetType() const { return m_type
; }
32 size_t GetCount() const;
33 lldb::addr_t
GetKeyPointer() const;
34 lldb::addr_t
GetValuePointer() const;
37 template <typename T
> struct __CFBasicHash
{
45 uint16_t __reserved1
: 2;
46 uint16_t keys_offset
: 1;
47 uint16_t counts_offset
: 2;
48 uint16_t counts_width
: 2;
49 uint16_t __reserved2
: 9;
50 uint32_t used_buckets
; // number of used buckets
51 uint64_t deleted
: 16; // number of elements deleted
52 uint64_t num_buckets_idx
: 8; // index to number of buckets
53 uint64_t __reserved3
: 40;
59 template <typename T
> bool UpdateFor(std::unique_ptr
<__CFBasicHash
<T
>> &m_ht
);
61 size_t GetPointerCount() const;
63 uint32_t m_ptr_size
= UINT32_MAX
;
64 lldb::ByteOrder m_byte_order
= lldb::eByteOrderInvalid
;
65 Address m_address
= LLDB_INVALID_ADDRESS
;
66 std::unique_ptr
<__CFBasicHash
<uint32_t>> m_ht_32
= nullptr;
67 std::unique_ptr
<__CFBasicHash
<uint64_t>> m_ht_64
= nullptr;
68 ExecutionContextRef m_exe_ctx_ref
;
69 bool m_mutable
= true;
71 HashType m_type
= HashType::set
;
74 } // namespace lldb_private
76 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H