Deleted Added
sdiff udiff text old ( 206639 ) new ( 273006 )
full compact
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

--- 15 unchanged lines hidden (view full) ---

24 * rights to redistribute these changes.
25 */
26/*
27 * Author: David B. Golub, Carnegie Mellon University
28 * Date: 7/90
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/ddb/db_sym.c 206639 2010-04-14 23:06:07Z julian $");
33
34#include <sys/param.h>
35#include <sys/pcpu.h>
36#include <sys/smp.h>
37#include <sys/systm.h>
38
39#include <net/vnet.h>
40

--- 124 unchanged lines hidden (view full) ---

165 }
166}
167#endif
168
169/*
170 * Add symbol table, with given name, to list of symbol tables.
171 */
172void
173db_add_symbol_table(start, end, name, ref)
174 char *start;
175 char *end;
176 char *name;
177 char *ref;
178{
179 if (db_nsymtab >= MAXNOSYMTABS) {
180 printf ("No slots left for %s symbol table", name);
181 panic ("db_sym.c: db_add_symbol_table");
182 }
183
184 db_symtabs[db_nsymtab].start = start;
185 db_symtabs[db_nsymtab].end = end;

--- 4 unchanged lines hidden (view full) ---

190
191/*
192 * db_qualify("vm_map", "ux") returns "unix:vm_map".
193 *
194 * Note: return value points to static data whose content is
195 * overwritten by each call... but in practice this seems okay.
196 */
197static char *
198db_qualify(sym, symtabname)
199 c_db_sym_t sym;
200 register char *symtabname;
201{
202 const char *symname;
203 static char tmp[256];
204
205 db_symbol_values(sym, &symname, 0);
206 snprintf(tmp, sizeof(tmp), "%s:%s", symtabname, symname);
207 return tmp;
208}
209
210
211boolean_t
212db_eqname(src, dst, c)
213 const char *src;
214 const char *dst;
215 int c;
216{
217 if (!strcmp(src, dst))
218 return (TRUE);
219 if (src[0] == c)
220 return (!strcmp(src+1,dst));
221 return (FALSE);
222}
223
224boolean_t
225db_value_of_name(name, valuep)
226 const char *name;
227 db_expr_t *valuep;
228{
229 c_db_sym_t sym;
230
231 sym = db_lookup(name);
232 if (sym == C_DB_SYM_NULL)
233 return (FALSE);
234 db_symbol_values(sym, &name, valuep);
235 return (TRUE);
236}
237
238boolean_t
239db_value_of_name_pcpu(name, valuep)
240 const char *name;
241 db_expr_t *valuep;
242{
243 static char tmp[256];
244 db_expr_t value;
245 c_db_sym_t sym;
246 int cpu;
247
248 if (db_cpu != -1)
249 cpu = db_cpu;

--- 6 unchanged lines hidden (view full) ---

256 db_symbol_values(sym, &name, &value);
257 if (value < DPCPU_START || value >= DPCPU_STOP)
258 return (FALSE);
259 *valuep = (db_expr_t)((uintptr_t)value + dpcpu_off[cpu]);
260 return (TRUE);
261}
262
263boolean_t
264db_value_of_name_vnet(name, valuep)
265 const char *name;
266 db_expr_t *valuep;
267{
268#ifdef VIMAGE
269 static char tmp[256];
270 db_expr_t value;
271 c_db_sym_t sym;
272 struct vnet *vnet;
273
274 if (db_vnet != NULL)

--- 16 unchanged lines hidden (view full) ---

291
292/*
293 * Lookup a symbol.
294 * If the symbol has a qualifier (e.g., ux:vm_map),
295 * then only the specified symbol table will be searched;
296 * otherwise, all symbol tables will be searched.
297 */
298static c_db_sym_t
299db_lookup(symstr)
300 const char *symstr;
301{
302 c_db_sym_t sp;
303 register int i;
304 int symtab_start = 0;
305 int symtab_end = db_nsymtab;
306 register const char *cp;
307
308 /*

--- 40 unchanged lines hidden (view full) ---

349 */
350static volatile boolean_t db_qualify_ambiguous_names = FALSE;
351
352/*
353 * Does this symbol name appear in more than one symbol table?
354 * Used by db_symbol_values to decide whether to qualify a symbol.
355 */
356static boolean_t
357db_symbol_is_ambiguous(sym)
358 c_db_sym_t sym;
359{
360 const char *sym_name;
361 register int i;
362 register
363 boolean_t found_once = FALSE;
364
365 if (!db_qualify_ambiguous_names)
366 return FALSE;

--- 9 unchanged lines hidden (view full) ---

376 return FALSE;
377}
378
379/*
380 * Find the closest symbol to val, and return its name
381 * and the difference between val and the symbol found.
382 */
383c_db_sym_t
384db_search_symbol( val, strategy, offp)
385 register db_addr_t val;
386 db_strategy_t strategy;
387 db_expr_t *offp;
388{
389 register
390 unsigned int diff;
391 size_t newdiff;
392 register int i;
393 c_db_sym_t ret = C_DB_SYM_NULL, sym;
394
395 newdiff = diff = ~0;

--- 8 unchanged lines hidden (view full) ---

404 *offp = diff;
405 return ret;
406}
407
408/*
409 * Return name and value of a symbol
410 */
411void
412db_symbol_values(sym, namep, valuep)
413 c_db_sym_t sym;
414 const char **namep;
415 db_expr_t *valuep;
416{
417 db_expr_t value;
418
419 if (sym == DB_SYM_NULL) {
420 *namep = 0;
421 return;
422 }
423

--- 20 unchanged lines hidden (view full) ---

444 * bogus symbol associations, e.g. 3 might get some absolute
445 * value like _INCLUDE_VERSION or something, therefore we do
446 * not accept symbols whose value is "small" (and use plain hex).
447 */
448
449db_expr_t db_maxoff = 0x10000;
450
451void
452db_printsym(off, strategy)
453 db_expr_t off;
454 db_strategy_t strategy;
455{
456 db_expr_t d;
457 char *filename;
458 const char *name;
459 db_expr_t value;
460 int linenum;
461 c_db_sym_t cursym;
462

--- 18 unchanged lines hidden (view full) ---

481 db_printf("+%+#lr", (long)d);
482 if (strategy == DB_STGY_PROC) {
483 if (db_line_at_pc(cursym, &filename, &linenum, off))
484 db_printf(" [%s:%d]", filename, linenum);
485 }
486}
487
488static boolean_t
489db_line_at_pc( sym, filename, linenum, pc)
490 c_db_sym_t sym;
491 char **filename;
492 int *linenum;
493 db_expr_t pc;
494{
495 return X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc);
496}
497
498int
499db_sym_numargs(sym, nargp, argnames)
500 c_db_sym_t sym;
501 int *nargp;
502 char **argnames;
503{
504 return X_db_sym_numargs(db_last_symtab, sym, nargp, argnames);
505}