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

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: 
1.1.1.2 ! root       31: #ifndef        _DDB_DB_SYM_H_
        !            32: #define        _DDB_DB_SYM_H_
        !            33: 
1.1       root       34: #include <mach/boolean.h>
                     35: #include <mach/machine/vm_types.h>
                     36: #include <machine/db_machdep.h>
                     37: 
                     38: /*
                     39:  * This module can handle multiple symbol tables,
                     40:  * of multiple types, at the same time
                     41:  */
                     42: #define        SYMTAB_NAME_LEN 32
                     43: 
                     44: typedef struct {
                     45:        int             type;
                     46: #define        SYMTAB_AOUT     0
                     47: #define        SYMTAB_COFF     1
                     48: #define        SYMTAB_MACHDEP  2
                     49:        char            *start;         /* symtab location */
                     50:        char            *end;
                     51:        char            *private;       /* optional machdep pointer */
                     52:        char            *map_pointer;   /* symbols are for this map only,
                     53:                                           if not null */
                     54:        char            name[SYMTAB_NAME_LEN];
                     55:                                        /* symtab name */
                     56: } db_symtab_t;
                     57: 
                     58: extern db_symtab_t     *db_last_symtab; /* where last symbol was found */
                     59: 
                     60: /*
                     61:  * Symbol representation is specific to the symtab style:
                     62:  * BSD compilers use dbx' nlist, other compilers might use
                     63:  * a different one
                     64:  */
                     65: typedef        char *          db_sym_t;       /* opaque handle on symbols */
                     66: #define        DB_SYM_NULL     ((db_sym_t)0)
                     67: 
                     68: /*
                     69:  * Non-stripped symbol tables will have duplicates, for instance
                     70:  * the same string could match a parameter name, a local var, a
                     71:  * global var, etc.
                     72:  * We are most concerned with the following matches.
                     73:  */
                     74: typedef int            db_strategy_t;  /* search strategy */
                     75: 
                     76: #define        DB_STGY_ANY     0                       /* anything goes */
                     77: #define DB_STGY_XTRN   1                       /* only external symbols */
                     78: #define DB_STGY_PROC   2                       /* only procedures */
                     79: 
                     80: extern boolean_t       db_qualify_ambiguous_names;
                     81:                                        /* if TRUE, check across symbol tables
                     82:                                         * for multiple occurrences of a name.
                     83:                                         * Might slow down quite a bit
                     84:                                         * ..but the machine has nothing
                     85:                                         * else to do, now does it ? */
                     86: 
                     87: /*
                     88:  * Functions exported by the symtable module
                     89:  */
                     90: 
                     91: /* extend the list of symbol tables */
                     92: 
                     93: extern boolean_t       db_add_symbol_table(    int type,
                     94:                                                char * start,
                     95:                                                char * end,
                     96:                                                char *name,
                     97:                                                char *ref,
                     98:                                                char *map_pointer );
                     99: 
                    100: /* find symbol value given name */
                    101: 
                    102: extern int     db_value_of_name( char* name, db_expr_t* valuep);
                    103: 
                    104: /* find symbol given value */
                    105: 
                    106: extern db_sym_t        db_search_task_symbol(  db_addr_t val,
                    107:                                        db_strategy_t strategy,
                    108:                                        db_addr_t *offp,
                    109:                                        task_t task );
                    110: 
                    111: /* return name and value of symbol */
                    112: 
                    113: extern void    db_symbol_values( db_symtab_t *stab,
                    114:                                  db_sym_t sym,
                    115:                                  char** namep,
                    116:                                  db_expr_t* valuep);
                    117: 
                    118: /* find name&value given approx val */
                    119: 
                    120: #define db_find_sym_and_offset(val,namep,offp) \
1.1.1.2 ! root      121:         do {                                                           \
        !           122:          db_sym_t      s;                                              \
        !           123:          db_symbol_values(0, s = db_search_symbol(val,DB_STGY_ANY,offp) \
        !           124:                           ,namep,0);                                   \
        !           125:          db_free_symbol(s);                                            \
        !           126:        } while(0);
        !           127: 
1.1       root      128: 
                    129: /* ditto, but no locals */
                    130: #define db_find_xtrn_sym_and_offset(val,namep,offp)    \
1.1.1.2 ! root      131:         do {                                                           \
        !           132:          db_sym_t      s;                                              \
        !           133:          db_symbol_values(0, s = db_search_symbol(val,DB_STGY_XTRN,offp) \
        !           134:                           ,namep,0);                                   \
        !           135:          db_free_symbol(s);                                            \
        !           136:        } while(0);
1.1       root      137: 
                    138: /* find name&value given approx val */
                    139: 
                    140: #define db_find_task_sym_and_offset(val,namep,offp,task)       \
1.1.1.2 ! root      141:         do {                                                           \
        !           142:          db_sym_t      s;                                              \
        !           143:          db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_ANY \
        !           144:                                                        ,offp,task),    \
        !           145:                           namep, 0);                                   \
        !           146:          db_free_symbol(s);                                            \
        !           147:        } while(0);
1.1       root      148: 
                    149: /* ditto, but no locals */
                    150: #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task)  \
1.1.1.2 ! root      151:         do {                                                           \
        !           152:          db_sym_t      s;                                              \
        !           153:          db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_XTRN \
        !           154:                                                        ,offp,task),    \
        !           155:                           namep,0);                                    \
        !           156:          db_free_symbol(s);                                            \
        !           157:        } while(0);
1.1       root      158: 
                    159: /* find symbol in current task */
                    160: #define db_search_symbol(val,strgy,offp)       \
                    161:        db_search_task_symbol(val,strgy,offp,0)
                    162: 
                    163: /* strcmp, modulo leading char */
                    164: extern boolean_t       db_eqname( char* src, char* dst, char c );
                    165: 
                    166: /* print closest symbol to a value */
                    167: extern void    db_task_printsym( db_expr_t off,
                    168:                                  db_strategy_t strategy,
                    169:                                  task_t task);
                    170: 
                    171: /* print closest symbol to a value */
                    172: extern void    db_printsym( db_expr_t off, db_strategy_t strategy);
                    173: 
1.1.1.2 ! root      174: /* free a symbol */
        !           175: extern void db_free_symbol(db_sym_t s);
        !           176: 
        !           177: 
1.1       root      178: /*
                    179:  * Symbol table switch, defines the interface
                    180:  * to symbol-table specific routines.
                    181:  */
                    182: 
                    183: extern struct db_sym_switch {
                    184: 
                    185:        boolean_t       (*init)(
1.1.1.2 ! root      186:                                char *start,
1.1       root      187:                                char *end,
                    188:                                char *name,
                    189:                                char *task_addr
1.1.1.2 ! root      190:                                );
1.1       root      191: 
                    192:        db_sym_t        (*lookup)(
1.1.1.2 ! root      193:                                db_symtab_t *stab,
1.1       root      194:                                char *symstr
1.1.1.2 ! root      195:                                );
1.1       root      196:        db_sym_t        (*search_symbol)(
1.1.1.2 ! root      197:                                db_symtab_t *stab,
1.1       root      198:                                db_addr_t off,
                    199:                                db_strategy_t strategy,
                    200:                                db_expr_t *diffp
1.1.1.2 ! root      201:                                );
1.1       root      202: 
                    203:        boolean_t       (*line_at_pc)(
1.1.1.2 ! root      204:                                db_symtab_t     *stab,
1.1       root      205:                                db_sym_t        sym,
                    206:                                char            **file,
                    207:                                int             *line,
                    208:                                db_expr_t       pc
1.1.1.2 ! root      209:                                );
1.1       root      210: 
                    211:        void            (*symbol_values)(
1.1.1.2 ! root      212:                                db_symtab_t     *stab,
        !           213:                                db_sym_t        sym,
1.1       root      214:                                char            **namep,
                    215:                                db_expr_t       *valuep
1.1.1.2 ! root      216:                                );
1.1       root      217: 
1.1.1.2 ! root      218:        void            (*free_symbol)(
        !           219:                                db_sym_t        sym
        !           220:                                );
1.1       root      221: } x_db[];
                    222: 
                    223: #ifndef        symtab_type
                    224: #define        symtab_type(s)          SYMTAB_AOUT
                    225: #endif
                    226: 
                    227: #define        X_db_sym_init(s,e,n,t)          x_db[symtab_type(s)].init(s,e,n,t)
                    228: #define        X_db_lookup(s,n)                x_db[(s)->type].lookup(s,n)
                    229: #define        X_db_search_symbol(s,o,t,d)     x_db[(s)->type].search_symbol(s,o,t,d)
                    230: #define        X_db_line_at_pc(s,p,f,l,a)      x_db[(s)->type].line_at_pc(s,p,f,l,a)
1.1.1.2 ! root      231: #define        X_db_symbol_values(s,p,n,v)     x_db[(s)->type].symbol_values(s,p,n,v)
        !           232: #define        X_db_free_symbol(s,m)           x_db[(s)->type].free_symbol(m)
        !           233: 
        !           234: extern boolean_t db_line_at_pc(
        !           235:        db_sym_t sym,
        !           236:        char **filename,
        !           237:        int *linenum,
        !           238:        db_expr_t pc);
        !           239: 
        !           240: #endif

unix.superglobalmegacorp.com

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