Annotation of GNUtools/cctools/include/mach-o/rld_state.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * To allow the debugger to debug programs that used rld on themselves without
                      3:  * having the having the programs create a debug file information is maintained
                      4:  * in the rld package for the debugger.  This information is two static data
                      5:  * items and a static routine.  The information that is maintained is the state
                      6:  * of the loaded sets are currently loaded into the program.  The number of
                      7:  * object files and their names that make up each set and the resulting address
                      8:  * they were loaded at is maintained for each set.  The static data symbol
                      9:  * rld_loaded_state points to an array of rld_loaded_state structures that
                     10:  * contains the above information.  The static data symbol rld_nloaded_states
                     11:  * contains the count of these structures.  When the loaded state is changed
                     12:  * the static routine rld_loaded_state_changed() is called.
                     13:  *
                     14:  * This is the only information in the rld package the debugger is allowed to
                     15:  * use.  The debugger sets a break point on the routine rld_loaded_state_changed
                     16:  * when it is triped on then it can inspect the rld_loaded_state.  Then using
                     17:  * the rld package and the program it is debugging as a base file then it can
                     18:  * create the symbols for the loaded sets by doing rld_loads for each set.
                     19:  * The debugger uses an undocumented feature of rld_load (intended only for it's
                     20:  * use) which is to used the interger value of 1 (RLD_DEBUG_OUTPUT_FILENAME)
                     21:  * for the output_filename which causes the symbols to be created and left in
                     22:  * memory and not written to a file.
                     23:  *
                     24:  * When the debugger attaches to a running process there is a window of time
                     25:  * where the process could be doing an rld operation and the state in not
                     26:  * correct.  The window is shorted to it's minimal time by changing the value
                     27:  * of rld_nloaded_states so that that number of states can be safely accessed.
                     28:  * There are still small windows where problems can occur.
                     29:  */
                     30: 
                     31: struct rld_loaded_state {
                     32:     char **object_filenames;   /* pointer to an array of file names loaded */
                     33:     unsigned long              /*  in this set */
                     34:        nobject_filenames;      /* number of file names loaded in this set */
                     35:     struct mach_header         /* The address the set was link edited at */
                     36:        *header_addr;
                     37: };
                     38: 
                     39: /* 
                     40:  * static unsigned long rld_nloaded_states = 0;
                     41:  * static struct rld_loaded_state *rld_loaded_state = NULL;
                     42:  *
                     43:  * static void rld_loaded_state_changed(void);
                     44:  */
                     45: #define RLD_NLOADED_STATES     "rld_nloaded_states"
                     46: #define RLD_LOADED_STATE       "rld_loaded_state"
                     47: #define RLD_LOADED_STATE_CHANGED "rld_loaded_state_changed"
                     48: 
                     49: #define RLD_DEBUG_OUTPUT_FILENAME ((char *)1)
                     50: 
                     51: /*
                     52:  * moninitrld() can be defined in the librld.o library module if it is used or
                     53:  * defined as a common in gcrt0.o if the librld.o library module is not used.
                     54:  * The library module is passed monaddition() to call when a rld_load() is done
                     55:  * and returns a pointer to the routine to get the rld loaded state so it can
                     56:  * be written in to the gmon.out file.
                     57:  */
                     58: extern void (*moninitrld(
                     59:     void (* monaddition)(char *lowpc, char *highpc)))
                     60:            (struct rld_loaded_state **rld_loaded_state,
                     61:             unsigned long *rld_nloaded_states);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.