Introducing /proc/xenomai/registry/dump which could be accessed by something like "cat" to dump the current registry. Like the "usage" file it is available when CONFIG_XENO_OPT_VFILE is enabled.
The main purpose of this file is providing some additional help when trying to find resource leaks triggered by Xenomai based applications. Signed-off-by: Florian Bezdeka <[email protected]> --- kernel/cobalt/registry.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c index 816102f7a..8befa795c 100644 --- a/kernel/cobalt/registry.c +++ b/kernel/cobalt/registry.c @@ -80,6 +80,23 @@ static int usage_vfile_show(struct xnvfile_regular_iterator *it, void *data) return 0; } +static int dump_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + struct xnobject *elem; + struct hlist_node *next; + int n; + + xnvfile_printf(it, "nr_object_entries: %d\n", nr_object_entries); + xnvfile_printf(it, "obj_idx[0]: \treserved\n"); + + for (n = 0; n < nr_object_entries; n++) + hlist_for_each_entry_safe(elem, next, &object_index[n], hlink) + xnvfile_printf(it, "obj_idx[%d]:\tobj=%p, key=%s\n", n, + elem->objaddr, elem->key ?: "(anon)"); + + return 0; +} + static struct xnvfile_regular_ops usage_vfile_ops = { .show = usage_vfile_show, }; @@ -88,6 +105,14 @@ static struct xnvfile_regular usage_vfile = { .ops = &usage_vfile_ops, }; +static struct xnvfile_regular_ops dump_vfile_ops = { + .show = dump_vfile_show, +}; + +static struct xnvfile_regular dump_vfile = { + .ops = &dump_vfile_ops, +}; + #endif /* CONFIG_XENO_OPT_VFILE */ unsigned xnregistry_hash_size(void) @@ -124,8 +149,16 @@ int xnregistry_init(void) return ret; } + ret = xnvfile_init_regular("dump", &dump_vfile, ®istry_vfroot); + if (ret) { + xnvfile_destroy_regular(&usage_vfile); + xnvfile_destroy_dir(®istry_vfroot); + return ret; + } + proc_virq = pipeline_create_inband_sirq(registry_proc_schedule); if (proc_virq < 0) { + xnvfile_destroy_regular(&dump_vfile); xnvfile_destroy_regular(&usage_vfile); xnvfile_destroy_dir(®istry_vfroot); return proc_virq; @@ -149,6 +182,7 @@ int xnregistry_init(void) if (object_index == NULL) { #ifdef CONFIG_XENO_OPT_VFILE + xnvfile_destroy_regular(&dump_vfile); xnvfile_destroy_regular(&usage_vfile); xnvfile_destroy_dir(®istry_vfroot); pipeline_delete_inband_sirq(proc_virq); @@ -199,6 +233,7 @@ void xnregistry_cleanup(void) #ifdef CONFIG_XENO_OPT_VFILE pipeline_delete_inband_sirq(proc_virq); flush_scheduled_work(); + xnvfile_destroy_regular(&dump_vfile); xnvfile_destroy_regular(&usage_vfile); xnvfile_destroy_dir(®istry_vfroot); #endif /* CONFIG_XENO_OPT_VFILE */ -- 2.30.2
