root/ddb/db_sym.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. db_symtab_t
  2. db_symformat_t

    1 /*      $NetBSD: db_sym.h,v 1.13 2000/05/25 19:57:36 jhawk Exp $        */
    2 
    3 /* 
    4  * Mach Operating System
    5  * Copyright (c) 1993,1992,1991,1990 Carnegie Mellon University
    6  * All Rights Reserved.
    7  * 
    8  * Permission to use, copy, modify and distribute this software and its
    9  * documentation is hereby granted, provided that both the copyright
   10  * notice and this permission notice appear in all copies of the
   11  * software, derivative works or modified versions, and any portions
   12  * thereof, and that both notices appear in supporting documentation.
   13  * 
   14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   17  * 
   18  * Carnegie Mellon requests users of this software to return to
   19  * 
   20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   21  *  School of Computer Science
   22  *  Carnegie Mellon University
   23  *  Pittsburgh PA 15213-3890
   24  * 
   25  * any improvements or extensions that they make and grant Carnegie Mellon
   26  * the rights to redistribute these changes.
   27  *
   28  *      Author: Alessandro Forin, Carnegie Mellon University
   29  *      Date:   8/90
   30  */
   31 
   32 /*
   33  * This module can handle multiple symbol tables
   34  */
   35 typedef struct {
   36         const char      *name;          /* symtab name */
   37         char            *start;         /* symtab location */
   38         char            *end;
   39         char            *private;       /* optional machdep pointer */
   40 } db_symtab_t;
   41 
   42 extern db_symtab_t      *db_last_symtab; /* where last symbol was found */
   43 
   44 /*
   45  * Symbol representation is specific to the symtab style:
   46  * BSD compilers use dbx' nlist, other compilers might use
   47  * a different one
   48  */
   49 typedef char *          db_sym_t;       /* opaque handle on symbols */
   50 #define DB_SYM_NULL     ((db_sym_t)0)
   51 
   52 /*
   53  * Non-stripped symbol tables will have duplicates, for instance
   54  * the same string could match a parameter name, a local var, a
   55  * global var, etc.
   56  * We are most concern with the following matches.
   57  */
   58 typedef int             db_strategy_t;  /* search strategy */
   59 
   60 #define DB_STGY_ANY     0                       /* anything goes */
   61 #define DB_STGY_XTRN    1                       /* only external symbols */
   62 #define DB_STGY_PROC    2                       /* only procedures */
   63 
   64 
   65 /*
   66  * Internal db_forall function calling convention:
   67  *
   68  * (*db_forall_func)(stab, sym, name, suffix, prefix, arg);
   69  *
   70  * stab is the symbol table, symbol the (opaque) symbol pointer,
   71  * name the name of the symbol, suffix a string representing
   72  * the type, prefix an initial ignorable function prefix (e.g. "_"
   73  * in a.out), and arg an opaque argument to be passed in.
   74  */
   75 typedef void (db_forall_func_t)(db_symtab_t *, db_sym_t, char *, char *, int, void *);
   76 
   77 void            X_db_forall(db_symtab_t *,
   78                     db_forall_func_t db_forall_func, void *);
   79 
   80 /*
   81  * A symbol table may be in one of many formats.  All symbol tables
   82  * must be of the same format as the master kernel symbol table.
   83  */
   84 typedef struct {
   85         const char *sym_format;
   86         boolean_t (*sym_init)(int, void *, void *, const char *);
   87         db_sym_t (*sym_lookup)(db_symtab_t *, char *);
   88         db_sym_t (*sym_search)(db_symtab_t *, db_addr_t, db_strategy_t,
   89                 db_expr_t *);
   90         void    (*sym_value)(db_symtab_t *, db_sym_t, char **,
   91                 db_expr_t *);
   92         boolean_t (*sym_line_at_pc)(db_symtab_t *, db_sym_t,
   93                 char **, int *, db_expr_t);
   94         boolean_t (*sym_numargs)(db_symtab_t *, db_sym_t, int *,
   95                 char **);
   96         void    (*sym_forall)(db_symtab_t *,
   97                 db_forall_func_t *db_forall_func, void *);
   98 } db_symformat_t;
   99 
  100 extern boolean_t        db_qualify_ambiguous_names;
  101                                         /* if TRUE, check across symbol tables
  102                                          * for multiple occurrences of a name.
  103                                          * Might slow down quite a bit */
  104 
  105 extern unsigned int db_maxoff;          /* like gdb's "max-symbolic-offset" */
  106 /*
  107  * Functions exported by the symtable module
  108  */
  109 int db_add_symbol_table(char *, char *, const char *, char *);
  110                                         /* extend the list of symbol tables */
  111 
  112 void db_del_symbol_table(char *);
  113                                         /* remove a symbol table from list */
  114 
  115 boolean_t db_eqname(char *, char *, int);
  116                                         /* strcmp, modulo leading char */
  117 
  118 int db_value_of_name(char *, db_expr_t *);
  119                                         /* find symbol value given name */
  120 
  121 db_sym_t db_lookup(char *);
  122 
  123 void db_sifting(char *, int);
  124                                 /* print partially matching symbol names */
  125 
  126 boolean_t db_symbol_is_ambiguous(db_sym_t);
  127 
  128 db_sym_t db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *);
  129                                         /* find symbol given value */
  130 
  131 void db_symbol_values(db_sym_t, char **, db_expr_t *);
  132                                         /* return name and value of symbol */
  133 
  134 #define db_find_sym_and_offset(val,namep,offp)  \
  135         db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
  136                                         /* find name&value given approx val */
  137 
  138 #define db_find_xtrn_sym_and_offset(val,namep,offp)     \
  139         db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
  140                                         /* ditto, but no locals */
  141 
  142 void db_printsym(db_expr_t, db_strategy_t, int (*)(const char *, ...));
  143                                         /* print closest symbol to a value */
  144 
  145 boolean_t db_line_at_pc(db_sym_t, char **, int *, db_expr_t);
  146 
  147 int db_sym_numargs(db_sym_t, int *, char **);
  148 char *db_qualify(db_sym_t, const char *);
  149 
  150 #ifdef DB_AOUT_SYMBOLS
  151 extern  db_symformat_t db_symformat_aout;
  152 #endif
  153 #ifdef DB_ELF_SYMBOLS
  154 extern  db_symformat_t db_symformat_elf;
  155 #endif

/* [<][>][^][v][top][bottom][index][help] */