164 return (DCMD_ERR);
165 }
166 if ((class_name_sz = mdb_readstr(class_name, CLASS_LIST_FIELD_MAX,
167 (uintptr_t)clist.cl_name)) == -1) {
168 mdb_warn("failed to read class name at %p",
169 clist.cl_name);
170 return (DCMD_ERR);
171 }
172 if (class_name_sz >= CLASS_LIST_FIELD_MAX - 1)
173 (void) strcpy(&class_name[CLASS_LIST_FIELD_MAX - 4], "...");
174
175 mdb_printf("%-?p %-24s %-?p\n", addr, class_name,
176 clist.cl_subclass_list);
177
178 return (DCMD_OK);
179 }
180
181 int
182 sysevent_subclass_list_walk_init(mdb_walk_state_t *wsp)
183 {
184 if (wsp->walk_addr == NULL) {
185 mdb_warn("sysevent_subclass_list does not support global "
186 "walks");
187 return (WALK_ERR);
188 }
189
190 wsp->walk_data = mdb_alloc(sizeof (subclass_lst_t), UM_SLEEP);
191 return (WALK_NEXT);
192 }
193
194 int
195 sysevent_subclass_list_walk_step(mdb_walk_state_t *wsp)
196 {
197 int status;
198
199 if (wsp->walk_addr == NULL)
200 return (WALK_DONE);
201
202 if (mdb_vread(wsp->walk_data, sizeof (subclass_lst_t),
203 wsp->walk_addr) == -1) {
204 mdb_warn("failed to read class list at %p", wsp->walk_addr);
205 return (WALK_ERR);
206 }
207
208 status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
209 wsp->walk_cbdata);
210
211 wsp->walk_addr =
212 (uintptr_t)(((subclass_lst_t *)wsp->walk_data)->sl_next);
213
214 return (status);
215 }
216
217 void
218 sysevent_subclass_list_walk_fini(mdb_walk_state_t *wsp)
219 {
220 mdb_free(wsp->walk_data, sizeof (subclass_lst_t));
221 }
222
223 typedef struct class_walk_data {
224 int hash_index;
225 class_lst_t *hash_tbl[CLASS_HASH_SZ + 1];
226 } class_walk_data_t;
227
228 int
229 sysevent_class_list_walk_init(mdb_walk_state_t *wsp)
230 {
231 class_walk_data_t *cl_walker;
232
233 if (wsp->walk_addr == NULL) {
234 mdb_warn("sysevent_class_list does not support global walks");
235 return (WALK_ERR);
236 }
237
238 cl_walker = mdb_zalloc(sizeof (class_walk_data_t), UM_SLEEP);
239 if (mdb_vread(cl_walker->hash_tbl,
240 sizeof (cl_walker->hash_tbl), wsp->walk_addr) == -1) {
241 mdb_warn("failed to read class hash table at %p",
242 wsp->walk_addr);
243 return (WALK_ERR);
244 }
245
246 wsp->walk_addr = (uintptr_t)cl_walker->hash_tbl[0];
247 wsp->walk_data = cl_walker;
248
249 return (WALK_NEXT);
250 }
251
252 int
253 sysevent_class_list_walk_step(mdb_walk_state_t *wsp)
254 {
255 int status = WALK_NEXT;
256 class_walk_data_t *cl_walker;
257 class_lst_t clist;
258
259 cl_walker = (class_walk_data_t *)wsp->walk_data;
260
261 /* Skip over empty class table entries */
262 if (wsp->walk_addr != NULL) {
263 if (mdb_vread(&clist, sizeof (class_lst_t),
264 wsp->walk_addr) == -1) {
265 mdb_warn("failed to read class list at %p",
266 wsp->walk_addr);
267 return (WALK_ERR);
268 }
269
270 status = wsp->walk_callback(wsp->walk_addr, NULL,
271 wsp->walk_cbdata);
272 wsp->walk_addr = (uintptr_t)clist.cl_next;
273 } else {
274 if (cl_walker->hash_index > CLASS_HASH_SZ) {
275 return (WALK_DONE);
276 } else {
277 wsp->walk_addr = (uintptr_t)
278 cl_walker->hash_tbl[cl_walker->hash_index];
279 cl_walker->hash_index++;
280 }
281 }
282
|
164 return (DCMD_ERR);
165 }
166 if ((class_name_sz = mdb_readstr(class_name, CLASS_LIST_FIELD_MAX,
167 (uintptr_t)clist.cl_name)) == -1) {
168 mdb_warn("failed to read class name at %p",
169 clist.cl_name);
170 return (DCMD_ERR);
171 }
172 if (class_name_sz >= CLASS_LIST_FIELD_MAX - 1)
173 (void) strcpy(&class_name[CLASS_LIST_FIELD_MAX - 4], "...");
174
175 mdb_printf("%-?p %-24s %-?p\n", addr, class_name,
176 clist.cl_subclass_list);
177
178 return (DCMD_OK);
179 }
180
181 int
182 sysevent_subclass_list_walk_init(mdb_walk_state_t *wsp)
183 {
184 if (wsp->walk_addr == (uintptr_t)NULL) {
185 mdb_warn("sysevent_subclass_list does not support global "
186 "walks");
187 return (WALK_ERR);
188 }
189
190 wsp->walk_data = mdb_alloc(sizeof (subclass_lst_t), UM_SLEEP);
191 return (WALK_NEXT);
192 }
193
194 int
195 sysevent_subclass_list_walk_step(mdb_walk_state_t *wsp)
196 {
197 int status;
198
199 if (wsp->walk_addr == (uintptr_t)NULL)
200 return (WALK_DONE);
201
202 if (mdb_vread(wsp->walk_data, sizeof (subclass_lst_t),
203 wsp->walk_addr) == -1) {
204 mdb_warn("failed to read class list at %p", wsp->walk_addr);
205 return (WALK_ERR);
206 }
207
208 status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
209 wsp->walk_cbdata);
210
211 wsp->walk_addr =
212 (uintptr_t)(((subclass_lst_t *)wsp->walk_data)->sl_next);
213
214 return (status);
215 }
216
217 void
218 sysevent_subclass_list_walk_fini(mdb_walk_state_t *wsp)
219 {
220 mdb_free(wsp->walk_data, sizeof (subclass_lst_t));
221 }
222
223 typedef struct class_walk_data {
224 int hash_index;
225 class_lst_t *hash_tbl[CLASS_HASH_SZ + 1];
226 } class_walk_data_t;
227
228 int
229 sysevent_class_list_walk_init(mdb_walk_state_t *wsp)
230 {
231 class_walk_data_t *cl_walker;
232
233 if (wsp->walk_addr == (uintptr_t)NULL) {
234 mdb_warn("sysevent_class_list does not support global walks");
235 return (WALK_ERR);
236 }
237
238 cl_walker = mdb_zalloc(sizeof (class_walk_data_t), UM_SLEEP);
239 if (mdb_vread(cl_walker->hash_tbl,
240 sizeof (cl_walker->hash_tbl), wsp->walk_addr) == -1) {
241 mdb_warn("failed to read class hash table at %p",
242 wsp->walk_addr);
243 return (WALK_ERR);
244 }
245
246 wsp->walk_addr = (uintptr_t)cl_walker->hash_tbl[0];
247 wsp->walk_data = cl_walker;
248
249 return (WALK_NEXT);
250 }
251
252 int
253 sysevent_class_list_walk_step(mdb_walk_state_t *wsp)
254 {
255 int status = WALK_NEXT;
256 class_walk_data_t *cl_walker;
257 class_lst_t clist;
258
259 cl_walker = (class_walk_data_t *)wsp->walk_data;
260
261 /* Skip over empty class table entries */
262 if (wsp->walk_addr != (uintptr_t)NULL) {
263 if (mdb_vread(&clist, sizeof (class_lst_t),
264 wsp->walk_addr) == -1) {
265 mdb_warn("failed to read class list at %p",
266 wsp->walk_addr);
267 return (WALK_ERR);
268 }
269
270 status = wsp->walk_callback(wsp->walk_addr, NULL,
271 wsp->walk_cbdata);
272 wsp->walk_addr = (uintptr_t)clist.cl_next;
273 } else {
274 if (cl_walker->hash_index > CLASS_HASH_SZ) {
275 return (WALK_DONE);
276 } else {
277 wsp->walk_addr = (uintptr_t)
278 cl_walker->hash_tbl[cl_walker->hash_index];
279 cl_walker->hash_index++;
280 }
281 }
282
|