Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/modules/examples/ddbping ddbping - restore the original ...



details:   https://anonhg.NetBSD.org/src/rev/dc526af5e592
branches:  trunk
changeset: 373312:dc526af5e592
user:      uwe <uwe%NetBSD.org@localhost>
date:      Wed Feb 01 10:22:20 2023 +0000

description:
ddbping - restore the original narration of the example, NFCI

Adjust previous change so that it only replaces my home-grown define
for the end marker with the new official DDB_END_CMD marker that it
introduced.  Undo the rest of that last change.

As the author of this example I'm pretty sure what example I wanted to
set and this narration order is an important part of it.

diffstat:

 sys/modules/examples/ddbping/ddbping.c |  41 ++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 16 deletions(-)

diffs (74 lines):

diff -r d2ae5564f3f2 -r dc526af5e592 sys/modules/examples/ddbping/ddbping.c
--- a/sys/modules/examples/ddbping/ddbping.c    Wed Feb 01 03:27:45 2023 +0000
+++ b/sys/modules/examples/ddbping/ddbping.c    Wed Feb 01 10:22:20 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddbping.c,v 1.2 2021/02/23 07:13:53 mrg Exp $ */
+/*     $NetBSD: ddbping.c,v 1.3 2023/02/01 10:22:20 uwe Exp $ */
 /*
  * Copyright (c) 2020 Valery Ushakov
  * All rights reserved.
@@ -28,19 +28,42 @@
  * Example of a kernel module that registers DDB commands.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddbping.c,v 1.2 2021/02/23 07:13:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddbping.c,v 1.3 2023/02/01 10:22:20 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/module.h>
 
 #include <ddb/ddb.h>
 
+/* XXX: db_command.h should provide something like this */
+typedef void db_cmdfn_t(db_expr_t, bool, db_expr_t, const char *);
+
+
+static db_cmdfn_t db_ping;
+static db_cmdfn_t db_show_ping;
+
+
+static const struct db_command db_ping_base_tbl[] = {
+       { DDB_ADD_CMD("ping", db_ping, 0,
+                     "Example command",
+                     NULL, NULL) },
+       { DDB_END_CMD },
+};
+
+static const struct db_command db_ping_show_tbl[] = {
+       { DDB_ADD_CMD("ping", db_show_ping, 0,
+                     "Example command stats",
+                     NULL, NULL) },
+       { DDB_END_CMD },
+};
+
 
 static unsigned int ping_count;
 static unsigned int ping_count_modif;
 static unsigned int ping_count_addr;
 static unsigned int ping_count_count;
 
+
 static void
 db_ping(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
@@ -75,20 +98,6 @@
        db_printf("with count\t%u\n", ping_count_count);
 }
 
-static const struct db_command db_ping_base_tbl[] = {
-       { DDB_ADD_CMD("ping", db_ping, 0,
-                     "Example command",
-                     NULL, NULL) },
-       { DDB_END_CMD },
-};
-
-static const struct db_command db_ping_show_tbl[] = {
-       { DDB_ADD_CMD("ping", db_show_ping, 0,
-                     "Example command stats",
-                     NULL, NULL) },
-       { DDB_END_CMD },
-};
-
 
 MODULE(MODULE_CLASS_MISC, ddbping, NULL);
 



Home | Main Index | Thread Index | Old Index