Deleted Added
full compact
db_sym.c (159668) db_sym.c (195699)
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>
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 159668 2006-06-16 16:17:52Z kib $");
32__FBSDID("$FreeBSD: head/sys/ddb/db_sym.c 195699 2009-07-14 22:48:30Z rwatson $");
33
34#include <sys/param.h>
33
34#include <sys/param.h>
35#include <sys/smp.h>
35#include <sys/systm.h>
36#include <sys/systm.h>
37#include <sys/vimage.h>
36
38
39#include <net/vnet.h>
40
37#include <ddb/ddb.h>
38#include <ddb/db_sym.h>
41#include <ddb/ddb.h>
42#include <ddb/db_sym.h>
43#include <ddb/db_variables.h>
39
40#include <opt_ddb.h>
41
42/*
43 * Multiple symbol tables
44 */
45#ifndef MAXNOSYMTABS
46#define MAXNOSYMTABS 3 /* mach, ux, emulator */

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

51
52static db_symtab_t *db_last_symtab; /* where last symbol was found */
53
54static c_db_sym_t db_lookup( const char *symstr);
55static char *db_qualify(c_db_sym_t sym, char *symtabname);
56static boolean_t db_symbol_is_ambiguous(c_db_sym_t sym);
57static boolean_t db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
58
44
45#include <opt_ddb.h>
46
47/*
48 * Multiple symbol tables
49 */
50#ifndef MAXNOSYMTABS
51#define MAXNOSYMTABS 3 /* mach, ux, emulator */

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

56
57static db_symtab_t *db_last_symtab; /* where last symbol was found */
58
59static c_db_sym_t db_lookup( const char *symstr);
60static char *db_qualify(c_db_sym_t sym, char *symtabname);
61static boolean_t db_symbol_is_ambiguous(c_db_sym_t sym);
62static boolean_t db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
63
64static int db_cpu = -1;
65
66#ifdef VIMAGE
67extern uintptr_t *__start_set_vnet;
68extern uintptr_t *__stop_set_vnet;
69
70#define VNET_START (uintptr_t)&__start_set_vnet
71#define VNET_STOP (uintptr_t)&__stop_set_vnet
72
73static void *db_vnet = NULL;
74#endif
75
59/*
76/*
77 * Validate the CPU number used to interpret per-CPU variables so we can
78 * avoid later confusion if an invalid CPU is requested.
79 */
80int
81db_var_db_cpu(struct db_variable *vp, db_expr_t *valuep, int op)
82{
83
84 switch (op) {
85 case DB_VAR_GET:
86 *valuep = db_cpu;
87 return (1);
88
89 case DB_VAR_SET:
90 if (*(int *)valuep < -1 && *(int *)valuep > mp_maxid) {
91 db_printf("Invalid value: %d", *(int*)valuep);
92 return (0);
93 }
94 db_cpu = *(int *)valuep;
95 return (1);
96
97 default:
98 db_printf("db_var_db_cpu: unknown operation\n");
99 return (0);
100 }
101}
102
103/*
104 * Read-only variable reporting the current CPU, which is what we use when
105 * db_cpu is set to -1.
106 */
107int
108db_var_curcpu(struct db_variable *vp, db_expr_t *valuep, int op)
109{
110
111 switch (op) {
112 case DB_VAR_GET:
113 *valuep = curcpu;
114 return (1);
115
116 case DB_VAR_SET:
117 db_printf("Read-only variable.\n");
118 return (0);
119
120 default:
121 db_printf("db_var_curcpu: unknown operation\n");
122 return (0);
123 }
124}
125
126#ifdef VIMAGE
127/*
128 * Validate the virtual network pointer used to interpret per-vnet global
129 * variable expansion. Right now we don't do much here, really we should
130 * walk the global vnet list to check it's an OK pointer.
131 */
132int
133db_var_db_vnet(struct db_variable *vp, db_expr_t *valuep, int op)
134{
135
136 switch (op) {
137 case DB_VAR_GET:
138 *valuep = (db_expr_t)db_vnet;
139 return (1);
140
141 case DB_VAR_SET:
142 db_vnet = *(void **)valuep;
143 return (1);
144
145 default:
146 db_printf("db_var_db_vnet: unknown operation\n");
147 return (0);
148 }
149}
150
151/*
152 * Read-only variable reporting the current vnet, which is what we use when
153 * db_vnet is set to NULL.
154 */
155int
156db_var_curvnet(struct db_variable *vp, db_expr_t *valuep, int op)
157{
158
159 switch (op) {
160 case DB_VAR_GET:
161 *valuep = (db_expr_t)curvnet;
162 return (1);
163
164 case DB_VAR_SET:
165 db_printf("Read-only variable.\n");
166 return (0);
167
168 default:
169 db_printf("db_var_curcpu: unknown operation\n");
170 return (0);
171 }
172}
173#endif
174
175/*
60 * Add symbol table, with given name, to list of symbol tables.
61 */
62void
63db_add_symbol_table(start, end, name, ref)
64 char *start;
65 char *end;
66 char *name;
67 char *ref;

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

120
121 sym = db_lookup(name);
122 if (sym == C_DB_SYM_NULL)
123 return (FALSE);
124 db_symbol_values(sym, &name, valuep);
125 return (TRUE);
126}
127
176 * Add symbol table, with given name, to list of symbol tables.
177 */
178void
179db_add_symbol_table(start, end, name, ref)
180 char *start;
181 char *end;
182 char *name;
183 char *ref;

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

236
237 sym = db_lookup(name);
238 if (sym == C_DB_SYM_NULL)
239 return (FALSE);
240 db_symbol_values(sym, &name, valuep);
241 return (TRUE);
242}
243
244boolean_t
245db_value_of_name_pcpu(name, valuep)
246 const char *name;
247 db_expr_t *valuep;
248{
249 static char tmp[256];
250 db_expr_t value;
251 c_db_sym_t sym;
252 int cpu;
128
253
254 if (db_cpu != -1)
255 cpu = db_cpu;
256 else
257 cpu = curcpu;
258 snprintf(tmp, sizeof(tmp), "pcpu_entry_%s", name);
259 sym = db_lookup(tmp);
260 if (sym == C_DB_SYM_NULL)
261 return (FALSE);
262 db_symbol_values(sym, &name, &value);
263 if (value < DPCPU_START || value >= DPCPU_STOP)
264 return (FALSE);
265 *valuep = (db_expr_t)((uintptr_t)value + dpcpu_off[cpu]);
266 return (TRUE);
267}
268
269boolean_t
270db_value_of_name_vnet(name, valuep)
271 const char *name;
272 db_expr_t *valuep;
273{
274#ifdef VIMAGE
275 static char tmp[256];
276 db_expr_t value;
277 c_db_sym_t sym;
278 struct vnet *vnet;
279
280 if (db_vnet != NULL)
281 vnet = db_vnet;
282 else
283 vnet = curvnet;
284 snprintf(tmp, sizeof(tmp), "vnet_entry_%s", name);
285 sym = db_lookup(tmp);
286 if (sym == C_DB_SYM_NULL)
287 return (FALSE);
288 db_symbol_values(sym, &name, &value);
289 if (value < VNET_START || value >= VNET_STOP)
290 return (FALSE);
291 *valuep = (db_expr_t)((uintptr_t)value + vnet->vnet_data_base);
292 return (TRUE);
293#else
294 return (FALSE);
295#endif
296}
297
129/*
130 * Lookup a symbol.
131 * If the symbol has a qualifier (e.g., ux:vm_map),
132 * then only the specified symbol table will be searched;
133 * otherwise, all symbol tables will be searched.
134 */
135static c_db_sym_t
136db_lookup(symstr)

--- 206 unchanged lines hidden ---
298/*
299 * Lookup a symbol.
300 * If the symbol has a qualifier (e.g., ux:vm_map),
301 * then only the specified symbol table will be searched;
302 * otherwise, all symbol tables will be searched.
303 */
304static c_db_sym_t
305db_lookup(symstr)

--- 206 unchanged lines hidden ---