[PATCH v9 37/39] dyndbg: add epilogue to dynamic_debug/control file

From: Jim Cromie via B4 Relay

Date: Tue Sep 08 2026 - 21:06:38 EST


From: Jim Cromie <jim.cromie@xxxxxxxxx>

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 <jim.cromie@xxxxxxxxx>
---
v9:
. update ddebug_proc_start() to return EPILOGUE_TOKEN when seeking directly to epilogue.
---
lib/dynamic_debug.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index afde13a2121f..77976e7b264c 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1159,6 +1159,9 @@ static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter)
* read() call from userspace. Takes the ddebug_lock and
* seeks the seq_file's iterator to the given position.
*/
+static char ddebug_epilogue_token;
+#define EPILOGUE_TOKEN (&ddebug_epilogue_token)
+
static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
{
struct ddebug_iter *iter = m->private;
@@ -1174,7 +1177,9 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
dp = ddebug_iter_first(iter);
while (dp != NULL && --n > 0)
dp = ddebug_iter_next(iter);
- return dp;
+ if (dp)
+ return dp;
+ return n == 0 ? EPILOGUE_TOKEN : NULL;
}

/*
@@ -1187,12 +1192,20 @@ 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)
@@ -1244,6 +1257,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