home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / local / include / mach-o / rld_state.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-14  |  4.0 KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
  7.  * Reserved.  This file contains Original Code and/or Modifications of
  8.  * Original Code as defined in and that are subject to the Apple Public
  9.  * Source License Version 1.1 (the "License").  You may not use this file
  10.  * except in compliance with the License.  Please obtain a copy of the
  11.  * License at http://www.apple.com/publicsource and read it before using
  12.  * this file.
  13.  * 
  14.  * The Original Code and all software distributed under the License are
  15.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  16.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  17.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
  19.  * License for the specific language governing rights and limitations
  20.  * under the License.
  21.  * 
  22.  * @APPLE_LICENSE_HEADER_END@
  23.  */
  24. /*
  25.  * To allow the debugger to debug programs that used rld on themselves without
  26.  * having the having the programs create a debug file information is maintained
  27.  * in the rld package for the debugger.  This information is two static data
  28.  * items and a static routine.  The information that is maintained is the state
  29.  * of the loaded sets are currently loaded into the program.  The number of
  30.  * object files and their names that make up each set and the resulting address
  31.  * they were loaded at is maintained for each set.  The static data symbol
  32.  * rld_loaded_state points to an array of rld_loaded_state structures that
  33.  * contains the above information.  The static data symbol rld_nloaded_states
  34.  * contains the count of these structures.  When the loaded state is changed
  35.  * the static routine rld_loaded_state_changed() is called.
  36.  *
  37.  * This is the only information in the rld package the debugger is allowed to
  38.  * use.  The debugger sets a break point on the routine rld_loaded_state_changed
  39.  * when it is triped on then it can inspect the rld_loaded_state.  Then using
  40.  * the rld package and the program it is debugging as a base file then it can
  41.  * create the symbols for the loaded sets by doing rld_loads for each set.
  42.  * The debugger uses an undocumented feature of rld_load (intended only for it's
  43.  * use) which is to used the interger value of 1 (RLD_DEBUG_OUTPUT_FILENAME)
  44.  * for the output_filename which causes the symbols to be created and left in
  45.  * memory and not written to a file.
  46.  *
  47.  * When the debugger attaches to a running process there is a window of time
  48.  * where the process could be doing an rld operation and the state in not
  49.  * correct.  The window is shorted to it's minimal time by changing the value
  50.  * of rld_nloaded_states so that that number of states can be safely accessed.
  51.  * There are still small windows where problems can occur.
  52.  */
  53.  
  54. struct rld_loaded_state {
  55.     char **object_filenames;    /* pointer to an array of file names loaded */
  56.     unsigned long        /*  in this set */
  57.     nobject_filenames;    /* number of file names loaded in this set */
  58.     struct mach_header        /* The address the set was link edited at */
  59.     *header_addr;
  60. };
  61.  
  62. /* 
  63.  * static unsigned long rld_nloaded_states = 0;
  64.  * static struct rld_loaded_state *rld_loaded_state = NULL;
  65.  *
  66.  * static void rld_loaded_state_changed(void);
  67.  */
  68. #define RLD_NLOADED_STATES    "rld_nloaded_states"
  69. #define RLD_LOADED_STATE    "rld_loaded_state"
  70. #define RLD_LOADED_STATE_CHANGED "rld_loaded_state_changed"
  71.  
  72. #define RLD_DEBUG_OUTPUT_FILENAME ((char *)1)
  73.  
  74. /*
  75.  * moninitrld() can be defined in the librld.o library module if it is used or
  76.  * defined as a common in gcrt0.o if the librld.o library module is not used.
  77.  * The library module is passed monaddition() to call when a rld_load() is done
  78.  * and returns a pointer to the routine to get the rld loaded state so it can
  79.  * be written in to the gmon.out file.
  80.  */
  81. extern void (*moninitrld(
  82.     void (* monaddition)(char *lowpc, char *highpc)))
  83.         (struct rld_loaded_state **rld_loaded_state,
  84.          unsigned long *rld_nloaded_states);
  85.