4305 mdb_whatis_register("kmem", whatis_run_kmem, NULL,
4306 WHATIS_PRIO_ALLOCATOR, 0);
4307 mdb_whatis_register("vmem", whatis_run_vmem, NULL,
4308 WHATIS_PRIO_ALLOCATOR, 0);
4309 }
4310
4311 typedef struct whatthread {
4312 uintptr_t wt_target;
4313 int wt_verbose;
4314 } whatthread_t;
4315
4316 static int
4317 whatthread_walk_thread(uintptr_t addr, const kthread_t *t, whatthread_t *w)
4318 {
4319 uintptr_t current, data;
4320
4321 if (t->t_stkbase == NULL)
4322 return (WALK_NEXT);
4323
4324 /*
4325 * Warn about swapped out threads, but drive on anyway
4326 */
4327 if (!(t->t_schedflag & TS_LOAD)) {
4328 mdb_warn("thread %p's stack swapped out\n", addr);
4329 return (WALK_NEXT);
4330 }
4331
4332 /*
4333 * Search the thread's stack for the given pointer. Note that it would
4334 * be more efficient to follow ::kgrep's lead and read in page-sized
4335 * chunks, but this routine is already fast and simple.
4336 */
4337 for (current = (uintptr_t)t->t_stkbase; current < (uintptr_t)t->t_stk;
4338 current += sizeof (uintptr_t)) {
4339 if (mdb_vread(&data, sizeof (data), current) == -1) {
4340 mdb_warn("couldn't read thread %p's stack at %p",
4341 addr, current);
4342 return (WALK_ERR);
4343 }
4344
4345 if (data == w->wt_target) {
4346 if (w->wt_verbose) {
4347 mdb_printf("%p in thread %p's stack%s\n",
4348 current, addr, stack_active(t, current));
4349 } else {
4350 mdb_printf("%#lr\n", addr);
4351 return (WALK_NEXT);
4352 }
|
4305 mdb_whatis_register("kmem", whatis_run_kmem, NULL,
4306 WHATIS_PRIO_ALLOCATOR, 0);
4307 mdb_whatis_register("vmem", whatis_run_vmem, NULL,
4308 WHATIS_PRIO_ALLOCATOR, 0);
4309 }
4310
4311 typedef struct whatthread {
4312 uintptr_t wt_target;
4313 int wt_verbose;
4314 } whatthread_t;
4315
4316 static int
4317 whatthread_walk_thread(uintptr_t addr, const kthread_t *t, whatthread_t *w)
4318 {
4319 uintptr_t current, data;
4320
4321 if (t->t_stkbase == NULL)
4322 return (WALK_NEXT);
4323
4324 /*
4325 * Search the thread's stack for the given pointer. Note that it would
4326 * be more efficient to follow ::kgrep's lead and read in page-sized
4327 * chunks, but this routine is already fast and simple.
4328 */
4329 for (current = (uintptr_t)t->t_stkbase; current < (uintptr_t)t->t_stk;
4330 current += sizeof (uintptr_t)) {
4331 if (mdb_vread(&data, sizeof (data), current) == -1) {
4332 mdb_warn("couldn't read thread %p's stack at %p",
4333 addr, current);
4334 return (WALK_ERR);
4335 }
4336
4337 if (data == w->wt_target) {
4338 if (w->wt_verbose) {
4339 mdb_printf("%p in thread %p's stack%s\n",
4340 current, addr, stack_active(t, current));
4341 } else {
4342 mdb_printf("%#lr\n", addr);
4343 return (WALK_NEXT);
4344 }
|