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 #define _OBJC_PRIVATE_H_
39 #include <objc/hashtable.h>
40 #include <objc/maptable.h>
45 /***********************************************************************
46 * Class pointer preflighting
47 **********************************************************************/
49 // Return cls if it's a valid class, or crash.
50 OBJC_EXPORT Class
gdb_class_getClass(Class cls
)
52 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0);
54 OBJC_AVAILABLE(10.7, 3.1, 9.0, 1.0);
57 // Same as gdb_class_getClass(object_getClass(cls)).
58 OBJC_EXPORT Class
gdb_object_getClass(id obj
)
59 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
62 /***********************************************************************
63 * Class lists for heap.
64 **********************************************************************/
68 // Maps class name to Class, for in-use classes only. NXStrValueMapPrototype.
69 OBJC_EXPORT NXMapTable
*gdb_objc_realized_classes
70 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0);
74 // Hashes Classes, for all known classes. Custom prototype.
75 OBJC_EXPORT NXHashTable
*_objc_debug_class_hash
77 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
;
82 /***********************************************************************
84 **********************************************************************/
88 // Extract isa pointer from an isa field.
89 // (Class)(isa & mask) == class pointer
90 OBJC_EXPORT
const uintptr_t objc_debug_isa_class_mask
91 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0);
93 // Extract magic cookie from an isa field.
94 // (isa & magic_mask) == magic_value
95 OBJC_EXPORT
const uintptr_t objc_debug_isa_magic_mask
96 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0);
97 OBJC_EXPORT
const uintptr_t objc_debug_isa_magic_value
98 OBJC_AVAILABLE(10.10, 7.0, 9.0, 1.0);
100 // Use indexed ISAs for targets which store index of the class in the ISA.
101 // This index can be used to index the array of classes.
102 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_magic_mask
;
103 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_magic_value
;
105 // Then these are used to extract the index from the ISA.
106 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_index_mask
;
107 OBJC_EXPORT
const uintptr_t objc_debug_indexed_isa_index_shift
;
109 // And then we can use that index to get the class from this array. Note
110 // the size is provided so that clients can ensure the index they get is in
111 // bounds and not read off the end of the array.
112 OBJC_EXPORT Class objc_indexed_classes
[];
114 // When we don't have enough bits to store a class*, we can instead store an
115 // index in to this array. Classes are added here when they are realized.
116 // Note, an index of 0 is illegal.
117 OBJC_EXPORT
uintptr_t objc_indexed_classes_count
;
119 // Absolute symbols for some of the above values are in objc-abi.h.
124 /***********************************************************************
125 * Tagged pointer decoding
126 **********************************************************************/
129 // Basic tagged pointers (7 classes, 60-bit payload).
131 // if (obj & mask) obj is a tagged pointer object
132 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_mask
133 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
135 // tag_slot = (obj >> slot_shift) & slot_mask
136 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_slot_shift
137 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
138 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_slot_mask
139 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
141 // class = classes[tag_slot]
142 OBJC_EXPORT Class objc_debug_taggedpointer_classes
[]
143 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
145 // payload = (obj << payload_lshift) >> payload_rshift
146 // Payload signedness is determined by the signedness of the right-shift.
147 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_payload_lshift
148 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
149 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_payload_rshift
150 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);
153 // Extended tagged pointers (255 classes, 52-bit payload).
155 // If you interrogate an extended tagged pointer using the basic
156 // tagged pointer scheme alone, it will appear to have an isa
157 // that is either nil or class __NSUnrecognizedTaggedPointer.
159 // if (ext_mask != 0 && (obj & ext_mask) == ext_mask)
160 // obj is a ext tagged pointer object
161 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_ext_mask
162 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
164 // ext_tag_slot = (obj >> ext_slot_shift) & ext_slot_mask
165 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_slot_shift
166 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
167 OBJC_EXPORT
uintptr_t objc_debug_taggedpointer_ext_slot_mask
168 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
170 // class = ext_classes[ext_tag_slot]
171 OBJC_EXPORT Class objc_debug_taggedpointer_ext_classes
[]
172 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
174 // payload = (obj << ext_payload_lshift) >> ext_payload_rshift
175 // Payload signedness is determined by the signedness of the right-shift.
176 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_payload_lshift
177 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
178 OBJC_EXPORT
unsigned int objc_debug_taggedpointer_ext_payload_rshift
179 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
184 /***********************************************************************
185 * Breakpoints in objc_msgSend for debugger stepping.
186 * The array is a {0,0} terminated list of addresses.
187 * Each address is one of the following:
188 * OBJC_MESSENGER_START: Address is the start of a messenger function.
189 * OBJC_MESSENGER_END_FAST: Address is a jump insn that calls an IMP.
190 * OBJC_MESSENGER_END_SLOW: Address is some insn in the slow lookup path.
191 * OBJC_MESSENGER_END_NIL: Address is a return insn for messages to nil.
193 * Every path from OBJC_MESSENGER_START should reach some OBJC_MESSENGER_END.
194 * At all ENDs, the stack and parameter register state is the same as START.
196 * In some cases, the END_FAST case jumps to something other than the
197 * method's implementation. In those cases the jump's destination will
198 * be another function that is marked OBJC_MESSENGER_START.
199 **********************************************************************/
202 #define OBJC_MESSENGER_START 1
203 #define OBJC_MESSENGER_END_FAST 2
204 #define OBJC_MESSENGER_END_SLOW 3
205 #define OBJC_MESSENGER_END_NIL 4
207 struct objc_messenger_breakpoint
{
212 OBJC_EXPORT
struct objc_messenger_breakpoint
213 gdb_objc_messenger_breakpoints
[]
214 OBJC_AVAILABLE(10.9, 7.0, 9.0, 1.0);