xref: /dragonfly/sys/ddb/db_kld.c (revision 6e285212)
1 /*
2  * Mach Operating System
3  * Copyright (c) 1991,1990 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie the
24  * rights to redistribute these changes.
25  *
26  * $FreeBSD: src/sys/ddb/db_kld.c,v 1.9 2000/01/11 13:25:12 peter Exp $
27  * $DragonFly: src/sys/ddb/db_kld.c,v 1.2 2003/06/17 04:28:20 dillon Exp $
28  *	from db_aout.c,v 1.20 1998/06/07 17:09:36 dfr Exp
29  */
30 
31 /*
32  *	Author: David B. Golub, Carnegie Mellon University
33  *	Date:	7/90
34  */
35 /*
36  * Symbol table routines for kld maintained kernels.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/linker.h>
42 
43 #include <ddb/ddb.h>
44 #include <ddb/db_sym.h>
45 
46 c_db_sym_t
47 X_db_lookup(stab, symstr)
48 	db_symtab_t	*stab;
49 	const char *	symstr;
50 {
51 	c_linker_sym_t sym;
52 
53 	if (linker_ddb_lookup(symstr, &sym) == 0)
54 	    return (c_db_sym_t) sym;
55 	else
56 	    return (c_db_sym_t) 0;
57 }
58 
59 c_db_sym_t
60 X_db_search_symbol(symtab, off, strategy, diffp)
61 	db_symtab_t *	symtab;
62 	register
63 	db_addr_t	off;
64 	db_strategy_t	strategy;
65 	db_expr_t	*diffp;		/* in/out */
66 {
67 	c_linker_sym_t sym;
68 	long diff;
69 
70 	if (linker_ddb_search_symbol((caddr_t) off, &sym, &diff) == 0) {
71 		*diffp = (db_expr_t) diff;
72 		return (c_db_sym_t) sym;
73 	}
74 
75 	return 0;
76 }
77 
78 /*
79  * Return the name and value for a symbol.
80  */
81 void
82 X_db_symbol_values(symtab, dbsym, namep, valuep)
83 	db_symtab_t	*symtab;
84 	c_db_sym_t	dbsym;
85 	const char	**namep;
86 	db_expr_t	*valuep;
87 {
88 	c_linker_sym_t sym = (c_linker_sym_t) dbsym;
89 	linker_symval_t symval;
90 
91 	linker_ddb_symbol_values(sym, &symval);
92 	if (namep)
93 	    *namep = (const char*) symval.name;
94 	if (valuep)
95 	    *valuep = (db_expr_t) symval.value;
96 }
97 
98 
99 boolean_t
100 X_db_line_at_pc(symtab, cursym, filename, linenum, off)
101 	db_symtab_t *	symtab;
102 	c_db_sym_t	cursym;
103 	char 		**filename;
104 	int 		*linenum;
105 	db_expr_t	off;
106 {
107 	return FALSE;
108 }
109 
110 boolean_t
111 X_db_sym_numargs(symtab, cursym, nargp, argnamep)
112 	db_symtab_t *	symtab;
113 	c_db_sym_t	cursym;
114 	int		*nargp;
115 	char		**argnamep;
116 {
117 	return FALSE;
118 }
119 
120 /*
121  * Initialization routine for a.out files.
122  */
123 void
124 kdb_init()
125 {
126 	db_add_symbol_table(0, 0, "kernel", 0);
127 }
128