From 99df2027777cb732918ca8aaaa5efcfd75b615d3 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 1 Jan 2025 16:21:13 -0800 Subject: libvmon: add vmon_dump_procs() debugging aid It's handy to see what the libvmon hash table state of the world is when trying to understand brokenness, but also as a tool for verifying things aren't out of sync with what the hierarchical view contains. --- src/libvmon/vmon.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/libvmon/vmon.c') diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index 4ce0974..69dc99b 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -1689,3 +1689,21 @@ int vmon_sample(vmon_t *vmon) return ret; } + + +void vmon_dump_procs(vmon_t *vmon, FILE *out) +{ + assert(vmon); + assert(out); + + fprintf(out, "generation=%i\n", vmon->generation); + for (int i = 0; i < VMON_HTAB_SIZE; i++) { + vmon_proc_t *proc; + + list_for_each_entry(proc, &vmon->htab[i], bucket) { + fprintf(out, "[%i] proc=%p parent=%p gen=%i pid=%i rc=%i is_threaded=%i is_thread=%i is_new=%u is_stale=%u\n", + i, proc, proc->parent, proc->generation, proc->pid, proc->refcnt, (unsigned)proc->is_threaded, (unsigned)proc->is_thread, (unsigned)proc->is_new, (unsigned)proc->is_stale); + + } + } +} -- cgit v1.2.3