2 * Copyright (c) 1999 Apple Computer, 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@
26 #include <mach/mach.h>
27 #ifndef DYLD_BUILD /* do not include this when building dyld itself */
28 #include <mach-o/dyld.h>
29 #endif /* !defined(DYLD_BUILD) */
31 #include <AvailabilityMacros.h>
34 * The dyld debugging API is deprecated as of Mac OS X 10.4
36 enum dyld_debug_return
{
38 DYLD_INCONSISTENT_DATA
,
39 DYLD_INVALID_ARGUMENTS
,
43 struct dyld_debug_module
{
44 struct mach_header
*header
;
45 unsigned long vmaddr_slide
;
46 unsigned long module_index
;
49 enum dyld_event_type
{
59 enum dyld_event_type type
;
60 struct dyld_debug_module arg
[2];
63 extern enum dyld_debug_return
_dyld_debug_defining_module(
64 mach_port_t target_task
,
65 unsigned long send_timeout
,
66 unsigned long rcv_timeout
,
67 boolean_t inconsistent_data_ok
,
69 struct dyld_debug_module
*module) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
71 extern enum dyld_debug_return
_dyld_debug_is_module_bound(
72 mach_port_t target_task
,
73 unsigned long send_timeout
,
74 unsigned long rcv_timeout
,
75 boolean_t inconsistent_data_ok
,
76 struct dyld_debug_module
module,
77 boolean_t
*bound
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
79 extern enum dyld_debug_return
_dyld_debug_bind_module(
80 mach_port_t target_task
,
81 unsigned long send_timeout
,
82 unsigned long rcv_timeout
,
83 boolean_t inconsistent_data_ok
,
84 struct dyld_debug_module
module) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
86 extern enum dyld_debug_return
_dyld_debug_module_name(
87 mach_port_t target_task
,
88 unsigned long send_timeout
,
89 unsigned long rcv_timeout
,
90 boolean_t inconsistent_data_ok
,
91 struct dyld_debug_module
module,
93 unsigned long *image_nameCnt
,
95 unsigned long *module_nameCnt
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
97 extern enum dyld_debug_return
_dyld_debug_subscribe_to_events(
98 mach_port_t target_task
,
99 unsigned long send_timeout
,
100 unsigned long rcv_timeout
,
101 boolean_t inconsistent_data_ok
,
102 void (*dyld_event_routine
)(struct dyld_event event
)) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
105 * _dyld_debug_add_event_subscriber() uses the mig interface functions below
106 * to dispatch the dyld event messages from the subscriber port specified.
108 extern enum dyld_debug_return
_dyld_debug_add_event_subscriber(
109 mach_port_t target_task
,
110 unsigned long send_timeout
,
111 unsigned long rcv_timeout
,
112 boolean_t inconsistent_data_ok
,
113 mach_port_t subscriber
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
116 * These structures should be produced by mig(1) from the mig generated files
117 * but they are not. These are really only needed so the correct size of the
118 * request and reply messages can be allocated.
120 struct _dyld_event_message_request
{
122 mach_msg_header_t head
;
124 struct dyld_event event
;
125 mach_msg_trailer_t trailer
;
128 msg_type_t eventType
;
129 struct dyld_event event
;
132 struct _dyld_event_message_reply
{
134 mach_msg_header_t head
;
136 struct dyld_event event
;
139 msg_type_t RetCodeType
;
140 kern_return_t RetCode
;
145 * _dyld_event_server() is the mig generated routine to dispatch dyld event
148 extern boolean_t
_dyld_event_server(
150 mach_msg_header_t
*request
,
151 mach_msg_header_t
*reply
);
153 struct _dyld_event_message_request
*request
,
154 struct _dyld_event_message_reply
*reply
);
156 #endif /* mig_internal */
160 * _dyld_event_server_callback() is the routine called by _dyld_event_server()
161 * that must be written by users of _dyld_event_server().
169 _dyld_event_server_callback(
171 mach_port_t subscriber
,
175 struct dyld_event event
);
179 * This is the state of the target task while we are sending a message to it.
181 struct _dyld_debug_task_state
{
182 mach_port_t debug_port
;
183 mach_port_t debug_thread
;
184 unsigned int debug_thread_resume_count
;
185 unsigned int task_resume_count
;
186 mach_port_t
*threads
;
187 unsigned int thread_count
;
191 * _dyld_debug_make_runnable() is called before sending messages to the
192 * dynamic link editor. Basically it assures that the debugging
193 * thread is the only runnable thread in the task to receive the
194 * message. It also assures that the debugging thread is indeed
195 * runnable if it was suspended. The function will make sure each
196 * thread in the remote task is suspended and resumed the same number
197 * of times, so in the end the suspend count of each individual thread
200 extern enum dyld_debug_return
_dyld_debug_make_runnable(
201 mach_port_t target_task
,
202 struct _dyld_debug_task_state
*state
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
205 * _dyld_debug_restore_runnable() is called after sending messages to the
206 * dynamic link editor. It undoes what _dyld_debug_make_runnable() did to the
207 * task and put it back the way it was.
209 extern enum dyld_debug_return
_dyld_debug_restore_runnable(
210 mach_port_t target_task
,
211 struct _dyld_debug_task_state
*state
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
214 * To provide more detailed information when the APIs of the dyld debug
215 * interfaces fail (return DYLD_FAILURE) the following structure is filled in.
216 * After it is filled in the function registered with
217 * set_dyld_debug_error_func() is called with a pointer to that struct.
219 * The local_error field is a unique number for each possible error condition
220 * in the source code in that makes up the dyld debug APIs. The source file
221 * and line number in the cctools libdyld directory where the dyld debug APIs
222 * are implemented are set into the file_name and line_number fields. The
223 * field dyld_debug_return is filled in with that would be returned by the
224 * API (usually DYLD_FAILURE). The other fields will be zero or filled in by
225 * the error code from the mach system call, or UNIX system call that failed.
227 struct dyld_debug_error_data
{
228 enum dyld_debug_return dyld_debug_return
;
229 kern_return_t mach_error
;
230 int dyld_debug_errno
;
231 unsigned long local_error
;
233 unsigned long line_number
;
236 extern void _dyld_debug_set_error_func(
237 void (*func
)(struct dyld_debug_error_data
*e
)) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
239 #ifndef DYLD_BUILD /* do not include this when building dyld itself */
241 extern enum dyld_debug_return
_dyld_debug_task_from_core(
242 NSObjectFileImage coreFileImage
,
243 mach_port_t
*core_task
) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
;
245 #endif /* !defined(DYLD_BUILD) */
247 #endif /* _DYLD_DEBUG_ */