db_sym.h revision 27121
190075Sobrien/* 2132718Skan * Mach Operating System 390075Sobrien * Copyright (c) 1991,1990 Carnegie Mellon University 490075Sobrien * All Rights Reserved. 590075Sobrien * 690075Sobrien * Permission to use, copy, modify and distribute this software and its 790075Sobrien * documentation is hereby granted, provided that both the copyright 890075Sobrien * notice and this permission notice appear in all copies of the 990075Sobrien * software, derivative works or modified versions, and any portions 1090075Sobrien * thereof, and that both notices appear in supporting documentation. 1190075Sobrien * 1290075Sobrien * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 1390075Sobrien * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 1490075Sobrien * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 1590075Sobrien * 1690075Sobrien * Carnegie Mellon requests users of this software to return to 1790075Sobrien * 1890075Sobrien * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 1990075Sobrien * School of Computer Science 20132718Skan * Carnegie Mellon University 21132718Skan * Pittsburgh PA 15213-3890 2290075Sobrien * 2390075Sobrien * any improvements or extensions that they make and grant Carnegie the 2490075Sobrien * rights to redistribute these changes. 25117395Skan * 2690075Sobrien * $Id: db_sym.h,v 1.12 1997/02/22 09:28:30 peter Exp $ 2790075Sobrien */ 2890075Sobrien 2990075Sobrien#ifndef _DDB_DB_SYM_H_ 3090075Sobrien#define _DDB_DB_SYM_H_ 3190075Sobrien 3290075Sobrien/* 3390075Sobrien * Author: Alessandro Forin, Carnegie Mellon University 3490075Sobrien * Date: 8/90 3590075Sobrien */ 3690075Sobrien 3790075Sobrien/* 38117395Skan * This module can handle multiple symbol tables 39117395Skan */ 4090075Sobrientypedef struct { 4190075Sobrien char *name; /* symtab name */ 4290075Sobrien char *start; /* symtab location */ 4390075Sobrien char *end; 4490075Sobrien char *private; /* optional machdep pointer */ 4590075Sobrien} db_symtab_t; 46132718Skan 47132718Skanextern db_symtab_t *db_last_symtab; /* where last symbol was found */ 4890075Sobrien 4990075Sobrien/* 5090075Sobrien * Symbol representation is specific to the symtab style: 5190075Sobrien * BSD compilers use dbx' nlist, other compilers might use 5290075Sobrien * a different one 5390075Sobrien */ 54132718Skantypedef char * db_sym_t; /* opaque handle on symbols */ 5590075Sobrien#define DB_SYM_NULL ((db_sym_t)0) 5690075Sobrien 5790075Sobrien/* 5890075Sobrien * Non-stripped symbol tables will have duplicates, for instance 59132718Skan * the same string could match a parameter name, a local var, a 6090075Sobrien * global var, etc. 6190075Sobrien * We are most concern with the following matches. 6290075Sobrien */ 6390075Sobrientypedef int db_strategy_t; /* search strategy */ 64132718Skan 6590075Sobrien#define DB_STGY_ANY 0 /* anything goes */ 6690075Sobrien#define DB_STGY_XTRN 1 /* only external symbols */ 6790075Sobrien#define DB_STGY_PROC 2 /* only procedures */ 6890075Sobrien 6990075Sobrienextern boolean_t db_qualify_ambiguous_names; 70132718Skan /* if TRUE, check across symbol tables 7190075Sobrien * for multiple occurrences of a name. 7290075Sobrien * Might slow down quite a bit */ 7390075Sobrien 7490075Sobrien/* 75132718Skan * Functions exported by the symtable module 7690075Sobrien */ 7790075Sobrienvoid db_add_symbol_table __P((char *, char *, char *, char *)); 7890075Sobrien /* extend the list of symbol tables */ 7990075Sobrien 80132718Skandb_sym_t db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *)); 81132718Skan /* find symbol given value */ 8290075Sobrien 8390075Sobrienvoid db_symbol_values __P((db_sym_t, char **, db_expr_t *)); 8490075Sobrien /* return name and value of symbol */ 8590075Sobrien 86132718Skan#define db_find_sym_and_offset(val,namep,offp) \ 8790075Sobrien db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 8890075Sobrien /* find name&value given approx val */ 8990075Sobrien 9090075Sobrien#define db_find_xtrn_sym_and_offset(val,namep,offp) \ 91132718Skan db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 92132718Skan /* ditto, but no locals */ 9390075Sobrien 9490075Sobrienint db_eqname __P((char *, char *, int)); 95 /* strcmp, modulo leading char */ 96 97void db_printsym __P((db_expr_t, db_strategy_t)); 98 /* print closest symbol to a value */ 99 100int db_sym_numargs __P((db_sym_t, int *, char **)); 101 102boolean_t X_db_line_at_pc __P((db_symtab_t *symtab, db_sym_t cursym, 103 char **filename, int *linenum, 104 db_expr_t off)); 105db_sym_t X_db_lookup __P((db_symtab_t *stab, char *symstr)); 106db_sym_t X_db_search_symbol __P((db_symtab_t *symtab, db_addr_t off, 107 db_strategy_t strategy, 108 db_expr_t *diffp)); 109int X_db_sym_numargs __P((db_symtab_t *, db_sym_t, int *, 110 char **)); 111void X_db_symbol_values __P((db_sym_t sym, char **namep, 112 db_expr_t *valuep)); 113 114#endif /* !_DDB_DB_SYM_H_ */ 115