···710710 <listitem><para>A simple shell</para></listitem>711711 <listitem><para>The kdb core command set</para></listitem>712712 <listitem><para>A registration API to register additional kdb shell commands.</para>713713- <para>A good example of a self-contained kdb module is the "ftdump" command for dumping the ftrace buffer. See: kernel/trace/trace_kdb.c</para></listitem>713713+ <itemizedlist>714714+ <listitem><para>A good example of a self-contained kdb module715715+ is the "ftdump" command for dumping the ftrace buffer. See:716716+ kernel/trace/trace_kdb.c</para></listitem>717717+ <listitem><para>For an example of how to dynamically register718718+ a new kdb command you can build the kdb_hello.ko kernel module719719+ from samples/kdb/kdb_hello.c. To build this example you can720720+ set CONFIG_SAMPLES=y and CONFIG_SAMPLE_KDB=m in your kernel721721+ config. Later run "modprobe kdb_hello" and the next time you722722+ enter the kdb shell, you can run the "hello"723723+ command.</para></listitem>724724+ </itemizedlist></listitem>714725 <listitem><para>The implementation for kdb_printf() which715726 emits messages directly to I/O drivers, bypassing the kernel716727 log.</para></listitem>
+7
samples/Kconfig
···54545555 If in doubt, say "N" here.56565757+config SAMPLE_KDB5858+ tristate "Build kdb command exmaple -- loadable modules only"5959+ depends on KGDB_KDB && m6060+ help6161+ Build an example of how to dynamically add the hello6262+ command to the kdb shell.6363+5764endif # SAMPLES
+1-1
samples/Makefile
···11# Makefile for Linux samples code2233obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ tracepoints/ trace_events/ \44- hw_breakpoint/ kfifo/44+ hw_breakpoint/ kfifo/ kdb/
···11+/*22+ * Created by: Jason Wessel <jason.wessel@windriver.com>33+ *44+ * Copyright (c) 2010 Wind River Systems, Inc. All Rights Reserved.55+ *66+ * This file is licensed under the terms of the GNU General Public77+ * License version 2. This program is licensed "as is" without any88+ * warranty of any kind, whether express or implied.99+ */1010+1111+#include <linux/module.h>1212+#include <linux/kdb.h>1313+1414+/*1515+ * All kdb shell command call backs receive argc and argv, where1616+ * argv[0] is the command the end user typed1717+ */1818+static int kdb_hello_cmd(int argc, const char **argv)1919+{2020+ if (argc > 1)2121+ return KDB_ARGCOUNT;2222+2323+ if (argc)2424+ kdb_printf("Hello %s.\n", argv[1]);2525+ else2626+ kdb_printf("Hello world!\n");2727+2828+ return 0;2929+}3030+3131+3232+static int __init kdb_hello_cmd_init(void)3333+{3434+ /*3535+ * Registration of a dynamically added kdb command is done with3636+ * kdb_register() with the arguments being:3737+ * 1: The name of the shell command3838+ * 2: The function that processes the command3939+ * 3: Description of the usage of any arguments4040+ * 4: Descriptive text when you run help4141+ * 5: Number of characters to complete the command4242+ * 0 == type the whole command4343+ * 1 == match both "g" and "go" for example4444+ */4545+ kdb_register("hello", kdb_hello_cmd, "[string]",4646+ "Say Hello World or Hello [string]", 0);4747+ return 0;4848+}4949+5050+static void __exit kdb_hello_cmd_exit(void)5151+{5252+ kdb_unregister("hello");5353+}5454+5555+module_init(kdb_hello_cmd_init);5656+module_exit(kdb_hello_cmd_exit);5757+5858+MODULE_AUTHOR("WindRiver");5959+MODULE_DESCRIPTION("KDB example to add a hello command");6060+MODULE_LICENSE("GPL");