db_sym.h revision 4
14Srgrimes/* 24Srgrimes * Mach Operating System 34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University 44Srgrimes * All Rights Reserved. 54Srgrimes * 64Srgrimes * Permission to use, copy, modify and distribute this software and its 74Srgrimes * documentation is hereby granted, provided that both the copyright 84Srgrimes * notice and this permission notice appear in all copies of the 94Srgrimes * software, derivative works or modified versions, and any portions 104Srgrimes * thereof, and that both notices appear in supporting documentation. 114Srgrimes * 124Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 134Srgrimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 144Srgrimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 154Srgrimes * 164Srgrimes * Carnegie Mellon requests users of this software to return to 174Srgrimes * 184Srgrimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 194Srgrimes * School of Computer Science 204Srgrimes * Carnegie Mellon University 214Srgrimes * Pittsburgh PA 15213-3890 224Srgrimes * 234Srgrimes * any improvements or extensions that they make and grant Carnegie the 244Srgrimes * rights to redistribute these changes. 254Srgrimes */ 264Srgrimes/* 274Srgrimes * HISTORY 284Srgrimes * $Log: db_sym.h,v $ 294Srgrimes * Revision 1.1 1992/03/25 21:45:29 pace 304Srgrimes * Initial revision 314Srgrimes * 324Srgrimes * Revision 2.3 91/02/05 17:07:12 mrt 334Srgrimes * Changed to new Mach copyright 344Srgrimes * [91/01/31 16:19:27 mrt] 354Srgrimes * 364Srgrimes * Revision 2.2 90/08/27 21:52:39 dbg 374Srgrimes * Changed type of db_sym_t to char * - it's a better type for an 384Srgrimes * opaque pointer. 394Srgrimes * [90/08/22 dbg] 404Srgrimes * 414Srgrimes * Created. 424Srgrimes * [90/08/19 af] 434Srgrimes * 444Srgrimes */ 454Srgrimes/* 464Srgrimes * Author: Alessandro Forin, Carnegie Mellon University 474Srgrimes * Date: 8/90 484Srgrimes */ 494Srgrimes 504Srgrimes/* 514Srgrimes * This module can handle multiple symbol tables 524Srgrimes */ 534Srgrimestypedef struct { 544Srgrimes char *name; /* symtab name */ 554Srgrimes char *start; /* symtab location */ 564Srgrimes char *end; 574Srgrimes char *private; /* optional machdep pointer */ 584Srgrimes} db_symtab_t; 594Srgrimes 604Srgrimesextern db_symtab_t *db_last_symtab; /* where last symbol was found */ 614Srgrimes 624Srgrimes/* 634Srgrimes * Symbol representation is specific to the symtab style: 644Srgrimes * BSD compilers use dbx' nlist, other compilers might use 654Srgrimes * a different one 664Srgrimes */ 674Srgrimestypedef char * db_sym_t; /* opaque handle on symbols */ 684Srgrimes#define DB_SYM_NULL ((db_sym_t)0) 694Srgrimes 704Srgrimes/* 714Srgrimes * Non-stripped symbol tables will have duplicates, for instance 724Srgrimes * the same string could match a parameter name, a local var, a 734Srgrimes * global var, etc. 744Srgrimes * We are most concern with the following matches. 754Srgrimes */ 764Srgrimestypedef int db_strategy_t; /* search strategy */ 774Srgrimes 784Srgrimes#define DB_STGY_ANY 0 /* anything goes */ 794Srgrimes#define DB_STGY_XTRN 1 /* only external symbols */ 804Srgrimes#define DB_STGY_PROC 2 /* only procedures */ 814Srgrimes 824Srgrimesextern boolean_t db_qualify_ambiguous_names; 834Srgrimes /* if TRUE, check across symbol tables 844Srgrimes * for multiple occurrences of a name. 854Srgrimes * Might slow down quite a bit */ 864Srgrimes 874Srgrimes/* 884Srgrimes * Functions exported by the symtable module 894Srgrimes */ 904Srgrimesextern void db_add_symbol_table(); 914Srgrimes /* extend the list of symbol tables */ 924Srgrimes 934Srgrimesextern int db_value_of_name(/* char*, db_expr_t* */); 944Srgrimes /* find symbol value given name */ 954Srgrimes 964Srgrimesextern db_sym_t db_search_symbol(/* db_expr_t, db_strategy_t, int* */); 974Srgrimes /* find symbol given value */ 984Srgrimes 994Srgrimesextern void db_symbol_values(/* db_sym_t, char**, db_expr_t* */); 1004Srgrimes /* return name and value of symbol */ 1014Srgrimes 1024Srgrimes#define db_find_sym_and_offset(val,namep,offp) \ 1034Srgrimes db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 1044Srgrimes /* find name&value given approx val */ 1054Srgrimes 1064Srgrimes#define db_find_xtrn_sym_and_offset(val,namep,offp) \ 1074Srgrimes db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 1084Srgrimes /* ditto, but no locals */ 1094Srgrimes 1104Srgrimesextern int db_eqname(/* char*, char*, char */); 1114Srgrimes /* strcmp, modulo leading char */ 1124Srgrimes 1134Srgrimesextern void db_printsym(/* db_expr_t, db_strategy_t */); 1144Srgrimes /* print closest symbol to a value */ 115