Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/common/modules/genunix/sysevent.c
+++ new/usr/src/cmd/mdb/common/modules/genunix/sysevent.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #pragma ident "%Z%%M% %I% %E% SMI"
28 28
29 29 #include "sysevent.h"
30 30
31 31 int
32 32 sysevent_buf(uintptr_t addr, uint_t flags, uint_t opt_flags)
33 33 {
34 34 sysevent_hdr_t evh;
35 35 sysevent_impl_t *ev;
36 36 int size;
37 37
38 38 if (DCMD_HDRSPEC(flags)) {
39 39 if ((opt_flags & SYSEVENT_VERBOSE) == 0) {
40 40 mdb_printf("%<u>%-?s %-16s %-9s %-10s "
41 41 "%-?s%</u>\n", "ADDRESS", "SEQUENCE ID",
42 42 "CLASS", "SUBCLASS", "NVPAIR BUF ADDR");
43 43 }
44 44 }
45 45
46 46 /*
47 47 * Read in the sysevent buffer header first. After extracting
48 48 * the size of the buffer, re-read the buffer in its entirety.
49 49 */
50 50 if (mdb_vread(&evh, sizeof (sysevent_hdr_t), addr) == -1) {
51 51 mdb_warn("failed to read event header at %p", addr);
52 52 return (DCMD_ERR);
53 53 }
54 54
55 55 size = SE_SIZE((sysevent_impl_t *)&evh);
56 56 ev = mdb_alloc(size, UM_SLEEP | UM_GC);
57 57
58 58 if (mdb_vread(ev, size, addr) == -1) {
59 59 mdb_warn("can not read sysevent at %p", addr);
60 60 return (DCMD_ERR);
61 61 }
62 62
63 63 if ((opt_flags & SYSEVENT_VERBOSE) == 0) {
64 64 char ev_class[CLASS_FIELD_MAX];
65 65 char ev_subclass[SUBCLASS_FIELD_MAX];
66 66
67 67 if (mdb_snprintf(ev_class, CLASS_FIELD_MAX, "%s",
68 68 SE_CLASS_NAME(ev)) >= CLASS_FIELD_MAX - 1)
69 69 (void) strcpy(&ev_class[CLASS_FIELD_MAX - 4], "...");
70 70
71 71 if (mdb_snprintf(ev_subclass, SUBCLASS_FIELD_MAX, "%s",
72 72 SE_SUBCLASS_NAME(ev)) >= SUBCLASS_FIELD_MAX - 1)
73 73 (void) strcpy(&ev_subclass[SUBCLASS_FIELD_MAX - 4],
74 74 "...");
75 75
76 76 mdb_printf("%-?p %-16llu %-9s %-10s %-?p%\n",
77 77 addr, SE_SEQ(ev), ev_class, ev_subclass,
78 78 addr + SE_ATTR_OFF(ev));
79 79 } else {
80 80 mdb_printf("%<b>Sequence ID\t : %llu%</b>\n", SE_SEQ(ev));
81 81 mdb_printf("%16s : %s\n", "publisher", SE_PUB_NAME(ev));
82 82 mdb_printf("%16s : %p\n", "event address", (caddr_t)addr);
83 83 mdb_printf("%16s : %s\n", "class", SE_CLASS_NAME(ev));
84 84 mdb_printf("%16s : %s\n", "subclass", SE_SUBCLASS_NAME(ev));
85 85 mdb_printf("%16s : %llu\n", "time stamp", SE_TIME(ev));
86 86 mdb_printf("%16s : %p\n", "nvpair buf addr",
87 87 addr + SE_ATTR_OFF(ev));
88 88 }
89 89
90 90 return (DCMD_OK);
91 91 }
92 92
93 93 int
94 94 sysevent_subclass_list(uintptr_t addr, uint_t flags, int argc,
95 95 const mdb_arg_t *argv)
96 96 {
97 97 int subclass_name_sz;
98 98 char subclass_name[CLASS_LIST_FIELD_MAX];
99 99 subclass_lst_t sclist;
100 100
101 101 if ((flags & DCMD_ADDRSPEC) == 0)
102 102 return (DCMD_USAGE);
103 103
104 104 if ((flags & DCMD_LOOP) == 0) {
105 105 if (mdb_pwalk_dcmd("sysevent_subclass_list",
106 106 "sysevent_subclass_list", argc, argv, addr) == -1) {
107 107 mdb_warn("can't walk sysevent subclass list");
108 108 return (DCMD_ERR);
109 109 }
110 110 return (DCMD_OK);
111 111 }
112 112
113 113 if (DCMD_HDRSPEC(flags)) {
114 114 mdb_printf("%<u>%-?s %-24s %-?s%</u>\n",
115 115 "ADDR", "NAME", "SUBSCRIBER DATA ADDR");
116 116 }
117 117 if (mdb_vread(&sclist, sizeof (sclist), (uintptr_t)addr) == -1) {
118 118 mdb_warn("failed to read subclass list at %p", addr);
119 119 return (DCMD_ERR);
120 120 }
121 121 if ((subclass_name_sz = mdb_readstr(subclass_name, CLASS_LIST_FIELD_MAX,
122 122 (uintptr_t)sclist.sl_name)) == -1) {
123 123 mdb_warn("failed to read class name at %p",
124 124 sclist.sl_name);
125 125 return (DCMD_ERR);
126 126 }
127 127 if (subclass_name_sz >= CLASS_LIST_FIELD_MAX - 1)
128 128 (void) strcpy(&subclass_name[CLASS_LIST_FIELD_MAX - 4], "...");
129 129
130 130 mdb_printf("%-?p %-24s %-?p\n", addr, subclass_name,
131 131 addr + offsetof(subclass_lst_t, sl_num));
132 132
133 133 return (DCMD_OK);
134 134 }
135 135
136 136
137 137 int
138 138 sysevent_class_list(uintptr_t addr, uint_t flags, int argc,
139 139 const mdb_arg_t *argv)
140 140 {
141 141 int class_name_sz;
142 142 char class_name[CLASS_LIST_FIELD_MAX];
143 143 class_lst_t clist;
144 144
145 145 if ((flags & DCMD_ADDRSPEC) == 0)
146 146 return (DCMD_USAGE);
147 147
148 148 if ((flags & DCMD_LOOP) == 0) {
149 149 if (mdb_pwalk_dcmd("sysevent_class_list", "sysevent_class_list",
150 150 argc, argv, addr) == -1) {
151 151 mdb_warn("can't walk sysevent class list");
152 152 return (DCMD_ERR);
153 153 }
154 154 return (DCMD_OK);
155 155 }
156 156
157 157 if (DCMD_HDRSPEC(flags))
158 158 mdb_printf("%<u>%-?s %-24s %-?s%</u>\n",
159 159 "ADDR", "NAME", "SUBCLASS LIST ADDR");
160 160
161 161 if (mdb_vread(&clist, sizeof (clist),
162 162 (uintptr_t)addr) == -1) {
163 163 mdb_warn("failed to read class clist at %p", addr);
164 164 return (DCMD_ERR);
165 165 }
166 166 if ((class_name_sz = mdb_readstr(class_name, CLASS_LIST_FIELD_MAX,
167 167 (uintptr_t)clist.cl_name)) == -1) {
168 168 mdb_warn("failed to read class name at %p",
169 169 clist.cl_name);
170 170 return (DCMD_ERR);
171 171 }
172 172 if (class_name_sz >= CLASS_LIST_FIELD_MAX - 1)
173 173 (void) strcpy(&class_name[CLASS_LIST_FIELD_MAX - 4], "...");
↓ open down ↓ |
173 lines elided |
↑ open up ↑ |
174 174
175 175 mdb_printf("%-?p %-24s %-?p\n", addr, class_name,
176 176 clist.cl_subclass_list);
177 177
178 178 return (DCMD_OK);
179 179 }
180 180
181 181 int
182 182 sysevent_subclass_list_walk_init(mdb_walk_state_t *wsp)
183 183 {
184 - if (wsp->walk_addr == NULL) {
184 + if (wsp->walk_addr == (uintptr_t)NULL) {
185 185 mdb_warn("sysevent_subclass_list does not support global "
186 186 "walks");
187 187 return (WALK_ERR);
188 188 }
189 189
190 190 wsp->walk_data = mdb_alloc(sizeof (subclass_lst_t), UM_SLEEP);
191 191 return (WALK_NEXT);
192 192 }
193 193
194 194 int
195 195 sysevent_subclass_list_walk_step(mdb_walk_state_t *wsp)
196 196 {
197 197 int status;
198 198
199 - if (wsp->walk_addr == NULL)
199 + if (wsp->walk_addr == (uintptr_t)NULL)
200 200 return (WALK_DONE);
201 201
202 202 if (mdb_vread(wsp->walk_data, sizeof (subclass_lst_t),
203 203 wsp->walk_addr) == -1) {
204 204 mdb_warn("failed to read class list at %p", wsp->walk_addr);
205 205 return (WALK_ERR);
206 206 }
207 207
208 208 status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
209 209 wsp->walk_cbdata);
210 210
211 211 wsp->walk_addr =
212 212 (uintptr_t)(((subclass_lst_t *)wsp->walk_data)->sl_next);
213 213
214 214 return (status);
215 215 }
216 216
217 217 void
218 218 sysevent_subclass_list_walk_fini(mdb_walk_state_t *wsp)
219 219 {
220 220 mdb_free(wsp->walk_data, sizeof (subclass_lst_t));
221 221 }
222 222
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
223 223 typedef struct class_walk_data {
224 224 int hash_index;
225 225 class_lst_t *hash_tbl[CLASS_HASH_SZ + 1];
226 226 } class_walk_data_t;
227 227
228 228 int
229 229 sysevent_class_list_walk_init(mdb_walk_state_t *wsp)
230 230 {
231 231 class_walk_data_t *cl_walker;
232 232
233 - if (wsp->walk_addr == NULL) {
233 + if (wsp->walk_addr == (uintptr_t)NULL) {
234 234 mdb_warn("sysevent_class_list does not support global walks");
235 235 return (WALK_ERR);
236 236 }
237 237
238 238 cl_walker = mdb_zalloc(sizeof (class_walk_data_t), UM_SLEEP);
239 239 if (mdb_vread(cl_walker->hash_tbl,
240 240 sizeof (cl_walker->hash_tbl), wsp->walk_addr) == -1) {
241 241 mdb_warn("failed to read class hash table at %p",
242 242 wsp->walk_addr);
243 243 return (WALK_ERR);
244 244 }
245 245
246 246 wsp->walk_addr = (uintptr_t)cl_walker->hash_tbl[0];
247 247 wsp->walk_data = cl_walker;
248 248
249 249 return (WALK_NEXT);
250 250 }
251 251
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
252 252 int
253 253 sysevent_class_list_walk_step(mdb_walk_state_t *wsp)
254 254 {
255 255 int status = WALK_NEXT;
256 256 class_walk_data_t *cl_walker;
257 257 class_lst_t clist;
258 258
259 259 cl_walker = (class_walk_data_t *)wsp->walk_data;
260 260
261 261 /* Skip over empty class table entries */
262 - if (wsp->walk_addr != NULL) {
262 + if (wsp->walk_addr != (uintptr_t)NULL) {
263 263 if (mdb_vread(&clist, sizeof (class_lst_t),
264 264 wsp->walk_addr) == -1) {
265 265 mdb_warn("failed to read class list at %p",
266 266 wsp->walk_addr);
267 267 return (WALK_ERR);
268 268 }
269 269
270 270 status = wsp->walk_callback(wsp->walk_addr, NULL,
271 271 wsp->walk_cbdata);
272 272 wsp->walk_addr = (uintptr_t)clist.cl_next;
273 273 } else {
274 274 if (cl_walker->hash_index > CLASS_HASH_SZ) {
275 275 return (WALK_DONE);
276 276 } else {
277 277 wsp->walk_addr = (uintptr_t)
278 278 cl_walker->hash_tbl[cl_walker->hash_index];
279 279 cl_walker->hash_index++;
280 280 }
281 281 }
282 282
283 283
284 284 return (status);
285 285 }
286 286
287 287 void
288 288 sysevent_class_list_walk_fini(mdb_walk_state_t *wsp)
289 289 {
290 290 class_walk_data_t *cl_walker = wsp->walk_data;
291 291
292 292 mdb_free(cl_walker, sizeof (cl_walker));
293 293 }
294 294
295 295 #ifdef _KERNEL
296 296 int
297 297 sysevent(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
298 298 {
299 299 uint_t sys_flags = FALSE;
300 300
301 301 if (mdb_getopts(argc, argv,
302 302 's', MDB_OPT_SETBITS, SYSEVENT_SENTQ, &sys_flags,
303 303 'v', MDB_OPT_SETBITS, SYSEVENT_VERBOSE, &sys_flags, NULL) != argc)
304 304 return (DCMD_USAGE);
305 305
306 306 if ((flags & DCMD_ADDRSPEC) == 0) {
307 307 if (sys_flags & SYSEVENT_SENTQ) {
308 308 if (mdb_walk_dcmd("sysevent_sent", "sysevent", argc,
309 309 argv) == -1) {
310 310 mdb_warn("can not walk sent queue");
311 311 return (DCMD_ERR);
312 312 }
313 313 } else {
314 314 if (mdb_walk_dcmd("sysevent_pend", "sysevent", argc,
315 315 argv) == -1) {
316 316 mdb_warn("can not walk pending queue");
317 317 return (DCMD_ERR);
318 318 }
319 319 }
320 320 return (DCMD_OK);
321 321 }
322 322
323 323 return (sysevent_buf(addr, flags, sys_flags));
324 324 }
325 325
326 326 int
327 327 sysevent_channel(uintptr_t addr, uint_t flags, int argc,
328 328 const mdb_arg_t *argv)
329 329 {
330 330 ssize_t channel_name_sz;
331 331 char channel_name[CHAN_FIELD_MAX];
332 332 sysevent_channel_descriptor_t chan_tbl;
333 333
334 334 if (argc != 0)
335 335 return (DCMD_USAGE);
336 336
337 337 if ((flags & DCMD_ADDRSPEC) == 0) {
338 338 if (mdb_walk_dcmd("sysevent_channel", "sysevent_channel",
339 339 argc, argv) == -1) {
340 340 mdb_warn("can't walk sysevent channel");
341 341 return (DCMD_ERR);
342 342 }
343 343 return (DCMD_OK);
344 344 }
345 345
346 346
347 347 if (DCMD_HDRSPEC(flags))
348 348 mdb_printf("%<u>%-?s %-16s %-8s %-?s%</u>\n",
349 349 "ADDR", "NAME", "REF CNT", "CLASS LST ADDR");
350 350
351 351 if (mdb_vread(&chan_tbl, sizeof (chan_tbl),
352 352 (uintptr_t)addr) == -1) {
353 353 mdb_warn("failed to read channel table at %p", addr);
354 354 return (DCMD_ERR);
355 355 }
356 356 if ((channel_name_sz = mdb_readstr(channel_name, CHAN_FIELD_MAX,
357 357 (uintptr_t)chan_tbl.scd_channel_name)) == -1) {
358 358 mdb_warn("failed to read channel name at %p",
359 359 chan_tbl.scd_channel_name);
360 360 return (DCMD_ERR);
361 361 }
362 362 if (channel_name_sz >= CHAN_FIELD_MAX - 1)
363 363 (void) strcpy(&channel_name[CHAN_FIELD_MAX - 4], "...");
364 364
365 365 mdb_printf("%-?p %-16s %-8lu %-?p\n",
366 366 addr, channel_name, chan_tbl.scd_ref_cnt,
367 367 addr + offsetof(sysevent_channel_descriptor_t,
368 368 scd_class_list_tbl));
369 369
370 370 return (DCMD_OK);
371 371 }
372 372
373 373 typedef struct channel_walk_data {
374 374 int hash_index;
375 375 sysevent_channel_descriptor_t *hash_tbl[CHAN_HASH_SZ];
376 376 } channel_walk_data_t;
377 377
378 378 int
379 379 sysevent_channel_walk_init(mdb_walk_state_t *wsp)
380 380 {
381 381 channel_walk_data_t *ch_walker;
382 382
383 383 if (wsp->walk_addr != NULL) {
384 384 mdb_warn("sysevent_channel supports only global walks");
385 385 return (WALK_ERR);
386 386 }
387 387
388 388 ch_walker = mdb_zalloc(sizeof (channel_walk_data_t), UM_SLEEP);
389 389 if (mdb_readvar(ch_walker->hash_tbl, "registered_channels")
390 390 == -1) {
391 391 mdb_warn("failed to read 'registered_channels'");
392 392 return (WALK_ERR);
393 393 }
394 394
395 395 wsp->walk_addr = (uintptr_t)ch_walker->hash_tbl[0];
396 396 wsp->walk_data = ch_walker;
397 397
398 398 return (WALK_NEXT);
399 399 }
400 400
401 401 int
402 402 sysevent_channel_walk_step(mdb_walk_state_t *wsp)
403 403 {
404 404 int status = WALK_NEXT;
405 405 channel_walk_data_t *ch_walker;
406 406 sysevent_channel_descriptor_t scd;
407 407
408 408 ch_walker = (channel_walk_data_t *)wsp->walk_data;
409 409
410 410 /* Skip over empty hash table entries */
411 411 if (wsp->walk_addr != NULL) {
412 412 if (mdb_vread(&scd, sizeof (sysevent_channel_descriptor_t),
413 413 wsp->walk_addr) == -1) {
414 414 mdb_warn("failed to read channel at %p",
415 415 wsp->walk_addr);
416 416 return (WALK_ERR);
417 417 }
418 418
419 419 status = wsp->walk_callback(wsp->walk_addr, NULL,
420 420 wsp->walk_cbdata);
421 421 wsp->walk_addr = (uintptr_t)scd.scd_next;
422 422 } else {
423 423 if (ch_walker->hash_index == CHAN_HASH_SZ) {
424 424 return (WALK_DONE);
425 425 } else {
426 426
427 427 wsp->walk_addr = (uintptr_t)
428 428 ch_walker->hash_tbl[ch_walker->hash_index];
429 429 ch_walker->hash_index++;
430 430 }
431 431 }
432 432
433 433 return (status);
434 434 }
435 435
436 436 void
437 437 sysevent_channel_walk_fini(mdb_walk_state_t *wsp)
438 438 {
439 439 channel_walk_data_t *ch_walker = wsp->walk_data;
440 440
441 441 mdb_free(ch_walker, sizeof (ch_walker));
442 442 }
443 443
444 444 int
445 445 sysevent_pend_walk_init(mdb_walk_state_t *wsp)
446 446 {
447 447 if (wsp->walk_addr == NULL) {
448 448 if (mdb_readvar(&wsp->walk_addr, "log_eventq_head") == -1) {
449 449 mdb_warn("failed to read 'log_eventq_head'");
450 450 return (WALK_ERR);
451 451 }
452 452 }
453 453
454 454 wsp->walk_data = mdb_alloc(sizeof (log_eventq_t), UM_SLEEP);
455 455 return (WALK_NEXT);
456 456 }
457 457
458 458 int
459 459 sysevent_walk_step(mdb_walk_state_t *wsp)
460 460 {
461 461 int status;
462 462 uintptr_t ev_arg_addr;
463 463
464 464 if (wsp->walk_addr == NULL)
465 465 return (WALK_DONE);
466 466
467 467 if (mdb_vread(wsp->walk_data, sizeof (log_eventq_t),
468 468 wsp->walk_addr) == -1) {
469 469 mdb_warn("failed to read event queue at %p", wsp->walk_addr);
470 470 return (WALK_ERR);
471 471 }
472 472 ev_arg_addr = wsp->walk_addr + offsetof(log_eventq_t, arg.buf);
473 473
474 474 status = wsp->walk_callback(ev_arg_addr, wsp->walk_data,
475 475 wsp->walk_cbdata);
476 476 wsp->walk_addr = (uintptr_t)(((log_eventq_t *)wsp->walk_data)->next);
477 477 return (status);
478 478 }
479 479
480 480 int
481 481 sysevent_sent_walk_init(mdb_walk_state_t *wsp)
482 482 {
483 483 if (wsp->walk_addr == NULL) {
484 484 if (mdb_readvar(&wsp->walk_addr, "log_eventq_sent") == -1) {
485 485 mdb_warn("failed to read 'log_eventq_sent'");
486 486 return (WALK_ERR);
487 487 }
488 488 }
489 489 wsp->walk_data = mdb_alloc(sizeof (log_eventq_t), UM_SLEEP);
490 490 return (WALK_NEXT);
491 491 }
492 492
493 493 void
494 494 sysevent_walk_fini(mdb_walk_state_t *wsp)
495 495 {
496 496 mdb_free(wsp->walk_data, sizeof (log_eventq_t));
497 497 }
498 498
499 499 #endif
↓ open down ↓ |
227 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX