The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_sym.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,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  Software.Distribution@CS.CMU.EDU
   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  * HISTORY
   28  * $Log:        db_sym.h,v $
   29  * Revision 2.8  93/11/17  16:25:33  dbg
   30  *      Added db_line_at_pc, db_sym_parse_and_lookup.
   31  *      [93/10/11            dbg]
   32  * 
   33  * Revision 2.7  93/01/14  17:25:50  danner
   34  *      Handle coexisting symtable types.
   35  *      64bit cleanup, prototypes.
   36  *      [92/11/30            af]
   37  * 
   38  * Revision 2.6  91/10/09  16:02:45  af
   39  *      Added macro definitions of db_find_task_sym_and_offset(),
   40  *        db_find_xtrn_task_sym_and_offset(), db_search_symbol().
   41  *      [91/08/29            tak]
   42  * 
   43  * Revision 2.5  91/07/31  17:31:49  dbg
   44  *      Add map pointer and storage for name to db_symtab_t.
   45  *      [91/07/30  16:45:08  dbg]
   46  * 
   47  * Revision 2.4  91/05/14  15:36:08  mrt
   48  *      Correcting copyright
   49  * 
   50  * Revision 2.3  91/02/05  17:07:12  mrt
   51  *      Changed to new Mach copyright
   52  *      [91/01/31  16:19:27  mrt]
   53  * 
   54  * Revision 2.2  90/08/27  21:52:39  dbg
   55  *      Changed type of db_sym_t to char * - it's a better type for an
   56  *      opaque pointer.
   57  *      [90/08/22            dbg]
   58  * 
   59  *      Created.
   60  *      [90/08/19            af]
   61  * 
   62  */
   63 /*
   64  *      Author: Alessandro Forin, Carnegie Mellon University
   65  *      Date:   8/90
   66  */
   67 
   68 #ifndef _DDB_DB_SYM_H_
   69 #define _DDB_DB_SYM_H_
   70 
   71 #include <mach/boolean.h>
   72 #include <mach/machine/vm_types.h>
   73 #include <machine/db_machdep.h>
   74 
   75 /*
   76  * This module can handle multiple symbol tables,
   77  * of multiple types, at the same time
   78  */
   79 #define SYMTAB_NAME_LEN 32
   80 
   81 typedef struct {
   82         int             type;
   83 #define SYMTAB_AOUT     0
   84 #define SYMTAB_COFF     1
   85 #define SYMTAB_MACHDEP  2
   86         char            *start;         /* symtab location */
   87         char            *end;
   88         char            *private;       /* optional machdep pointer */
   89         char            *map_pointer;   /* symbols are for this map only,
   90                                            if not null */
   91         char            name[SYMTAB_NAME_LEN];
   92                                         /* symtab name */
   93 } db_symtab_t;
   94 
   95 extern db_symtab_t      *db_last_symtab; /* where last symbol was found */
   96 
   97 /*
   98  * Symbol representation is specific to the symtab style:
   99  * BSD compilers use dbx' nlist, other compilers might use
  100  * a different one
  101  */
  102 typedef char *          db_sym_t;       /* opaque handle on symbols */
  103 #define DB_SYM_NULL     ((db_sym_t)0)
  104 
  105 /*
  106  * Non-stripped symbol tables will have duplicates, for instance
  107  * the same string could match a parameter name, a local var, a
  108  * global var, etc.
  109  * We are most concerned with the following matches.
  110  */
  111 typedef int             db_strategy_t;  /* search strategy */
  112 
  113 #define DB_STGY_ANY     0                       /* anything goes */
  114 #define DB_STGY_XTRN    1                       /* only external symbols */
  115 #define DB_STGY_PROC    2                       /* only procedures */
  116 
  117 extern boolean_t        db_qualify_ambiguous_names;
  118                                         /* if TRUE, check across symbol tables
  119                                          * for multiple occurrences of a name.
  120                                          * Might slow down quite a bit
  121                                          * ..but the machine has nothing
  122                                          * else to do, now does it ? */
  123 
  124 /*
  125  * Functions exported by the symtable module
  126  */
  127 
  128 /* extend the list of symbol tables */
  129 
  130 extern boolean_t        db_add_symbol_table(    int type,
  131                                                 char * start,
  132                                                 char * end,
  133                                                 char *name,
  134                                                 char *ref,
  135                                                 char *map_pointer );
  136 
  137 /* find symbol value given name */
  138 
  139 extern int      db_value_of_name( char* name, db_expr_t* valuep);
  140 
  141 /* find symbol given value */
  142 
  143 extern db_sym_t db_search_task_symbol(  db_addr_t val,
  144                                         db_strategy_t strategy,
  145                                         db_addr_t *offp,
  146                                         task_t task );
  147 
  148 /* return name and value of symbol */
  149 
  150 extern void     db_symbol_values( db_symtab_t *stab,
  151                                   db_sym_t sym,
  152                                   char** namep,
  153                                   db_expr_t* valuep);
  154 
  155 /* find name&value given approx val */
  156 
  157 #define db_find_sym_and_offset(val,namep,offp)  \
  158         db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
  159 
  160 /* ditto, but no locals */
  161 #define db_find_xtrn_sym_and_offset(val,namep,offp)     \
  162         db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
  163 
  164 /* find name&value given approx val */
  165 
  166 #define db_find_task_sym_and_offset(val,namep,offp,task)        \
  167         db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task),  \
  168                          namep, 0)
  169 
  170 /* ditto, but no locals */
  171 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task)   \
  172         db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
  173                          namep,0)
  174 
  175 /* find symbol in current task */
  176 #define db_search_symbol(val,strgy,offp)        \
  177         db_search_task_symbol(val,strgy,offp,0)
  178 
  179 /* strcmp, modulo leading char */
  180 extern boolean_t        db_eqname( char* src, char* dst, char c );
  181 
  182 /* print closest symbol to a value */
  183 extern void     db_task_printsym( db_expr_t off,
  184                                   db_strategy_t strategy,
  185                                   task_t task);
  186 
  187 /* print closest symbol to a value */
  188 extern void     db_printsym( db_expr_t off, db_strategy_t strategy);
  189 
  190 /* find filename/line in current symbol table for location */
  191 extern boolean_t        db_line_at_pc( db_sym_t sym,
  192                                        char **filename, /* out */
  193                                        int  *linenum,   /* out */
  194                                        db_expr_t pc);
  195 
  196 /* parse a symbol string into a file name, line number and symbol */
  197 extern db_sym_t
  198 db_sym_parse_and_lookup(
  199         db_sym_t        (*func)(
  200                             db_symtab_t *symtab,
  201                             char        *file_name,
  202                             char        *sym_name,
  203                             int         line_number),
  204         db_symtab_t     *symtab,
  205         char            *symstr);
  206 
  207 /*
  208  * Symbol table switch, defines the interface
  209  * to symbol-table specific routines.
  210  * [NOTE: incomplete prototypes cuz broken compiler]
  211  */
  212 
  213 extern struct db_sym_switch {
  214 
  215         boolean_t       (*init)(
  216 /*                              char *start,
  217                                 char *end,
  218                                 char *name,
  219                                 char *task_addr
  220 */                              );
  221 
  222         db_sym_t        (*lookup)(
  223 /*                              db_symtab_t *stab,
  224                                 char *symstr
  225 */                              );
  226         db_sym_t        (*search_symbol)(
  227 /*                              db_symtab_t *stab,
  228                                 db_addr_t off,
  229                                 db_strategy_t strategy,
  230                                 db_expr_t *diffp
  231 */                              );
  232 
  233         boolean_t       (*line_at_pc)(
  234 /*                              db_symtab_t     *stab,
  235                                 db_sym_t        sym,
  236                                 char            **file,
  237                                 int             *line,
  238                                 db_expr_t       pc
  239 */                              );
  240 
  241         void            (*symbol_values)(
  242 /*                              db_sym_t        sym,
  243                                 char            **namep,
  244                                 db_expr_t       *valuep
  245 */                              );
  246 
  247 } x_db[];
  248 
  249 #ifndef symtab_type
  250 #define symtab_type(s)          SYMTAB_AOUT
  251 #endif
  252 
  253 #define X_db_sym_init(s,e,n,t)          x_db[symtab_type(s)].init(s,e,n,t)
  254 #define X_db_lookup(s,n)                x_db[(s)->type].lookup(s,n)
  255 #define X_db_search_symbol(s,o,t,d)     x_db[(s)->type].search_symbol(s,o,t,d)
  256 #define X_db_line_at_pc(s,p,f,l,a)      x_db[(s)->type].line_at_pc(s,p,f,l,a)
  257 #define X_db_symbol_values(s,p,n,v)     x_db[(s)->type].symbol_values(p,n,v)
  258 
  259 #endif  /* _DDB_DB_SYM_H_ */

Cache object: 9d41898ac89b2214712c8c971268e60a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.