Annotation of Gnu-Mach/ddb/db_sym.h, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     Author: Alessandro Forin, Carnegie Mellon University
        !            28:  *     Date:   8/90
        !            29:  */
        !            30: 
        !            31: #include <mach/boolean.h>
        !            32: #include <mach/machine/vm_types.h>
        !            33: #include <machine/db_machdep.h>
        !            34: 
        !            35: /*
        !            36:  * This module can handle multiple symbol tables,
        !            37:  * of multiple types, at the same time
        !            38:  */
        !            39: #define        SYMTAB_NAME_LEN 32
        !            40: 
        !            41: typedef struct {
        !            42:        int             type;
        !            43: #define        SYMTAB_AOUT     0
        !            44: #define        SYMTAB_COFF     1
        !            45: #define        SYMTAB_MACHDEP  2
        !            46:        char            *start;         /* symtab location */
        !            47:        char            *end;
        !            48:        char            *private;       /* optional machdep pointer */
        !            49:        char            *map_pointer;   /* symbols are for this map only,
        !            50:                                           if not null */
        !            51:        char            name[SYMTAB_NAME_LEN];
        !            52:                                        /* symtab name */
        !            53: } db_symtab_t;
        !            54: 
        !            55: extern db_symtab_t     *db_last_symtab; /* where last symbol was found */
        !            56: 
        !            57: /*
        !            58:  * Symbol representation is specific to the symtab style:
        !            59:  * BSD compilers use dbx' nlist, other compilers might use
        !            60:  * a different one
        !            61:  */
        !            62: typedef        char *          db_sym_t;       /* opaque handle on symbols */
        !            63: #define        DB_SYM_NULL     ((db_sym_t)0)
        !            64: 
        !            65: /*
        !            66:  * Non-stripped symbol tables will have duplicates, for instance
        !            67:  * the same string could match a parameter name, a local var, a
        !            68:  * global var, etc.
        !            69:  * We are most concerned with the following matches.
        !            70:  */
        !            71: typedef int            db_strategy_t;  /* search strategy */
        !            72: 
        !            73: #define        DB_STGY_ANY     0                       /* anything goes */
        !            74: #define DB_STGY_XTRN   1                       /* only external symbols */
        !            75: #define DB_STGY_PROC   2                       /* only procedures */
        !            76: 
        !            77: extern boolean_t       db_qualify_ambiguous_names;
        !            78:                                        /* if TRUE, check across symbol tables
        !            79:                                         * for multiple occurrences of a name.
        !            80:                                         * Might slow down quite a bit
        !            81:                                         * ..but the machine has nothing
        !            82:                                         * else to do, now does it ? */
        !            83: 
        !            84: /*
        !            85:  * Functions exported by the symtable module
        !            86:  */
        !            87: 
        !            88: /* extend the list of symbol tables */
        !            89: 
        !            90: extern boolean_t       db_add_symbol_table(    int type,
        !            91:                                                char * start,
        !            92:                                                char * end,
        !            93:                                                char *name,
        !            94:                                                char *ref,
        !            95:                                                char *map_pointer );
        !            96: 
        !            97: /* find symbol value given name */
        !            98: 
        !            99: extern int     db_value_of_name( char* name, db_expr_t* valuep);
        !           100: 
        !           101: /* find symbol given value */
        !           102: 
        !           103: extern db_sym_t        db_search_task_symbol(  db_addr_t val,
        !           104:                                        db_strategy_t strategy,
        !           105:                                        db_addr_t *offp,
        !           106:                                        task_t task );
        !           107: 
        !           108: /* return name and value of symbol */
        !           109: 
        !           110: extern void    db_symbol_values( db_symtab_t *stab,
        !           111:                                  db_sym_t sym,
        !           112:                                  char** namep,
        !           113:                                  db_expr_t* valuep);
        !           114: 
        !           115: /* find name&value given approx val */
        !           116: 
        !           117: #define db_find_sym_and_offset(val,namep,offp) \
        !           118:        db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
        !           119: 
        !           120: /* ditto, but no locals */
        !           121: #define db_find_xtrn_sym_and_offset(val,namep,offp)    \
        !           122:        db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
        !           123: 
        !           124: /* find name&value given approx val */
        !           125: 
        !           126: #define db_find_task_sym_and_offset(val,namep,offp,task)       \
        !           127:        db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task),  \
        !           128:                         namep, 0)
        !           129: 
        !           130: /* ditto, but no locals */
        !           131: #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task)  \
        !           132:        db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
        !           133:                         namep,0)
        !           134: 
        !           135: /* find symbol in current task */
        !           136: #define db_search_symbol(val,strgy,offp)       \
        !           137:        db_search_task_symbol(val,strgy,offp,0)
        !           138: 
        !           139: /* strcmp, modulo leading char */
        !           140: extern boolean_t       db_eqname( char* src, char* dst, char c );
        !           141: 
        !           142: /* print closest symbol to a value */
        !           143: extern void    db_task_printsym( db_expr_t off,
        !           144:                                  db_strategy_t strategy,
        !           145:                                  task_t task);
        !           146: 
        !           147: /* print closest symbol to a value */
        !           148: extern void    db_printsym( db_expr_t off, db_strategy_t strategy);
        !           149: 
        !           150: /*
        !           151:  * Symbol table switch, defines the interface
        !           152:  * to symbol-table specific routines.
        !           153:  * [NOTE: incomplete prototypes cuz broken compiler]
        !           154:  */
        !           155: 
        !           156: extern struct db_sym_switch {
        !           157: 
        !           158:        boolean_t       (*init)(
        !           159: /*                             char *start,
        !           160:                                char *end,
        !           161:                                char *name,
        !           162:                                char *task_addr
        !           163: */                             );
        !           164: 
        !           165:        db_sym_t        (*lookup)(
        !           166: /*                             db_symtab_t *stab,
        !           167:                                char *symstr
        !           168: */                             );
        !           169:        db_sym_t        (*search_symbol)(
        !           170: /*                             db_symtab_t *stab,
        !           171:                                db_addr_t off,
        !           172:                                db_strategy_t strategy,
        !           173:                                db_expr_t *diffp
        !           174: */                             );
        !           175: 
        !           176:        boolean_t       (*line_at_pc)(
        !           177: /*                             db_symtab_t     *stab,
        !           178:                                db_sym_t        sym,
        !           179:                                char            **file,
        !           180:                                int             *line,
        !           181:                                db_expr_t       pc
        !           182: */                             );
        !           183: 
        !           184:        void            (*symbol_values)(
        !           185: /*                             db_sym_t        sym,
        !           186:                                char            **namep,
        !           187:                                db_expr_t       *valuep
        !           188: */                             );
        !           189: 
        !           190: } x_db[];
        !           191: 
        !           192: #ifndef        symtab_type
        !           193: #define        symtab_type(s)          SYMTAB_AOUT
        !           194: #endif
        !           195: 
        !           196: #define        X_db_sym_init(s,e,n,t)          x_db[symtab_type(s)].init(s,e,n,t)
        !           197: #define        X_db_lookup(s,n)                x_db[(s)->type].lookup(s,n)
        !           198: #define        X_db_search_symbol(s,o,t,d)     x_db[(s)->type].search_symbol(s,o,t,d)
        !           199: #define        X_db_line_at_pc(s,p,f,l,a)      x_db[(s)->type].line_at_pc(s,p,f,l,a)
        !           200: #define        X_db_symbol_values(s,p,n,v)     x_db[(s)->type].symbol_values(p,n,v)

unix.superglobalmegacorp.com

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