/*-1* SPDX-License-Identifier: MIT-CMU2*3* Mach Operating System4* Copyright (c) 1991,1990 Carnegie Mellon University5* All Rights Reserved.6*7* Permission to use, copy, modify and distribute this software and its8* documentation is hereby granted, provided that both the copyright9* notice and this permission notice appear in all copies of the10* software, derivative works or modified versions, and any portions11* thereof, and that both notices appear in supporting documentation.12*13* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS14* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR15* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.16*17* Carnegie Mellon requests users of this software to return to18*19* Software Distribution Coordinator or [email protected]20* School of Computer Science21* Carnegie Mellon University22* Pittsburgh PA 15213-389023*24* any improvements or extensions that they make and grant Carnegie the25* rights to redistribute these changes.26*/2728#ifndef _DDB_DB_SYM_H_29#define _DDB_DB_SYM_H_3031/*32* Author: Alessandro Forin, Carnegie Mellon University33* Date: 8/9034*/3536/*37* This module can handle multiple symbol tables38*/39typedef struct {40char *name; /* symtab name */41char *start; /* symtab location */42char *end;43char *private; /* optional machdep pointer */44} db_symtab_t;4546/*47* Symbol representation is specific to the symtab style:48* BSD compilers use dbx' nlist, other compilers might use49* a different one50*/51typedef char * db_sym_t; /* opaque handle on symbols */52typedef const char * c_db_sym_t; /* const opaque handle on symbols */53#define DB_SYM_NULL ((db_sym_t)0)54#define C_DB_SYM_NULL ((c_db_sym_t)0)5556/*57* Non-stripped symbol tables will have duplicates, for instance58* the same string could match a parameter name, a local var, a59* global var, etc.60* We are most concern with the following matches.61*/62typedef int db_strategy_t; /* search strategy */6364#define DB_STGY_ANY 0 /* anything goes */65#define DB_STGY_XTRN 1 /* only external symbols */66#define DB_STGY_PROC 2 /* only procedures */6768/*69* Functions exported by the symtable module70*/71void db_add_symbol_table(char *, char *, char *, char *);72/* extend the list of symbol tables */7374c_db_sym_t db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *);75/* find symbol given value */7677void db_symbol_values(c_db_sym_t, const char **, db_expr_t *);78/* return name and value of symbol */7980#define db_find_sym_and_offset(val,namep,offp) \81db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)82/* find name&value given approx val */8384#define db_find_xtrn_sym_and_offset(val,namep,offp) \85db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)86/* ditto, but no locals */8788bool db_eqname(const char *, const char *, int);89/* strcmp, modulo leading char */9091void db_printsym(db_expr_t, db_strategy_t);92/* print closest symbol to a value */9394bool db_sym_numargs(c_db_sym_t, int *, char **);9596bool X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,97char **filename, int *linenum, db_expr_t off);98c_db_sym_t X_db_lookup(db_symtab_t *stab, const char *symstr);99c_db_sym_t X_db_search_symbol(db_symtab_t *symtab, db_addr_t off,100db_strategy_t strategy, db_expr_t *diffp);101bool X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);102void X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,103const char **namep, db_expr_t *valuep);104105void db_decode_syscall(struct thread *td, u_int number);106107#endif /* !_DDB_DB_SYM_H_ */108109110