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)(stab, sym, name, suffix, prefix, arg); 55 * 56 * stab is the symbol table, symbol the (opaque) symbol pointer, 57 * name the name of the symbol, suffix a string representing 58 * the type, prefix an initial ignorable function prefix (e.g. "_" 59 * in a.out), and arg an opaque argument to be passed in. 60 */ 61 typedef void (db_forall_func_t)(Elf_Sym *, char *, char *, int, void *); 62 63 extern unsigned int db_maxoff; /* like gdb's "max-symbolic-offset" */ 64 65 int db_eqname(char *, char *, int); 66 /* strcmp, modulo leading char */ 67 68 Elf_Sym * db_symbol_by_name(char *, db_expr_t *); 69 /* find symbol value given name */ 70 71 Elf_Sym * db_search_symbol(vaddr_t, db_strategy_t, db_expr_t *); 72 /* find symbol given value */ 73 74 void db_symbol_values(Elf_Sym *, char **, db_expr_t *); 75 /* return name and value of symbol */ 76 77 #define db_find_sym_and_offset(val,namep,offp) \ 78 db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) 79 /* find name&value given approx val */ 80 81 #define db_find_xtrn_sym_and_offset(val,namep,offp) \ 82 db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) 83 /* ditto, but no locals */ 84 85 void db_printsym(db_expr_t, db_strategy_t, int (*)(const char *, ...)); 86 /* print closest symbol to a value */ 87 88 int db_elf_sym_init(int, void *, void *, const char *); 89 Elf_Sym * db_elf_sym_search(vaddr_t, db_strategy_t, db_expr_t *); 90 int db_elf_line_at_pc(Elf_Sym *, char **, int *, db_expr_t); 91 void db_elf_sym_forall(db_forall_func_t db_forall_func, void *); 92 93 bool db_dwarf_line_at_pc(const char *, size_t, uintptr_t, 94 const char **, const char **, int *); 95 96 int db_ctf_func_numargs(Elf_Sym *); 97 98 #endif /* _DDB_DB_SYM_H_ */ 99