1 /* $NetBSD: db_sym.h,v 1.13 2000/05/25 19:57:36 jhawk Exp $ */ 2 3 /* 4 * Mach Operating System 5 * Copyright (c) 1993,1992,1991,1990 Carnegie Mellon University 6 * All Rights Reserved. 7 * 8 * Permission to use, copy, modify and distribute this software and its 9 * documentation is hereby granted, provided that both the copyright 10 * notice and this permission notice appear in all copies of the 11 * software, derivative works or modified versions, and any portions 12 * thereof, and that both notices appear in supporting documentation. 13 * 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * Carnegie Mellon requests users of this software to return to 19 * 20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * School of Computer Science 22 * Carnegie Mellon University 23 * Pittsburgh PA 15213-3890 24 * 25 * any improvements or extensions that they make and grant Carnegie Mellon 26 * the rights to redistribute these changes. 27 * 28 * Author: Alessandro Forin, Carnegie Mellon University 29 * Date: 8/90 30 */ 31 32 #ifndef _DDB_DB_SYM_H_ 33 #define _DDB_DB_SYM_H_ 34 35 #include <sys/stdint.h> 36 #include <sys/exec_elf.h> 37 38 /* 39 * Non-stripped symbol tables will have duplicates, for instance 40 * the same string could match a parameter name, a local var, a 41 * global var, etc. 42 * We are most concern with the following matches. 43 */ 44 typedef int db_strategy_t; /* search strategy */ 45 46 #define DB_STGY_ANY 0 /* anything goes */ 47 #define DB_STGY_XTRN 1 /* only external symbols */ 48 #define DB_STGY_PROC 2 /* only procedures */ 49 50 51 /* 52 * Internal db_forall function calling convention: 53 * 54 * (*db_forall_func)(sym, name, suffix, arg); 55 * 56 * symbol is the (opaque) symbol pointer, name the name of the symbol, 57 * suffix a string representing the type, and arg an opaque argument to 58 * be passed in. 59 */ 60 typedef void (db_forall_func_t)(Elf_Sym *, const char *, const char *, void *); 61 62 extern unsigned int db_maxoff; /* like gdb's "max-symbolic-offset" */ 63 64 int db_eqname(const char *, const char *, int); 65 /* strcmp, modulo leading char */ 66 67 Elf_Sym * db_symbol_by_name(const char *, db_expr_t *); 68 /* find symbol value given name */ 69 70 Elf_Sym * db_search_symbol(vaddr_t, db_strategy_t, db_expr_t *); 71 /* find symbol given value */ 72 73 void db_symbol_values(Elf_Sym *, const char **, db_expr_t *); 74 /* return name and value of symbol */ 75 76 #define db_find_sym_and_offset(val,namep,offp) \ 77 db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,NULL) 78 /* find name&value given approx val */ 79 80 #define db_find_xtrn_sym_and_offset(val,namep,offp) \ 81 db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,NULL) 82 /* ditto, but no locals */ 83 84 void db_printsym(db_expr_t, db_strategy_t, int (*)(const char *, ...)); 85 /* print closest symbol to a value */ 86 87 int db_elf_sym_init(int, void *, void *, const char *); 88 Elf_Sym * db_elf_sym_search(vaddr_t, db_strategy_t, db_expr_t *); 89 int db_elf_line_at_pc(Elf_Sym *, const char **, int *, db_expr_t); 90 void db_elf_sym_forall(db_forall_func_t db_forall_func, void *); 91 92 bool db_dwarf_line_at_pc(const char *, size_t, uintptr_t, 93 const char **, const char **, int *); 94 95 int db_ctf_func_numargs(Elf_Sym *); 96 97 #endif /* _DDB_DB_SYM_H_ */ 98