Home | History | Annotate | Line # | Download | only in ddb
db_sym.c revision 1.70
      1  1.70  riastrad /*	$NetBSD: db_sym.c,v 1.70 2022/08/30 22:37:36 riastradh Exp $	*/
      2   1.7       cgd 
      3  1.31    simonb /*
      4   1.1       cgd  * Mach Operating System
      5   1.1       cgd  * Copyright (c) 1991,1990 Carnegie Mellon University
      6   1.1       cgd  * All Rights Reserved.
      7  1.31    simonb  *
      8   1.1       cgd  * Permission to use, copy, modify and distribute this software and its
      9   1.1       cgd  * documentation is hereby granted, provided that both the copyright
     10   1.1       cgd  * notice and this permission notice appear in all copies of the
     11   1.1       cgd  * software, derivative works or modified versions, and any portions
     12   1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     13  1.31    simonb  *
     14  1.17        pk  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15   1.1       cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     16   1.1       cgd  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17  1.31    simonb  *
     18   1.1       cgd  * Carnegie Mellon requests users of this software to return to
     19  1.31    simonb  *
     20   1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21   1.1       cgd  *  School of Computer Science
     22   1.1       cgd  *  Carnegie Mellon University
     23   1.1       cgd  *  Pittsburgh PA 15213-3890
     24  1.31    simonb  *
     25   1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     26   1.1       cgd  * rights to redistribute these changes.
     27   1.1       cgd  */
     28  1.28     lukem 
     29  1.28     lukem #include <sys/cdefs.h>
     30  1.70  riastrad __KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.70 2022/08/30 22:37:36 riastradh Exp $");
     31   1.5   mycroft 
     32  1.59        ad #ifdef _KERNEL_OPT
     33  1.32     itohy #include "opt_ddbparam.h"
     34  1.59        ad #endif
     35  1.26    simonb 
     36   1.6   mycroft #include <sys/param.h>
     37   1.6   mycroft #include <sys/proc.h>
     38  1.15   thorpej #include <sys/systm.h>
     39  1.35     ragge #include <sys/ksyms.h>
     40   1.6   mycroft 
     41  1.59        ad #include <ddb/ddb.h>
     42   1.1       cgd 
     43  1.35     ragge static void		db_symsplit(char *, char **, char **);
     44  1.31    simonb 
     45  1.15   thorpej 
     46  1.60       mrg #ifndef _KERNEL
     47  1.35     ragge #define	TBLNAME	"netbsd"
     48  1.15   thorpej 
     49  1.61       mrg #define use_ksyms 0
     50  1.61       mrg 
     51  1.15   thorpej const db_symformat_t *db_symformat;
     52  1.35     ragge static db_forall_func_t db_sift;
     53  1.59        ad extern db_symformat_t db_symformat_elf;
     54  1.35     ragge #endif
     55  1.15   thorpej 
     56  1.15   thorpej 
     57  1.15   thorpej /*
     58  1.15   thorpej  * Initialize the kernel debugger by initializing the master symbol
     59  1.15   thorpej  * table.  Note that if initializing the master symbol table fails,
     60  1.15   thorpej  * no other symbol tables can be loaded.
     61  1.15   thorpej  */
     62  1.15   thorpej void
     63  1.31    simonb ddb_init(int symsize, void *vss, void *vse)
     64  1.15   thorpej {
     65  1.59        ad #ifdef _KERNEL
     66  1.58    martin 	ksyms_addsyms_elf(symsize, vss, vse);	/* Will complain if necessary */
     67  1.59        ad #else	/* _KERNEL */
     68  1.59        ad 	db_symformat = &db_symformat_elf;
     69  1.61       mrg 	if ((*db_symformat->sym_init)(symsize, vss, vse, TBLNAME) != true)
     70  1.61       mrg 		printf("sym_init failed");
     71  1.59        ad #endif	/* _KERNEL */
     72   1.1       cgd }
     73   1.1       cgd 
     74  1.55   thorpej bool
     75  1.51  christos db_eqname(const char *src, const char *dst, int c)
     76   1.1       cgd {
     77  1.31    simonb 
     78   1.1       cgd 	if (!strcmp(src, dst))
     79  1.56   thorpej 		return (true);
     80   1.1       cgd 	if (src[0] == c)
     81  1.31    simonb 		return (!strcmp(src+1,dst));
     82  1.56   thorpej 	return (false);
     83   1.1       cgd }
     84   1.1       cgd 
     85  1.55   thorpej bool
     86  1.51  christos db_value_of_name(const char *name, db_expr_t *valuep)
     87   1.1       cgd {
     88  1.51  christos 	char symbol[128];
     89  1.35     ragge 	char *mod, *sym;
     90  1.59        ad #ifdef _KERNEL
     91  1.43       scw 	unsigned long uval;
     92  1.43       scw 	long val;
     93  1.59        ad #endif
     94   1.1       cgd 
     95  1.60       mrg #ifndef _KERNEL
     96  1.60       mrg 	if (!use_ksyms) {
     97  1.60       mrg 		db_sym_t ssym;
     98   1.1       cgd 
     99  1.35     ragge 		/*
    100  1.35     ragge 		 * Cannot load symtabs in a.out kernels, so the ':'
    101  1.35     ragge 		 * style of selecting modules is irrelevant.
    102  1.35     ragge 		 */
    103  1.35     ragge 		ssym = (*db_symformat->sym_lookup)(NULL, name);
    104  1.35     ragge 		if (ssym == DB_SYM_NULL)
    105  1.56   thorpej 			return (false);
    106  1.35     ragge 		db_symbol_values(ssym, &name, valuep);
    107  1.56   thorpej 		return (true);
    108   1.1       cgd 	}
    109  1.35     ragge #endif
    110  1.60       mrg 
    111  1.51  christos 	(void)strlcpy(symbol, name, sizeof(symbol));
    112  1.51  christos 	db_symsplit(symbol, &mod, &sym);
    113  1.59        ad #ifdef _KERNEL
    114  1.65      maxv 	if (ksyms_getval_unlocked(mod, sym, NULL, &uval, KSYMS_EXTERN) == 0) {
    115  1.43       scw 		val = (long) uval;
    116  1.41       scw 		*valuep = (db_expr_t)val;
    117  1.56   thorpej 		return true;
    118  1.41       scw 	}
    119  1.65      maxv 	if (ksyms_getval_unlocked(mod, sym, NULL, &uval, KSYMS_ANY) == 0) {
    120  1.43       scw 		val = (long) uval;
    121  1.41       scw 		*valuep = (db_expr_t)val;
    122  1.56   thorpej 		return true;
    123  1.41       scw 	}
    124  1.59        ad #endif
    125  1.56   thorpej 	return false;
    126   1.1       cgd }
    127   1.1       cgd 
    128  1.60       mrg #ifndef _KERNEL
    129  1.20     jhawk /* Private structure for passing args to db_sift() from db_sifting(). */
    130  1.20     jhawk struct db_sift_args {
    131  1.20     jhawk 	char	*symstr;
    132  1.20     jhawk 	int	mode;
    133  1.20     jhawk };
    134  1.20     jhawk 
    135  1.20     jhawk /*
    136  1.20     jhawk  * Does the work of db_sifting(), called once for each
    137  1.35     ragge  * symbol via db_forall(), prints out symbols matching
    138  1.20     jhawk  * criteria.
    139  1.20     jhawk  */
    140  1.20     jhawk static void
    141  1.54  christos db_sift(db_symtab_t *stab, db_sym_t sym, char *name,
    142  1.54  christos     char *suffix, int prefix, void *arg)
    143  1.20     jhawk {
    144  1.20     jhawk 	char c, sc;
    145  1.20     jhawk 	char *find, *p;
    146  1.20     jhawk 	size_t len;
    147  1.20     jhawk 	struct db_sift_args *dsa;
    148  1.20     jhawk 
    149  1.20     jhawk 	dsa = (struct db_sift_args*)arg;
    150  1.20     jhawk 
    151  1.20     jhawk 	find = dsa->symstr;	/* String we're looking for. */
    152  1.20     jhawk 	p = name;		/* String we're searching within. */
    153  1.31    simonb 
    154  1.20     jhawk 	/* Matching algorithm cribbed from strstr(), which is not
    155  1.20     jhawk 	   in the kernel. */
    156  1.20     jhawk 	if ((c = *find++) != 0) {
    157  1.20     jhawk 		len = strlen(find);
    158  1.20     jhawk 		do {
    159  1.20     jhawk 			do {
    160  1.20     jhawk 				if ((sc = *p++) == 0)
    161  1.20     jhawk 					return;
    162  1.20     jhawk 			} while (sc != c);
    163  1.20     jhawk 		} while (strncmp(p, find, len) != 0);
    164  1.20     jhawk 	}
    165  1.20     jhawk 	if (dsa->mode=='F')	/* ala ls -F */
    166  1.20     jhawk 		db_printf("%s%s ", name, suffix);
    167  1.20     jhawk 	else
    168  1.20     jhawk 		db_printf("%s ", name);
    169  1.20     jhawk }
    170  1.35     ragge #endif
    171  1.20     jhawk 
    172  1.20     jhawk /*
    173  1.20     jhawk  * "Sift" for a partial symbol.
    174  1.20     jhawk  * Named for the Sun OpenPROM command ("sifting").
    175  1.20     jhawk  * If the symbol has a qualifier (e.g., ux:vm_map),
    176  1.20     jhawk  * then only the specified symbol table will be searched;
    177  1.20     jhawk  * otherwise, all symbol tables will be searched..
    178  1.20     jhawk  *
    179  1.20     jhawk  * "mode" is how-to-display, set from modifiers.
    180  1.20     jhawk  */
    181  1.20     jhawk void
    182  1.31    simonb db_sifting(char *symstr, int mode)
    183  1.20     jhawk {
    184  1.59        ad #ifdef _KERNEL
    185  1.35     ragge 	char *mod, *sym;
    186  1.59        ad #endif
    187  1.35     ragge 
    188  1.60       mrg #ifndef _KERNEL
    189  1.20     jhawk 	struct db_sift_args dsa;
    190  1.20     jhawk 
    191  1.60       mrg 	if (!use_ksyms) {
    192  1.35     ragge 		dsa.symstr = symstr;
    193  1.35     ragge 		dsa.mode = mode;
    194  1.35     ragge 		(*db_symformat->sym_forall)(NULL, db_sift, &dsa);
    195  1.35     ragge 		db_printf("\n");
    196  1.35     ragge 		return;
    197  1.20     jhawk 	}
    198  1.35     ragge #endif
    199  1.20     jhawk 
    200  1.59        ad #ifdef _KERNEL
    201  1.35     ragge 	db_symsplit(symstr, &mod, &sym);
    202  1.35     ragge 	if (ksyms_sift(mod, sym, mode) == ENODEV)
    203  1.35     ragge 		db_error("invalid symbol table name");
    204  1.59        ad #endif
    205   1.1       cgd }
    206   1.1       cgd 
    207   1.1       cgd /*
    208   1.1       cgd  * Find the closest symbol to val, and return its name
    209   1.1       cgd  * and the difference between val and the symbol found.
    210   1.1       cgd  */
    211   1.1       cgd db_sym_t
    212  1.31    simonb db_search_symbol(db_addr_t val, db_strategy_t strategy, db_expr_t *offp)
    213   1.1       cgd {
    214  1.35     ragge 	unsigned int diff;
    215  1.59        ad 	db_sym_t ret = DB_SYM_NULL;
    216  1.59        ad #ifdef _KERNEL
    217  1.41       scw 	unsigned long naddr;
    218  1.39  jdolecek 	const char *mod;
    219  1.51  christos 	const char *sym;
    220  1.59        ad #endif
    221  1.35     ragge 
    222  1.60       mrg #ifndef _KERNEL
    223  1.60       mrg 	if (!use_ksyms) {
    224  1.60       mrg 		db_expr_t newdiff;
    225  1.60       mrg 		db_sym_t ssym;
    226  1.35     ragge 
    227  1.67       mrg 		diff = ~0u;
    228  1.67       mrg 		newdiff = ~0;
    229  1.35     ragge 		ssym = (*db_symformat->sym_search)
    230  1.35     ragge 		    (NULL, val, strategy, &newdiff);
    231  1.33   thorpej 		if ((unsigned int) newdiff < diff) {
    232  1.31    simonb 			diff = newdiff;
    233  1.35     ragge 			ret = ssym;
    234  1.31    simonb 		}
    235  1.35     ragge 		*offp = diff;
    236  1.35     ragge 		return ret;
    237  1.35     ragge 	}
    238  1.35     ragge #endif
    239  1.35     ragge 
    240  1.59        ad #ifdef _KERNEL
    241  1.41       scw 	if (ksyms_getname(&mod, &sym, (vaddr_t)val, strategy) == 0) {
    242  1.65      maxv 		(void)ksyms_getval_unlocked(mod, sym, NULL, &naddr, KSYMS_ANY);
    243  1.41       scw 		diff = val - (db_addr_t)naddr;
    244  1.41       scw 		ret = (db_sym_t)naddr;
    245  1.44  christos 	} else
    246  1.59        ad #endif
    247  1.44  christos 		diff = 0;
    248   1.1       cgd 	*offp = diff;
    249   1.1       cgd 	return ret;
    250   1.1       cgd }
    251   1.1       cgd 
    252   1.1       cgd /*
    253   1.1       cgd  * Return name and value of a symbol
    254   1.1       cgd  */
    255   1.1       cgd void
    256  1.51  christos db_symbol_values(db_sym_t sym, const char **namep, db_expr_t *valuep)
    257   1.1       cgd {
    258  1.59        ad #ifdef _KERNEL
    259  1.39  jdolecek 	const char *mod;
    260  1.59        ad #endif
    261   1.1       cgd 
    262   1.1       cgd 	if (sym == DB_SYM_NULL) {
    263   1.1       cgd 		*namep = 0;
    264   1.1       cgd 		return;
    265   1.1       cgd 	}
    266   1.1       cgd 
    267  1.60       mrg #ifndef _KERNEL
    268  1.60       mrg 	if (!use_ksyms) {
    269  1.35     ragge 		db_expr_t value;
    270  1.60       mrg 
    271  1.35     ragge 		(*db_symformat->sym_value)(NULL, sym, namep, &value);
    272  1.35     ragge 		if (valuep)
    273  1.35     ragge 			*valuep = value;
    274  1.35     ragge 		return;
    275  1.35     ragge 	}
    276  1.35     ragge #endif
    277   1.1       cgd 
    278  1.59        ad #ifdef _KERNEL
    279  1.41       scw 	if (ksyms_getname(&mod, namep, (vaddr_t)sym,
    280  1.41       scw 	    KSYMS_ANY|KSYMS_EXACT) == 0) {
    281  1.35     ragge 		if (valuep)
    282  1.35     ragge 			*valuep = sym;
    283  1.35     ragge 	} else
    284  1.59        ad #endif
    285  1.35     ragge 		*namep = NULL;
    286   1.1       cgd }
    287   1.1       cgd 
    288   1.1       cgd 
    289   1.1       cgd /*
    290   1.1       cgd  * Print a the closest symbol to value
    291   1.1       cgd  *
    292   1.1       cgd  * After matching the symbol according to the given strategy
    293   1.1       cgd  * we print it in the name+offset format, provided the symbol's
    294   1.1       cgd  * value is close enough (eg smaller than db_maxoff).
    295   1.1       cgd  * We also attempt to print [filename:linenum] when applicable
    296   1.1       cgd  * (eg for procedure names).
    297   1.1       cgd  *
    298   1.1       cgd  * If we could not find a reasonable name+offset representation,
    299   1.1       cgd  * then we just print the value in hex.  Small values might get
    300   1.1       cgd  * bogus symbol associations, e.g. 3 might get some absolute
    301   1.1       cgd  * value like _INCLUDE_VERSION or something, therefore we do
    302   1.1       cgd  * not accept symbols whose value is zero (and use plain hex).
    303   1.1       cgd  */
    304  1.47       chs unsigned int	db_maxoff = 0x100000;
    305   1.1       cgd 
    306  1.30     jhawk void
    307  1.40    itojun db_symstr(char *buf, size_t buflen, db_expr_t off, db_strategy_t strategy)
    308  1.30     jhawk {
    309  1.51  christos 	const char  *name;
    310  1.59        ad #ifdef _KERNEL
    311  1.39  jdolecek 	const char *mod;
    312  1.42     ragge 	unsigned long val;
    313  1.59        ad #endif
    314  1.38     ragge 
    315  1.60       mrg #ifndef _KERNEL
    316  1.60       mrg 	if (!use_ksyms) {
    317  1.38     ragge 		db_expr_t	d;
    318  1.38     ragge 		char 		*filename;
    319  1.38     ragge 		db_expr_t	value;
    320  1.38     ragge 		int 		linenum;
    321  1.38     ragge 		db_sym_t	cursym;
    322  1.38     ragge 
    323  1.62  christos 		cursym = db_search_symbol(off, strategy, &d);
    324  1.62  christos 		db_symbol_values(cursym, &name, &value);
    325  1.63  christos 		if (name != NULL && ((unsigned int)d < db_maxoff) &&
    326  1.62  christos 		    value != 0) {
    327  1.62  christos 			strlcpy(buf, name, buflen);
    328  1.62  christos 			if (d) {
    329  1.62  christos 				strlcat(buf, "+", buflen);
    330  1.63  christos 				db_format_radix(buf + strlen(buf), 24, d, true);
    331  1.62  christos 			}
    332  1.62  christos 			if (strategy == DB_STGY_PROC) {
    333  1.62  christos 				if ((*db_symformat->sym_line_at_pc)
    334  1.63  christos 				    (NULL, cursym, &filename, &linenum, off)) {
    335  1.63  christos 					size_t len = strlen(buf);
    336  1.63  christos 					snprintf(buf + len, buflen - len,
    337  1.63  christos 					    " [%s:%d]", filename, linenum);
    338  1.63  christos 				}
    339  1.38     ragge 			}
    340  1.62  christos 			return;
    341  1.38     ragge 		}
    342  1.40    itojun 		strlcpy(buf, db_num_to_str(off), buflen);
    343  1.38     ragge 		return;
    344  1.38     ragge 	}
    345  1.38     ragge #endif
    346  1.59        ad #ifdef _KERNEL
    347  1.41       scw 	if (ksyms_getname(&mod, &name, (vaddr_t)off,
    348  1.41       scw 	    strategy|KSYMS_CLOSEST) == 0) {
    349  1.65      maxv 		(void)ksyms_getval_unlocked(mod, name, NULL, &val, KSYMS_ANY);
    350  1.68       chs 		if (strategy & KSYMS_PROC && val == off) {
    351  1.68       chs 			if (ksyms_getname(&mod, &name, (vaddr_t)off - 1,
    352  1.68       chs 					  strategy|KSYMS_CLOSEST) != 0)
    353  1.68       chs 				goto out;
    354  1.68       chs 			(void)ksyms_getval_unlocked(mod, name, NULL, &val, KSYMS_ANY);
    355  1.68       chs 		}
    356  1.38     ragge 		if (((off - val) < db_maxoff) && val) {
    357  1.46    itojun 			snprintf(buf, buflen, "%s:%s", mod, name);
    358  1.38     ragge 			if (off - val) {
    359  1.40    itojun 				strlcat(buf, "+", buflen);
    360  1.38     ragge 				db_format_radix(buf+strlen(buf),
    361  1.56   thorpej 				    24, off - val, true);
    362  1.30     jhawk 			}
    363  1.38     ragge #ifdef notyet
    364  1.38     ragge 			if (strategy & KSYMS_PROC) {
    365  1.46    itojun 				if (ksyms_fmaddr(off, &filename, &linenum) == 0)
    366  1.46    itojun 					snprintf(buf + strlen(buf),
    367  1.46    itojun 					    buflen - strlen(buf),
    368  1.30     jhawk 					    " [%s:%d]", filename, linenum);
    369  1.30     jhawk 			}
    370  1.38     ragge #endif
    371  1.30     jhawk 			return;
    372  1.30     jhawk 		}
    373  1.30     jhawk 	}
    374  1.68       chs out:
    375  1.70  riastrad 	db_num_to_strbuf(off, buf, buflen);
    376  1.59        ad #endif
    377  1.30     jhawk }
    378   1.9       gwr 
    379   1.1       cgd void
    380  1.31    simonb db_printsym(db_expr_t off, db_strategy_t strategy,
    381  1.31    simonb     void (*pr)(const char *, ...))
    382   1.1       cgd {
    383  1.51  christos 	const char  *name;
    384  1.59        ad #ifdef _KERNEL
    385  1.39  jdolecek 	const char *mod;
    386  1.43       scw 	unsigned long uval;
    387  1.43       scw 	long val;
    388  1.59        ad #endif
    389  1.35     ragge #ifdef notyet
    390  1.35     ragge 	char *filename;
    391  1.35     ragge 	int  linenum;
    392  1.35     ragge #endif
    393   1.1       cgd 
    394  1.60       mrg #ifndef _KERNEL
    395  1.60       mrg 	if (!use_ksyms) {
    396  1.35     ragge 		db_expr_t	d;
    397  1.35     ragge 		char 		*filename;
    398  1.35     ragge 		db_expr_t	value;
    399  1.35     ragge 		int 		linenum;
    400  1.35     ragge 		db_sym_t	cursym;
    401  1.60       mrg 
    402  1.62  christos 		cursym = db_search_symbol(off, strategy, &d);
    403  1.62  christos 		db_symbol_values(cursym, &name, &value);
    404  1.63  christos 		if (name != NULL && ((unsigned int)d < db_maxoff) &&
    405  1.62  christos 		    value != 0) {
    406  1.62  christos 			(*pr)("%s", name);
    407  1.62  christos 			if (d) {
    408  1.62  christos 				char tbuf[24];
    409  1.62  christos 
    410  1.62  christos 				db_format_radix(tbuf, 24, d, true);
    411  1.62  christos 				(*pr)("+%s", tbuf);
    412  1.35     ragge 			}
    413  1.62  christos 			if (strategy == DB_STGY_PROC) {
    414  1.62  christos 				if ((*db_symformat->sym_line_at_pc)
    415  1.63  christos 				    (NULL, cursym, &filename, &linenum, off))
    416  1.63  christos 					(*pr)(" [%s:%d]", filename, linenum);
    417  1.62  christos 			}
    418  1.62  christos 			return;
    419  1.35     ragge 		}
    420  1.64  christos 		(*pr)("%s", db_num_to_str(off));
    421  1.35     ragge 		return;
    422  1.35     ragge 	}
    423  1.35     ragge #endif
    424  1.59        ad #ifdef _KERNEL
    425  1.41       scw 	if (ksyms_getname(&mod, &name, (vaddr_t)off,
    426  1.41       scw 	    strategy|KSYMS_CLOSEST) == 0) {
    427  1.65      maxv 		(void)ksyms_getval_unlocked(mod, name, NULL, &uval, KSYMS_ANY);
    428  1.68       chs 		if (strategy & KSYMS_PROC && uval == off) {
    429  1.68       chs 			if (ksyms_getname(&mod, &name, (vaddr_t)off - 1,
    430  1.68       chs 					  strategy|KSYMS_CLOSEST) != 0)
    431  1.68       chs 				goto out;
    432  1.68       chs 			(void)ksyms_getval_unlocked(mod, name, NULL, &uval, KSYMS_ANY);
    433  1.68       chs 		}
    434  1.43       scw 		val = (long) uval;
    435  1.35     ragge 		if (((off - val) < db_maxoff) && val) {
    436  1.35     ragge 			(*pr)("%s:%s", mod, name);
    437  1.35     ragge 			if (off - val) {
    438  1.23        tv 				char tbuf[24];
    439  1.23        tv 
    440  1.56   thorpej 				db_format_radix(tbuf, 24, off - val, true);
    441  1.24        tv 				(*pr)("+%s", tbuf);
    442  1.23        tv 			}
    443  1.35     ragge #ifdef notyet
    444  1.35     ragge 			if (strategy & KSYMS_PROC) {
    445  1.35     ragge 				if (ksyms_fmaddr(off, &filename, &linenum) == 0)
    446  1.21     jhawk 					(*pr)(" [%s:%d]", filename, linenum);
    447   1.9       gwr 			}
    448  1.35     ragge #endif
    449   1.9       gwr 			return;
    450   1.9       gwr 		}
    451   1.1       cgd 	}
    452  1.69       kre  out:;
    453  1.59        ad #endif
    454  1.64  christos 	(*pr)("%s", db_num_to_str(off));
    455   1.9       gwr 	return;
    456   1.1       cgd }
    457   1.1       cgd 
    458  1.35     ragge /*
    459  1.35     ragge  * Splits a string in the form "mod:sym" to two strings.
    460  1.35     ragge  */
    461  1.31    simonb static void
    462  1.35     ragge db_symsplit(char *str, char **mod, char **sym)
    463  1.15   thorpej {
    464  1.35     ragge 	char *cp;
    465  1.15   thorpej 
    466  1.35     ragge 	if ((cp = strchr(str, ':')) != NULL) {
    467  1.35     ragge 		*cp++ = '\0';
    468  1.35     ragge 		*mod = str;
    469  1.35     ragge 		*sym = cp;
    470  1.35     ragge 	} else {
    471  1.35     ragge 		*mod = NULL;
    472  1.35     ragge 		*sym = str;
    473  1.35     ragge 	}
    474   1.1       cgd }
    475  1.36     ragge 
    476  1.55   thorpej bool
    477  1.36     ragge db_sym_numargs(db_sym_t cursym, int *nargp, char **argnamep)
    478  1.36     ragge {
    479  1.60       mrg #ifndef _KERNEL
    480  1.60       mrg 	if (!use_ksyms)
    481  1.36     ragge 		return ((*db_symformat->sym_numargs)(NULL, cursym, nargp,
    482  1.36     ragge 		    argnamep));
    483  1.36     ragge #endif
    484  1.56   thorpej 	return (false);
    485  1.49     perry }
    486  1.36     ragge 
    487