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 * 264753168fSBruce Evans * $Id: db_sym.h,v 1.8 1995/05/30 07:57:11 rgrimes Exp $ 275b81b6b3SRodney W. Grimes */ 280edf66ecSRodney W. Grimes 296437fb2cSGarrett Wollman #ifndef _DDB_DB_SYM_H_ 304753168fSBruce Evans #define _DDB_DB_SYM_H_ 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 */ 774753168fSBruce Evans void db_add_symbol_table __P((char *, char *, char *, char *)); 785b81b6b3SRodney W. Grimes /* extend the list of symbol tables */ 795b81b6b3SRodney W. Grimes 804753168fSBruce Evans db_sym_t db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *)); 815b81b6b3SRodney W. Grimes /* find symbol given value */ 825b81b6b3SRodney W. Grimes 834753168fSBruce Evans void db_symbol_values __P((db_sym_t, char **, db_expr_t *)); 845b81b6b3SRodney W. Grimes /* return name and value of symbol */ 855b81b6b3SRodney W. Grimes 865b81b6b3SRodney W. Grimes #define db_find_sym_and_offset(val,namep,offp) \ 875b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 885b81b6b3SRodney W. Grimes /* find name&value given approx val */ 895b81b6b3SRodney W. Grimes 905b81b6b3SRodney W. Grimes #define db_find_xtrn_sym_and_offset(val,namep,offp) \ 915b81b6b3SRodney W. Grimes db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 925b81b6b3SRodney W. Grimes /* ditto, but no locals */ 935b81b6b3SRodney W. Grimes 944753168fSBruce Evans int db_eqname __P((char *, char *, char)); 955b81b6b3SRodney W. Grimes /* strcmp, modulo leading char */ 965b81b6b3SRodney W. Grimes 974753168fSBruce Evans void db_printsym __P((db_expr_t, db_strategy_t)); 985b81b6b3SRodney W. Grimes /* print closest symbol to a value */ 99f23b4c91SGarrett Wollman 1004753168fSBruce Evans boolean_t db_line_at_pc __P((db_sym_t, char **, int *, db_expr_t)); 1014753168fSBruce Evans int db_sym_numargs __P((db_sym_t, int *, char **)); 1024753168fSBruce Evans 1034753168fSBruce Evans boolean_t X_db_line_at_pc __P((db_symtab_t *symtab, db_sym_t cursym, 1044753168fSBruce Evans char **filename, int *linenum, 1054753168fSBruce Evans db_expr_t off)); 1064753168fSBruce Evans db_sym_t X_db_lookup __P((db_symtab_t *stab, char *symstr)); 1074753168fSBruce Evans db_sym_t X_db_search_symbol __P((db_symtab_t *symtab, db_addr_t off, 1084753168fSBruce Evans db_strategy_t strategy, 1094753168fSBruce Evans db_expr_t *diffp)); 1104753168fSBruce Evans void X_db_sym_init __P((int *symtab, char *esymtab, char *name)); 1114753168fSBruce Evans int X_db_sym_numargs __P((db_symtab_t *, db_sym_t, int *, 1124753168fSBruce Evans char **)); 1134753168fSBruce Evans void X_db_symbol_values __P((db_sym_t sym, char **namep, 1144753168fSBruce Evans db_expr_t *valuep)); 1154753168fSBruce Evans 1164753168fSBruce Evans #endif /* !_DDB_DB_SYM_H_ */ 117