2 * Copyright (c) 2008 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
28 * WARNING DANGER HAZARD BEWARE EEK
30 * Everything in this file is for debugger and developer tool use only.
31 * These will change in arbitrary OS updates and in unpredictable ways.
32 * When your program breaks, you get to keep both pieces.
35 #ifdef __APPLE_API_PRIVATE
37 #ifndef _OBJC_PRIVATE_H_
38 # define _OBJC_PRIVATE_H_
41 #include <objc/hashtable.h>
42 #include <objc/maptable.h>
47 /***********************************************************************
48 * Class pointer preflighting
49 **********************************************************************/
51 // Return cls if it's a valid class, or crash.
52 OBJC_EXPORT Class _Nonnull
53 gdb_class_getClass(Class _Nonnull cls
)
55 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0);
57 OBJC_AVAILABLE(10.7, 3.1, 9.0, 1.0, 2.0);
60 // Same as gdb_class_getClass(object_getClass(cls)).
61 OBJC_EXPORT Class _Nonnull
gdb_object_getClass(id _Nullable obj
)
62 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0);
64 /***********************************************************************
66 **********************************************************************/
70 // Return the raw, mangled name of cls.
71 OBJC_EXPORT
const char * _Nonnull
72 objc_debug_class_getNameRaw(Class _Nullable cls
)
73 OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
77 /***********************************************************************
78 * Class lists for heap.
79 **********************************************************************/
83 // Maps class name to Class, for in-use classes only. NXStrValueMapPrototype.
84 OBJC_EXPORT NXMapTable
* _Nullable gdb_objc_realized_classes
85 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0);
87 // A generation count of realized classes. Increments when new classes
88 // are realized. This is NOT an exact count of the number of classes.
89 // It's not guaranteed by how much it increases when classes are
90 // realized, only that it increases by something. When classes are
91 // removed (unloading bundles or destroying dynamically allocated
92 // classes) the number will also increase to signal that there has
94 OBJC_EXPORT
uintptr_t objc_debug_realized_class_generation_count
;
98 // Hashes Classes, for all known classes. Custom prototype.
99 OBJC_EXPORT NXHashTable
* _Nullable _objc_debug_class_hash
100 __OSX_AVAILABLE(10.2)
101 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
102 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
107 /***********************************************************************
109 **********************************************************************/
113 // Extract isa pointer from an isa field.
114 // (Class)(isa & mask) == class pointer
115 OBJC_EXPORT
const uintptr_t objc_debug_isa_class_mask
116 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0, 2.0);
118 // Extract magic cookie from an isa field.
119 // (isa & magic_mask) == magic_value
120 OBJC_EXPORT
const uintptr_t objc_debug_isa_magic_mask
121 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0, 2.0);
122 OBJC_EXPORT
const uintptr_t objc_debug_isa_magic_value
123 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0, 2.0);
125 // Use indexed ISAs for targets which store index of the class in the ISA.
126 // This index can be used to index the array of classes.
127 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_magic_mask
;
128 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_magic_value
;
130 // Then these are used to extract the index from the ISA.
131 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_index_mask
;
132 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_index_shift
;
134 // And then we can use that index to get the class from this array. Note
135 // the size is provided so that clients can ensure the index they get is in
136 // bounds and not read off the end of the array.
137 OBJC_EXPORT Class _Nullable objc_indexed_classes
[];
139 // When we don't have enough bits to store a class*, we can instead store an
140 // index in to this array. Classes are added here when they are realized.
141 // Note, an index of 0 is illegal.
142 OBJC_EXPORT
uintptr_t objc_indexed_classes_count
;
144 // Absolute symbols for some of the above values are in objc-abi.h.
149 /***********************************************************************
150 * Class structure decoding
151 **********************************************************************/
154 // Mask for the pointer from class struct to class rw data.
155 // Other bits may be used for flags.
156 // Use 0x00007ffffffffff8UL or 0xfffffffcUL when this variable is unavailable.
157 OBJC_EXPORT
const uintptr_t objc_debug_class_rw_data_mask
158 OBJC_AVAILABLE(10.13, 11.0, 11.0, 4.0, 2.0);
163 /***********************************************************************
164 * Tagged pointer decoding
165 **********************************************************************/
168 // Basic tagged pointers (7 classes, 60-bit payload).
170 // if (obj & mask) obj is a tagged pointer object
171 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_mask
172 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
174 // tagged pointers are obfuscated by XORing with a random value
175 // decoded_obj = (obj ^ obfuscator)
176 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_obfuscator
177 OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0);
180 // tag_slot = (obj >> slot_shift) & slot_mask
181 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_slot_shift
182 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
183 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_slot_mask
184 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
186 // class = classes[tag_slot]
187 OBJC_EXPORT Class _Nullable objc_debug_taggedpointer_classes
[]
188 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
190 // payload = (decoded_obj << payload_lshift) >> payload_rshift
191 // Payload signedness is determined by the signedness of the right-shift.
192 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_payload_lshift
193 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
194 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_payload_rshift
195 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0, 2.0);
198 // Extended tagged pointers (255 classes, 52-bit payload).
200 // If you interrogate an extended tagged pointer using the basic
201 // tagged pointer scheme alone, it will appear to have an isa
202 // that is either nil or class __NSUnrecognizedTaggedPointer.
204 // if (ext_mask != 0 && (decoded_obj & ext_mask) == ext_mask)
205 // obj is a ext tagged pointer object
206 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_ext_mask
207 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
209 // ext_tag_slot = (obj >> ext_slot_shift) & ext_slot_mask
210 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_slot_shift
211 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
212 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_ext_slot_mask
213 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
215 // class = ext_classes[ext_tag_slot]
216 OBJC_EXPORT Class _Nullable objc_debug_taggedpointer_ext_classes
[]
217 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
219 // payload = (decoded_obj << ext_payload_lshift) >> ext_payload_rshift
220 // Payload signedness is determined by the signedness of the right-shift.
221 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_payload_lshift
222 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
223 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_payload_rshift
224 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);
229 /***********************************************************************
231 **********************************************************************/
233 OBJC_EXPORT
const uintptr_t objc_debug_swift_stable_abi_bit
234 OBJC_AVAILABLE(10.14.4, 12.2, 12.2, 5.2, 3.2);
239 /***********************************************************************
240 * AutoreleasePoolPage
241 **********************************************************************/
242 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_magic_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
243 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_next_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
244 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_thread_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
245 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_parent_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
246 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_child_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
247 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_depth_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);
248 OBJC_EXTERN
const uint32_t objc_debug_autoreleasepoolpage_hiwat_offset
OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 5.0);