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. 255b81b6b3SRodney W. Grimes */ 265b81b6b3SRodney W. Grimes /* 275b81b6b3SRodney W. Grimes * HISTORY 285b81b6b3SRodney W. Grimes * $Log: db_sym.h,v $ 295b81b6b3SRodney W. Grimes * Revision 1.1 1992/03/25 21:45:29 pace 305b81b6b3SRodney W. Grimes * Initial revision 315b81b6b3SRodney W. Grimes * 325b81b6b3SRodney W. Grimes * Revision 2.3 91/02/05 17:07:12 mrt 335b81b6b3SRodney W. Grimes * Changed to new Mach copyright 345b81b6b3SRodney W. Grimes * [91/01/31 16:19:27 mrt] 355b81b6b3SRodney W. Grimes * 365b81b6b3SRodney W. Grimes * Revision 2.2 90/08/27 21:52:39 dbg 375b81b6b3SRodney W. Grimes * Changed type of db_sym_t to char * - it's a better type for an 385b81b6b3SRodney W. Grimes * opaque pointer. 395b81b6b3SRodney W. Grimes * [90/08/22 dbg] 405b81b6b3SRodney W. Grimes * 415b81b6b3SRodney W. Grimes * Created. 425b81b6b3SRodney W. Grimes * [90/08/19 af] 435b81b6b3SRodney W. Grimes * 445b81b6b3SRodney W. Grimes */ 455b81b6b3SRodney W. Grimes /* 465b81b6b3SRodney W. Grimes * Author: Alessandro Forin, Carnegie Mellon University 475b81b6b3SRodney W. Grimes * Date: 8/90 485b81b6b3SRodney W. Grimes */ 495b81b6b3SRodney W. Grimes 505b81b6b3SRodney W. Grimes /* 515b81b6b3SRodney W. Grimes * This module can handle multiple symbol tables 525b81b6b3SRodney W. Grimes */ 535b81b6b3SRodney W. Grimes typedef struct { 545b81b6b3SRodney W. Grimes char *name; /* symtab name */ 555b81b6b3SRodney W. Grimes char *start; /* symtab location */ 565b81b6b3SRodney W. Grimes char *end; 575b81b6b3SRodney W. Grimes char *private; /* optional machdep pointer */ 585b81b6b3SRodney W. Grimes } db_symtab_t; 595b81b6b3SRodney W. Grimes 605b81b6b3SRodney W. Grimes extern db_symtab_t *db_last_symtab; /* where last symbol was found */ 615b81b6b3SRodney W. Grimes 625b81b6b3SRodney W. Grimes /* 635b81b6b3SRodney W. Grimes * Symbol representation is specific to the symtab style: 645b81b6b3SRodney W. Grimes * BSD compilers use dbx' nlist, other compilers might use 655b81b6b3SRodney W. Grimes * a different one 665b81b6b3SRodney W. Grimes */ 675b81b6b3SRodney W. Grimes typedef char * db_sym_t; /* opaque handle on symbols */ 685b81b6b3SRodney W. Grimes #define DB_SYM_NULL ((db_sym_t)0) 695b81b6b3SRodney W. Grimes 705b81b6b3SRodney W. Grimes /* 715b81b6b3SRodney W. Grimes * Non-stripped symbol tables will have duplicates, for instance 725b81b6b3SRodney W. Grimes * the same string could match a parameter name, a local var, a 735b81b6b3SRodney W. Grimes * global var, etc. 745b81b6b3SRodney W. Grimes * We are most concern with the following matches. 755b81b6b3SRodney W. Grimes */ 765b81b6b3SRodney W. Grimes typedef int db_strategy_t; /* search strategy */ 775b81b6b3SRodney W. Grimes 785b81b6b3SRodney W. Grimes #define DB_STGY_ANY 0 /* anything goes */ 795b81b6b3SRodney W. Grimes #define DB_STGY_XTRN 1 /* only external symbols */ 805b81b6b3SRodney W. Grimes #define DB_STGY_PROC 2 /* only procedures */ 815b81b6b3SRodney W. Grimes 825b81b6b3SRodney W. Grimes extern boolean_t db_qualify_ambiguous_names; 835b81b6b3SRodney W. Grimes /* if TRUE, check across symbol tables 845b81b6b3SRodney W. Grimes * for multiple occurrences of a name. 855b81b6b3SRodney W. Grimes * Might slow down quite a bit */ 865b81b6b3SRodney W. Grimes 875b81b6b3SRodney W. Grimes /* 885b81b6b3SRodney W. Grimes * Functions exported by the symtable module 895b81b6b3SRodney W. Grimes */ 905b81b6b3SRodney W. Grimes extern void db_add_symbol_table(); 915b81b6b3SRodney W. Grimes /* extend the list of symbol tables */ 925b81b6b3SRodney W. Grimes 935b81b6b3SRodney W. Grimes extern int db_value_of_name(/* char*, db_expr_t* */); 945b81b6b3SRodney W. Grimes /* find symbol value given name */ 955b81b6b3SRodney W. Grimes 965b81b6b3SRodney W. Grimes extern db_sym_t db_search_symbol(/* db_expr_t, db_strategy_t, int* */); 975b81b6b3SRodney W. Grimes /* find symbol given value */ 985b81b6b3SRodney W. Grimes 995b81b6b3SRodney W. Grimes extern void db_symbol_values(/* db_sym_t, char**, db_expr_t* */); 1005b81b6b3SRodney W. Grimes /* return name and value of symbol */ 1015b81b6b3SRodney W. Grimes 1025b81b6b3SRodney W. Grimes #define db_find_sym_and_offset(val,namep,offp) \ 1035b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 1045b81b6b3SRodney W. Grimes /* find name&value given approx val */ 1055b81b6b3SRodney W. Grimes 1065b81b6b3SRodney W. Grimes #define db_find_xtrn_sym_and_offset(val,namep,offp) \ 1075b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 1085b81b6b3SRodney W. Grimes /* ditto, but no locals */ 1095b81b6b3SRodney W. Grimes 1105b81b6b3SRodney W. Grimes extern int db_eqname(/* char*, char*, char */); 1115b81b6b3SRodney W. Grimes /* strcmp, modulo leading char */ 1125b81b6b3SRodney W. Grimes 1135b81b6b3SRodney W. Grimes extern void db_printsym(/* db_expr_t, db_strategy_t */); 1145b81b6b3SRodney W. Grimes /* print closest symbol to a value */ 115