2 * Copyright (c) 2006 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@
32 * Beginning in Mac OS X 10.4, this is how gdb discovers which mach-o images are loaded in a process.
34 * gdb looks for the symbol "_dyld_all_image_infos" in dyld. It contains the fields below.
36 * For a snashot of what images are currently loaded, the infoArray fields contain a pointer
37 * to an array of all images. If infoArray is NULL, it means it is being modified, come back later.
39 * To be notified of changes, gdb sets a break point on the address pointed to by the notificationn
40 * field. The function it points to is called by dyld with an array of information about what images
41 * have been added (dyld_image_adding) or are about to be removed (dyld_image_removing).
43 * The notification is called after infoArray is updated. This means that if gdb attaches to a process
44 * and infoArray is NULL, gdb can set a break point on notification and let the proccess continue to
45 * run until the break point. Then gdb can inspect the full infoArray.
48 enum dyld_image_mode
{ dyld_image_adding
=0, dyld_image_removing
=1 };
50 struct dyld_image_info
{
51 const struct mach_header
* imageLoadAddress
; /* base address image is mapped into */
52 const char* imageFilePath
; /* path dyld used to load the image */
53 uintptr_t imageFileModDate
; /* time_t of image file */
54 /* if stat().st_mtime of imageFilePath does not match imageFileModDate, */
55 /* then file has been modified since dyld loaded it */
58 typedef void (*dyld_image_notifier
)(enum dyld_image_mode mode
, uint32_t infoCount
, const struct dyld_image_info info
[]);
60 struct dyld_all_image_infos
{
61 uint32_t version
; /* == 1 in Mac OS X 10.4 */
62 uint32_t infoArrayCount
;
63 const struct dyld_image_info
* infoArray
;
64 dyld_image_notifier notification
;
65 bool processDetachedFromSharedRegion
;
67 extern struct dyld_all_image_infos dyld_all_image_infos
;
73 * Beginning in Mac OS X 10.5, this is how gdb discovers where the shared cache is in a process.
74 * Images that are in the shared cache have their segments rearranged, so when using imageFilePath
75 * to load the file from disk, you have to know to adjust addresses based on how their segment
78 * gdb looks for the symbol "_dyld_shared_region_ranges" in dyld.
80 * It contains information the count of shared regions used by the process. The count is
81 * the number of start/length pairs.
83 struct dyld_shared_cache_ranges
{
84 uintptr_t sharedRegionsCount
; /* how many ranges follow */
88 } ranges
[4]; /* max regions */
90 extern struct dyld_shared_cache_ranges dyld_shared_cache_ranges
;
98 #endif /* _DYLD_IMAGES_ */