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