From: Jim Cromie <[email protected]> Add an epilogue to the control-file, to allow display of statistics etc, without disturbing the header.
NB: epilogue lines should start with "#: " to distinguish them from lines describing pr_debugs (and from the header line). No new lines are added here, only the place to do so. Signed-off-by: Jim Cromie <[email protected]> --- lib/dynamic_debug.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b7ccf471b5ef..d098afe8d340 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1183,17 +1183,28 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos) * call from userspace, with ddebug_lock held. Walks to the * next _ddebug object with a special case for the header line. */ +static char ddebug_epilogue_token; +#define EPILOGUE_TOKEN (&ddebug_epilogue_token) + static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) { struct ddebug_iter *iter = m->private; struct _ddebug *dp; + (*pos)++; + + if (p == EPILOGUE_TOKEN) + return NULL; + if (p == SEQ_START_TOKEN) dp = ddebug_iter_first(iter); else dp = ddebug_iter_next(iter); - ++*pos; - return dp; + + if (dp) + return dp; + + return EPILOGUE_TOKEN; } static bool ddebug_class_map_in_range(const int class_id, const struct ddebug_class_map *map) @@ -1245,6 +1256,10 @@ static int ddebug_proc_show(struct seq_file *m, void *p) "# filename:lineno [module]function flags format\n"); return 0; } + if (p == EPILOGUE_TOKEN) { + /* use this soon */ + return 0; + } seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dp->filename), dp->lineno, -- 2.55.0
