db_sym.h revision 12515
167754Smsmith/* 267754Smsmith * Mach Operating System 367754Smsmith * Copyright (c) 1991,1990 Carnegie Mellon University 467754Smsmith * All Rights Reserved. 567754Smsmith * 667754Smsmith * Permission to use, copy, modify and distribute this software and its 7217365Sjkim * documentation is hereby granted, provided that both the copyright 8217365Sjkim * notice and this permission notice appear in all copies of the 970243Smsmith * software, derivative works or modified versions, and any portions 1067754Smsmith * thereof, and that both notices appear in supporting documentation. 11217365Sjkim * 12217365Sjkim * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 13217365Sjkim * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 14217365Sjkim * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 15217365Sjkim * 16217365Sjkim * Carnegie Mellon requests users of this software to return to 17217365Sjkim * 18217365Sjkim * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 19217365Sjkim * School of Computer Science 20217365Sjkim * Carnegie Mellon University 21217365Sjkim * Pittsburgh PA 15213-3890 22217365Sjkim * 23217365Sjkim * any improvements or extensions that they make and grant Carnegie the 24217365Sjkim * rights to redistribute these changes. 2567754Smsmith * 26217365Sjkim * $Id: db_sym.h,v 1.9 1995/11/24 13:53:01 bde Exp $ 27217365Sjkim */ 28217365Sjkim 2967754Smsmith#ifndef _DDB_DB_SYM_H_ 30217365Sjkim#define _DDB_DB_SYM_H_ 31217365Sjkim 32217365Sjkim/* 33217365Sjkim * Author: Alessandro Forin, Carnegie Mellon University 34217365Sjkim * Date: 8/90 35217365Sjkim */ 36217365Sjkim 37217365Sjkim/* 38217365Sjkim * This module can handle multiple symbol tables 39217365Sjkim */ 40217365Sjkimtypedef struct { 41217365Sjkim char *name; /* symtab name */ 42217365Sjkim char *start; /* symtab location */ 4367754Smsmith char *end; 4467754Smsmith char *private; /* optional machdep pointer */ 4567754Smsmith} db_symtab_t; 46193341Sjkim 47193341Sjkimextern db_symtab_t *db_last_symtab; /* where last symbol was found */ 48193341Sjkim 49193341Sjkim/* 50193341Sjkim * Symbol representation is specific to the symtab style: 51206117Sjkim * BSD compilers use dbx' nlist, other compilers might use 5267754Smsmith * a different one 5367754Smsmith */ 5477424Smsmithtypedef char * db_sym_t; /* opaque handle on symbols */ 5591116Smsmith#define DB_SYM_NULL ((db_sym_t)0) 5667754Smsmith 57151937Sjkim/* 5867754Smsmith * Non-stripped symbol tables will have duplicates, for instance 59151937Sjkim * the same string could match a parameter name, a local var, a 60151937Sjkim * global var, etc. 61167802Sjkim * We are most concern with the following matches. 62151937Sjkim */ 63151937Sjkimtypedef int db_strategy_t; /* search strategy */ 64151937Sjkim 65167802Sjkim#define DB_STGY_ANY 0 /* anything goes */ 66151937Sjkim#define DB_STGY_XTRN 1 /* only external symbols */ 67151937Sjkim#define DB_STGY_PROC 2 /* only procedures */ 68151937Sjkim 69167802Sjkimextern boolean_t db_qualify_ambiguous_names; 70151937Sjkim /* if TRUE, check across symbol tables 71151937Sjkim * for multiple occurrences of a name. 72151937Sjkim * Might slow down quite a bit */ 7380062Smsmith 7467754Smsmith/* 75151937Sjkim * Functions exported by the symtable module 7667754Smsmith */ 77151937Sjkimvoid db_add_symbol_table __P((char *, char *, char *, char *)); 78151937Sjkim /* extend the list of symbol tables */ 79151937Sjkim 80151937Sjkimdb_sym_t db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *)); 8167754Smsmith /* find symbol given value */ 8267754Smsmith 8367754Smsmithvoid db_symbol_values __P((db_sym_t, char **, db_expr_t *)); 84151937Sjkim /* return name and value of symbol */ 85151937Sjkim 8667754Smsmith#define db_find_sym_and_offset(val,namep,offp) \ 8780062Smsmith db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 8867754Smsmith /* find name&value given approx val */ 8967754Smsmith 90151937Sjkim#define db_find_xtrn_sym_and_offset(val,namep,offp) \ 91151937Sjkim db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 92151937Sjkim /* ditto, but no locals */ 93151937Sjkim 94151937Sjkimint db_eqname __P((char *, char *, char)); 95151937Sjkim /* strcmp, modulo leading char */ 96151937Sjkim 97151937Sjkimvoid db_printsym __P((db_expr_t, db_strategy_t)); 98151937Sjkim /* print closest symbol to a value */ 99151937Sjkim 100151937Sjkimint db_sym_numargs __P((db_sym_t, int *, char **)); 101151937Sjkim 102151937Sjkimboolean_t X_db_line_at_pc __P((db_symtab_t *symtab, db_sym_t cursym, 103151937Sjkim char **filename, int *linenum, 104151937Sjkim db_expr_t off)); 105151937Sjkimdb_sym_t X_db_lookup __P((db_symtab_t *stab, char *symstr)); 106151937Sjkimdb_sym_t X_db_search_symbol __P((db_symtab_t *symtab, db_addr_t off, 107167802Sjkim db_strategy_t strategy, 108151937Sjkim db_expr_t *diffp)); 109151937Sjkimint X_db_sym_numargs __P((db_symtab_t *, db_sym_t, int *, 110151937Sjkim char **)); 111151937Sjkimvoid X_db_symbol_values __P((db_sym_t sym, char **namep, 112151937Sjkim db_expr_t *valuep)); 113151937Sjkim 114151937Sjkim#endif /* !_DDB_DB_SYM_H_ */ 115151937Sjkim