xref: /dragonfly/sys/ddb/db_kld.c (revision 0bb9290e)
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.4 2005/12/23 21:35:44 swildner 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(db_symtab_t *stab, const char *symstr)
48 {
49 	c_linker_sym_t sym;
50 
51 	if (linker_ddb_lookup(symstr, &sym) == 0)
52 	    return (c_db_sym_t) sym;
53 	else
54 	    return (c_db_sym_t) 0;
55 }
56 
57 /*
58  * Parameters:
59  *     diffp:	in/out
60  */
61 c_db_sym_t
62 X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, db_strategy_t strategy,
63 		   db_expr_t *diffp)
64 {
65 	c_linker_sym_t sym;
66 	long diff;
67 
68 	if (linker_ddb_search_symbol((caddr_t) off, &sym, &diff) == 0) {
69 		*diffp = (db_expr_t) diff;
70 		return (c_db_sym_t) sym;
71 	}
72 
73 	return 0;
74 }
75 
76 /*
77  * Return the name and value for a symbol.
78  */
79 void
80 X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t dbsym, const char **namep,
81 		   db_expr_t *valuep)
82 {
83 	c_linker_sym_t sym = (c_linker_sym_t) dbsym;
84 	linker_symval_t symval;
85 
86 	linker_ddb_symbol_values(sym, &symval);
87 	if (namep)
88 	    *namep = (const char*) symval.name;
89 	if (valuep)
90 	    *valuep = (db_expr_t) symval.value;
91 }
92 
93 
94 boolean_t
95 X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym, char **filename,
96 		int *linenum, db_expr_t off)
97 {
98 	return FALSE;
99 }
100 
101 boolean_t
102 X_db_sym_numargs(db_symtab_t *symtab, c_db_sym_t cursym, int *nargp,
103 		 char **argnamep)
104 {
105 	return FALSE;
106 }
107 
108 /*
109  * Initialization routine for a.out files.
110  */
111 void
112 kdb_init(void)
113 {
114 	db_add_symbol_table(0, 0, "kernel", 0);
115 }
116