15b81b6b3SRodney W. Grimes /* 25b81b6b3SRodney W. Grimes * Mach Operating System 35b81b6b3SRodney W. Grimes * Copyright (c) 1991,1990 Carnegie Mellon University 45b81b6b3SRodney W. Grimes * All Rights Reserved. 55b81b6b3SRodney W. Grimes * 65b81b6b3SRodney W. Grimes * Permission to use, copy, modify and distribute this software and its 75b81b6b3SRodney W. Grimes * documentation is hereby granted, provided that both the copyright 85b81b6b3SRodney W. Grimes * notice and this permission notice appear in all copies of the 95b81b6b3SRodney W. Grimes * software, derivative works or modified versions, and any portions 105b81b6b3SRodney W. Grimes * thereof, and that both notices appear in supporting documentation. 115b81b6b3SRodney W. Grimes * 125b81b6b3SRodney W. Grimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 135b81b6b3SRodney W. Grimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 145b81b6b3SRodney W. Grimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 155b81b6b3SRodney W. Grimes * 165b81b6b3SRodney W. Grimes * Carnegie Mellon requests users of this software to return to 175b81b6b3SRodney W. Grimes * 185b81b6b3SRodney W. Grimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 195b81b6b3SRodney W. Grimes * School of Computer Science 205b81b6b3SRodney W. Grimes * Carnegie Mellon University 215b81b6b3SRodney W. Grimes * Pittsburgh PA 15213-3890 225b81b6b3SRodney W. Grimes * 235b81b6b3SRodney W. Grimes * any improvements or extensions that they make and grant Carnegie the 245b81b6b3SRodney W. Grimes * rights to redistribute these changes. 250edf66ecSRodney W. Grimes * 266437fb2cSGarrett Wollman * $Id: db_sym.h,v 1.2 1993/10/16 16:47:27 rgrimes Exp $ 275b81b6b3SRodney W. Grimes */ 280edf66ecSRodney W. Grimes 296437fb2cSGarrett Wollman #ifndef _DDB_DB_SYM_H_ 306437fb2cSGarrett Wollman #define _DDB_DB_SYM_H_ 1 316437fb2cSGarrett Wollman 325b81b6b3SRodney W. Grimes /* 335b81b6b3SRodney W. Grimes * Author: Alessandro Forin, Carnegie Mellon University 345b81b6b3SRodney W. Grimes * Date: 8/90 355b81b6b3SRodney W. Grimes */ 365b81b6b3SRodney W. Grimes 375b81b6b3SRodney W. Grimes /* 385b81b6b3SRodney W. Grimes * This module can handle multiple symbol tables 395b81b6b3SRodney W. Grimes */ 405b81b6b3SRodney W. Grimes typedef struct { 415b81b6b3SRodney W. Grimes char *name; /* symtab name */ 425b81b6b3SRodney W. Grimes char *start; /* symtab location */ 435b81b6b3SRodney W. Grimes char *end; 445b81b6b3SRodney W. Grimes char *private; /* optional machdep pointer */ 455b81b6b3SRodney W. Grimes } db_symtab_t; 465b81b6b3SRodney W. Grimes 475b81b6b3SRodney W. Grimes extern db_symtab_t *db_last_symtab; /* where last symbol was found */ 485b81b6b3SRodney W. Grimes 495b81b6b3SRodney W. Grimes /* 505b81b6b3SRodney W. Grimes * Symbol representation is specific to the symtab style: 515b81b6b3SRodney W. Grimes * BSD compilers use dbx' nlist, other compilers might use 525b81b6b3SRodney W. Grimes * a different one 535b81b6b3SRodney W. Grimes */ 545b81b6b3SRodney W. Grimes typedef char * db_sym_t; /* opaque handle on symbols */ 555b81b6b3SRodney W. Grimes #define DB_SYM_NULL ((db_sym_t)0) 565b81b6b3SRodney W. Grimes 575b81b6b3SRodney W. Grimes /* 585b81b6b3SRodney W. Grimes * Non-stripped symbol tables will have duplicates, for instance 595b81b6b3SRodney W. Grimes * the same string could match a parameter name, a local var, a 605b81b6b3SRodney W. Grimes * global var, etc. 615b81b6b3SRodney W. Grimes * We are most concern with the following matches. 625b81b6b3SRodney W. Grimes */ 635b81b6b3SRodney W. Grimes typedef int db_strategy_t; /* search strategy */ 645b81b6b3SRodney W. Grimes 655b81b6b3SRodney W. Grimes #define DB_STGY_ANY 0 /* anything goes */ 665b81b6b3SRodney W. Grimes #define DB_STGY_XTRN 1 /* only external symbols */ 675b81b6b3SRodney W. Grimes #define DB_STGY_PROC 2 /* only procedures */ 685b81b6b3SRodney W. Grimes 695b81b6b3SRodney W. Grimes extern boolean_t db_qualify_ambiguous_names; 705b81b6b3SRodney W. Grimes /* if TRUE, check across symbol tables 715b81b6b3SRodney W. Grimes * for multiple occurrences of a name. 725b81b6b3SRodney W. Grimes * Might slow down quite a bit */ 735b81b6b3SRodney W. Grimes 745b81b6b3SRodney W. Grimes /* 755b81b6b3SRodney W. Grimes * Functions exported by the symtable module 765b81b6b3SRodney W. Grimes */ 775b81b6b3SRodney W. Grimes extern void db_add_symbol_table(); 785b81b6b3SRodney W. Grimes /* extend the list of symbol tables */ 795b81b6b3SRodney W. Grimes 805b81b6b3SRodney W. Grimes extern int db_value_of_name(/* char*, db_expr_t* */); 815b81b6b3SRodney W. Grimes /* find symbol value given name */ 825b81b6b3SRodney W. Grimes 835b81b6b3SRodney W. Grimes extern db_sym_t db_search_symbol(/* db_expr_t, db_strategy_t, int* */); 845b81b6b3SRodney W. Grimes /* find symbol given value */ 855b81b6b3SRodney W. Grimes 865b81b6b3SRodney W. Grimes extern void db_symbol_values(/* db_sym_t, char**, db_expr_t* */); 875b81b6b3SRodney W. Grimes /* return name and value of symbol */ 885b81b6b3SRodney W. Grimes 895b81b6b3SRodney W. Grimes #define db_find_sym_and_offset(val,namep,offp) \ 905b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 915b81b6b3SRodney W. Grimes /* find name&value given approx val */ 925b81b6b3SRodney W. Grimes 935b81b6b3SRodney W. Grimes #define db_find_xtrn_sym_and_offset(val,namep,offp) \ 945b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 955b81b6b3SRodney W. Grimes /* ditto, but no locals */ 965b81b6b3SRodney W. Grimes 975b81b6b3SRodney W. Grimes extern int db_eqname(/* char*, char*, char */); 985b81b6b3SRodney W. Grimes /* strcmp, modulo leading char */ 995b81b6b3SRodney W. Grimes 1005b81b6b3SRodney W. Grimes extern void db_printsym(/* db_expr_t, db_strategy_t */); 1015b81b6b3SRodney W. Grimes /* print closest symbol to a value */ 1026437fb2cSGarrett Wollman #endif /* _DDB_DB_SYM_H_ */ 103