Skip to content

Commit cb910c6

Browse files
committed
unix/moduselect: Add .dump() method for debugging.
Commented out by default.
1 parent 99bf544 commit cb910c6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ports/unix/moduselect.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,30 @@ STATIC mp_obj_t poll_iternext(mp_obj_t self_in) {
277277
return MP_OBJ_STOP_ITERATION;
278278
}
279279

280+
STATIC mp_obj_t poll_dump(mp_obj_t self_in) {
281+
mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in);
282+
283+
struct pollfd *entries = self->entries;
284+
for (int i = self->len - 1; i >= 0; i--) {
285+
printf("fd: %d ev: %x rev: %x", entries->fd, entries->events, entries->revents);
286+
if (self->obj_map) {
287+
printf(" obj: %p", self->obj_map[entries - self->entries]);
288+
}
289+
printf("\n");
290+
entries++;
291+
}
292+
293+
return mp_const_none;
294+
}
295+
MP_DEFINE_CONST_FUN_OBJ_1(poll_dump_obj, poll_dump);
296+
280297
STATIC const mp_rom_map_elem_t poll_locals_dict_table[] = {
281298
{ MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(&poll_register_obj) },
282299
{ MP_ROM_QSTR(MP_QSTR_unregister), MP_ROM_PTR(&poll_unregister_obj) },
283300
{ MP_ROM_QSTR(MP_QSTR_modify), MP_ROM_PTR(&poll_modify_obj) },
284301
{ MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&poll_poll_obj) },
285302
{ MP_ROM_QSTR(MP_QSTR_ipoll), MP_ROM_PTR(&poll_ipoll_obj) },
303+
// { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&poll_dump_obj) },
286304
};
287305
STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table);
288306

0 commit comments

Comments
 (0)