Subject: Re: ddb help command patch
To: Bill Stouder-Studenmund <wrstuden@netbsd.org>
From: Adam Hamsik <haaaad@gmail.com>
List: tech-kern
Date: 07/18/2007 10:54:44
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--Apple-Mail-7-283254841
Content-Type: multipart/mixed; boundary=Apple-Mail-6-283254789
--Apple-Mail-6-283254789
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
Hi
I was pointed off-list to that I have sent bad patches to the list. I
have accidently generated them without -u. Now I have generated my
patch with cvs diff -u command.
I have one question. I have added file db_command_list.h to the list
with cvs add command. How can I properly generate patch with this
added file because cvs diff -u doesn't contain this file.
--Apple-Mail-6-283254789
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name=db_command_list.h
Content-Disposition: attachment;
filename=db_command_list.h
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Adam Hamsik.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#ifndef _DDB_COMMAND_LIST_
#define _DDB_COMMAND_LIST_
/**/
TAILQ_HEAD(db_cmd_tbl_en_head, db_cmd_tbl_en);
/*TAILQ entry used in default commands and show commands lists.*/
struct db_cmd_tbl_en {
uint32_t db_cmd_num; /*Number of commands in cmd table*/
const struct db_command *db_cmd; /*pointer to static allocated cmd table*/
TAILQ_ENTRY(db_cmd_tbl_en) db_cmd_next; /*TAILQ pointers*/
};
#endif/*!_DDB_COMMAND_LIST_*/
--Apple-Mail-6-283254789
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name=ddb_cmd.diff
Content-Disposition: attachment;
filename=ddb_cmd.diff
? arch/i386/compile/GENERIC
? arch/i386/conf/.t41_not.swp
? arch/i386/conf/GENERIC_CD
? arch/i386/conf/GENERIC_T41
? arch/i386/conf/t41_not
? arch/i386/stand/boot/lib
? arch/i386/stand/genprom/genprom
? arch/i386/stand/genprom/genprom.lo
? arch/i386/stand/mbr/mbr/.gdbinit
? arch/i386/stand/mbr/mbr_bootsel/.gdbinit
? arch/i386/stand/mbr/mbr_ext/.gdbinit
? lkm/misc/example/test/.gdbinit
? lkm/misc/example/test/testmisc
Index: arch/acorn26/acorn26/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/db_interface.c,v
retrieving revision 1.14
diff -u -r1.14 db_interface.c
--- arch/acorn26/acorn26/db_interface.c 22 Feb 2007 04:47:27 -0000 1.14
+++ arch/acorn26/acorn26/db_interface.c 18 Jul 2007 07:24:10 -0000
@@ -241,11 +241,11 @@
}
const struct db_command db_machine_command_table[] = {
- { "bsw", db_bus_write_cmd, CS_MORE, NULL },
- { "frame", db_show_frame_cmd, 0, NULL },
- { "irqstat", db_irqstat_cmd, 0, NULL },
- { "panic", db_show_panic_cmd, 0, NULL },
- { NULL, NULL, 0, NULL }
+ { DDB_ADD_CMD("bsw", db_bus_write_cmd, CS_MORE, NULL,NULL) },
+ { DDB_ADD_CMD("frame", db_show_frame_cmd, 0, NULL, NULL) },
+ { DDB_ADD_CMD("irqstat",db_irqstat_cmd, 0, NULL, NULL) },
+ { DDB_ADD_CMD("panic", db_show_panic_cmd, 0, NULL, NULL) },
+ { DDB_ADD_CMD( NULL, NULL, 0, NULL, NULL) }
};
int
Index: arch/alpha/alpha/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/db_interface.c,v
retrieving revision 1.25
diff -u -r1.25 db_interface.c
--- arch/alpha/alpha/db_interface.c 22 Feb 2007 20:09:42 -0000 1.25
+++ arch/alpha/alpha/db_interface.c 18 Jul 2007 07:24:12 -0000
@@ -94,9 +94,9 @@
const struct db_command db_machine_command_table[] = {
#if defined(MULTIPROCESSOR)
- { "cpu", db_mach_cpu, 0, 0 },
+ { DDB_ADD_CMD("cpu", db_mach_cpu, 0,NULL,NULL) },
#endif
- { (char *)0, },
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) },
};
static int db_alpha_regop __P((const struct db_variable *, db_expr_t *, int));
Index: arch/amd64/amd64/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/db_interface.c,v
retrieving revision 1.8
diff -u -r1.8 db_interface.c
--- arch/amd64/amd64/db_interface.c 4 Jun 2007 23:15:00 -0000 1.8
+++ arch/amd64/amd64/db_interface.c 18 Jul 2007 07:24:15 -0000
@@ -73,9 +73,9 @@
const struct db_command db_machine_command_table[] = {
#ifdef MULTIPROCESSOR
- { "cpu", db_mach_cpu, 0, 0 },
+ { DDB_ADD_CMD("cpu", db_mach_cpu, 0, NULL,NULL )},
#endif
- { (char *)0, },
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) },
};
void kdbprinttrap(int, int);
Index: arch/arm/arm32/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/db_interface.c,v
retrieving revision 1.42
diff -u -r1.42 db_interface.c
--- arch/arm/arm32/db_interface.c 22 Feb 2007 05:14:05 -0000 1.42
+++ arch/arm/arm32/db_interface.c 18 Jul 2007 07:24:17 -0000
@@ -365,12 +365,12 @@
}
const struct db_command db_machine_command_table[] = {
- { "frame", db_show_frame_cmd, 0, NULL },
- { "panic", db_show_panic_cmd, 0, NULL },
+ { DDB_ADD_CMD("frame", db_show_frame_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("panic", db_show_panic_cmd, 0, NULL,NULL) },
#ifdef ARM32_DB_COMMANDS
ARM32_DB_COMMANDS,
#endif
- { NULL, NULL, 0, NULL }
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) }
};
int
Index: arch/i386/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.835
diff -u -r1.835 GENERIC
--- arch/i386/conf/GENERIC 27 Jun 2007 23:12:03 -0000 1.835
+++ arch/i386/conf/GENERIC 18 Jul 2007 07:24:28 -0000
@@ -123,17 +123,18 @@
#options BUFQ_PRIOCSCAN
# Diagnostic/debugging support options
-#options DIAGNOSTIC # expensive kernel consistency checks
-#options DEBUG # expensive debugging checks/support
-#options KMEMSTATS # kernel memory statistics (vmstat -m)
+options DIAGNOSTIC # expensive kernel consistency checks
+options DEBUG # expensive debugging checks/support
+options KMEMSTATS # kernel memory statistics (vmstat -m)
options DDB # in-kernel debugger
-#options DDB_ONPANIC=1 # see also sysctl(8): `ddb.onpanic'
+options DDB_VERBOSE_HELP=1 #verbose in kernel debuger help (increase size of kernel)
+options DDB_ONPANIC=1 # see also sysctl(8): `ddb.onpanic'
options DDB_HISTORY_SIZE=512 # enable history editing in DDB
#options KGDB # remote debugger
#options KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
-#makeoptions DEBUG="-g" # compile full symbol table
-#options SYSCALL_STATS # per syscall counts
-#options SYSCALL_TIMES # per syscall times
+makeoptions DEBUG="-g" # compile full symbol table
+options SYSCALL_STATS # per syscall counts
+options SYSCALL_TIMES # per syscall times
#options SYSCALL_TIMES_HASCOUNTER # use 'broken' rdtsc (soekris)
# Compatibility options
Index: arch/i386/i386/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/db_interface.c,v
retrieving revision 1.51
diff -u -r1.51 db_interface.c
--- arch/i386/i386/db_interface.c 7 Mar 2007 21:43:43 -0000 1.51
+++ arch/i386/i386/db_interface.c 18 Jul 2007 07:24:29 -0000
@@ -72,9 +72,9 @@
const struct db_command db_machine_command_table[] = {
#ifdef MULTIPROCESSOR
- { "cpu", db_mach_cpu, 0, 0 },
+ { DDB_ADD_CMD("cpu", db_mach_cpu, 0, NULL,NULL) },
#endif
- { NULL, NULL, 0, 0 },
+ { DDB_ADD_CMD(NULL, NULL, 0, NULL,NULL) },
};
void kdbprinttrap(int, int);
Index: arch/ia64/ia64/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/ia64/ia64/db_interface.c,v
retrieving revision 1.2
diff -u -r1.2 db_interface.c
--- arch/ia64/ia64/db_interface.c 21 Feb 2007 22:59:45 -0000 1.2
+++ arch/ia64/ia64/db_interface.c 18 Jul 2007 07:24:30 -0000
@@ -111,7 +111,7 @@
db_regs_t *ddb_regp;
const struct db_command db_machine_command_table[] = {
- { (char *)0, },
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) },
};
static int
Index: arch/mips/mips/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/db_interface.c,v
retrieving revision 1.61
diff -u -r1.61 db_interface.c
--- arch/mips/mips/db_interface.c 28 Feb 2007 04:21:53 -0000 1.61
+++ arch/mips/mips/db_interface.c 18 Jul 2007 07:24:34 -0000
@@ -542,10 +542,10 @@
}
const struct db_command db_machine_command_table[] = {
- { "kvtop", db_kvtophys_cmd, 0, 0 },
- { "tlb", db_tlbdump_cmd, 0, 0 },
- { "cp0", db_cp0dump_cmd, 0, 0 },
- { NULL, }
+ { DDB_ADD_CMD("kvtop", db_kvtophys_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("tlb", db_tlbdump_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("cp0", db_cp0dump_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD(NULL, NULL, 0, NULL,NULL) }
};
#endif /* !KGDB */
Index: arch/powerpc/powerpc/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/db_interface.c,v
retrieving revision 1.37
diff -u -r1.37 db_interface.c
--- arch/powerpc/powerpc/db_interface.c 22 Feb 2007 04:47:07 -0000 1.37
+++ arch/powerpc/powerpc/db_interface.c 18 Jul 2007 07:24:37 -0000
@@ -192,16 +192,16 @@
}
const struct db_command db_machine_command_table[] = {
- { "ctx", db_ppc4xx_ctx, 0, 0 },
- { "pv", db_ppc4xx_pv, 0, 0 },
- { "reset", db_ppc4xx_reset, 0, 0 },
- { "tf", db_ppc4xx_tf, 0, 0 },
- { "tlb", db_ppc4xx_dumptlb, 0, 0 },
- { "dcr", db_ppc4xx_dcr, CS_MORE|CS_SET_DOT, 0 },
+ { DDB_ADD_CMD("ctx", db_ppc4xx_ctx, 0, NULL,NULL) },
+ { DDB_ADD_CMD("pv", db_ppc4xx_pv, 0, NULL,NULL) },
+ { DDB_ADD_CMD("reset", db_ppc4xx_reset, 0, NULL,NULL) },
+ { DDB_ADD_CMD("tf", db_ppc4xx_tf, 0, NULL,NULL) },
+ { DDB_ADD_CMD("tlb", db_ppc4xx_dumptlb, 0, NULL,NULL) },
+ { DDB_ADD_CMD("dcr", db_ppc4xx_dcr, CS_MORE|CS_SET_DOT, NULL,NULL) },
#ifdef USERACC
- { "user", db_ppc4xx_useracc, 0, 0 },
+ { DDB_ADD_CMD("user", db_ppc4xx_useracc, 0, NULL,NULL) },
#endif
- { NULL, }
+ { DDB_ADD_CMD(NULL, NULL, 0, NULL,NULL) }
};
static void
Index: arch/sh3/sh3/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/db_interface.c,v
retrieving revision 1.43
diff -u -r1.43 db_interface.c
--- arch/sh3/sh3/db_interface.c 17 May 2007 22:12:08 -0000 1.43
+++ arch/sh3/sh3/db_interface.c 18 Jul 2007 07:24:39 -0000
@@ -90,13 +90,13 @@
const struct db_command db_machine_command_table[] = {
- { "tlb", db_tlbdump_cmd, 0, NULL },
- { "cache", db_cachedump_cmd, 0, NULL },
- { "frame", db_frame_cmd, 0, NULL },
+ { DDB_ADD_CMD("tlb", db_tlbdump_cmd, 0, NULL, NULL) },
+ { DDB_ADD_CMD("cache", db_cachedump_cmd, 0, NULL, NULL) },
+ { DDB_ADD_CMD("frame", db_frame_cmd, 0, NULL, NULL) },
#ifdef KSTACK_DEBUG
- { "stack", db_stackcheck_cmd, 0, NULL },
+ { DDB_ADD_CMD("stack", db_stackcheck_cmd, 0, NULL, NULL) },
#endif
- { NULL }
+ { DDB_ADD_CMD(NULL, NULL, 0, NULL, NULL) }
};
int db_active;
Index: arch/sparc/sparc/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/db_interface.c,v
retrieving revision 1.71
diff -u -r1.71 db_interface.c
--- arch/sparc/sparc/db_interface.c 22 Feb 2007 16:48:59 -0000 1.71
+++ arch/sparc/sparc/db_interface.c 18 Jul 2007 07:24:40 -0000
@@ -543,17 +543,17 @@
}
const struct db_command db_machine_command_table[] = {
- { "prom", db_prom_cmd, 0, 0 },
- { "proc", db_proc_cmd, 0, 0 },
- { "pcb", db_dump_pcb, 0, 0 },
- { "lock", db_lock_cmd, 0, 0 },
- { "slock", db_simple_lock_cmd, 0, 0 },
- { "page", db_page_cmd, 0, 0 },
- { "uvmdump", db_uvmhistdump, 0, 0 },
+ { DDB_ADD_CMD("prom", db_prom_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("proc", db_proc_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("pcb", db_dump_pcb, 0, NULL,NULL) },
+ { DDB_ADD_CMD("lock", db_lock_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("slock", db_simple_lock_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("page", db_page_cmd, 0, NULL,NULL) },
+ { DDB_ADD_CMD("uvmdump", db_uvmhistdump, 0, NULL,NULL) },
#ifdef MULTIPROCESSOR
- { "cpu", db_cpu_cmd, 0, 0 },
+ { DDB_ADD_CMD("cpu", db_cpu_cmd, 0, NULL,NULL) },
#endif
- { (char *)0, }
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) }
};
#endif /* DDB */
Index: arch/sparc64/sparc64/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/db_interface.c,v
retrieving revision 1.97
diff -u -r1.97 db_interface.c
--- arch/sparc64/sparc64/db_interface.c 17 May 2007 14:51:31 -0000 1.97
+++ arch/sparc64/sparc64/db_interface.c 18 Jul 2007 07:24:45 -0000
@@ -1257,37 +1257,37 @@
#endif
const struct db_command db_machine_command_table[] = {
- { "ctx", db_ctx_cmd, 0, 0 },
- { "dtlb", db_dump_dtlb, 0, 0 },
- { "itlb", db_dump_itlb, 0, 0 },
- { "dtsb", db_dump_dtsb, 0, 0 },
- { "itsb", db_dump_itsb, 0, 0 },
+ { DDB_ADD_CMD("ctx", db_ctx_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("dtlb", db_dump_dtlb, 0, NULL,NULL )},
+ { DDB_ADD_CMD("itlb", db_dump_itlb, 0, NULL,NULL )},
+ { DDB_ADD_CMD("dtsb", db_dump_dtsb, 0, NULL,NULL )},
+ { DDB_ADD_CMD("itsb", db_dump_itsb, 0, NULL,NULL )},
#if NESP_SBUS
- { "esp", db_esp, 0, 0 },
+ { DDB_ADD_CMD("esp", db_esp, 0, NULL,NULL )},
#endif
- { "extract", db_pm_extract, 0, 0 },
- { "fpstate", db_dump_fpstate,0, 0 },
- { "kmap", db_pmap_kernel, 0, 0 },
- { "lock", db_lock_cmd, 0, 0 },
- { "lwp", db_lwp_cmd, 0, 0 },
- { "pcb", db_dump_pcb, 0, 0 },
- { "pctx", db_setpcb, 0, 0 },
- { "page", db_page_cmd, 0, 0 },
- { "phys", db_pload_cmd, 0, 0 },
- { "pmap", db_pmap_cmd, 0, 0 },
- { "proc", db_proc_cmd, 0, 0 },
- { "prom", db_prom_cmd, 0, 0 },
- { "pv", db_dump_pv, 0, 0 },
- { "stack", db_dump_stack, 0, 0 },
- { "tf", db_dump_trap, 0, 0 },
- { "ts", db_dump_ts, 0, 0 },
- { "traptrace", db_traptrace, 0, 0 },
- { "uvmdump", db_uvmhistdump, 0, 0 },
- { "watch", db_watch, 0, 0 },
- { "window", db_dump_window, 0, 0 },
- { "cpu", db_cpu_cmd, 0, 0 },
- { "sir", db_sir_cmd, 0, 0 },
- { .name = NULL, }
+ { DDB_ADD_CMD("extract", db_pm_extract, 0, NULL,NULL )},
+ { DDB_ADD_CMD("fpstate", db_dump_fpstate,0, NULL,NULL )},
+ { DDB_ADD_CMD("kmap", db_pmap_kernel, 0, NULL,NULL )},
+ { DDB_ADD_CMD("lock", db_lock_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("lwp", db_lwp_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("pcb", db_dump_pcb, 0, NULL,NULL )},
+ { DDB_ADD_CMD("pctx", db_setpcb, 0, NULL,NULL )},
+ { DDB_ADD_CMD("page", db_page_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("phys", db_pload_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("pmap", db_pmap_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("proc", db_proc_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("prom", db_prom_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("pv", db_dump_pv, 0, NULL,NULL )},
+ { DDB_ADD_CMD("stack", db_dump_stack, 0, NULL,NULL )},
+ { DDB_ADD_CMD("tf", db_dump_trap, 0, NULL,NULL )},
+ { DDB_ADD_CMD("ts", db_dump_ts, 0, NULL,NULL )},
+ { DDB_ADD_CMD("traptrace", db_traptrace, 0, NULL,NULL )},
+ { DDB_ADD_CMD("uvmdump", db_uvmhistdump, 0, NULL,NULL )},
+ { DDB_ADD_CMD("watch", db_watch, 0, NULL,NULL )},
+ { DDB_ADD_CMD("window", db_dump_window, 0, NULL,NULL )},
+ { DDB_ADD_CMD("cpu", db_cpu_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD("sir", db_sir_cmd, 0, NULL,NULL )},
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) }
};
#endif /* DDB */
Index: arch/sun2/sun2/db_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun2/sun2/db_machdep.c,v
retrieving revision 1.8
diff -u -r1.8 db_machdep.c
--- arch/sun2/sun2/db_machdep.c 4 Mar 2007 09:54:58 -0000 1.8
+++ arch/sun2/sun2/db_machdep.c 18 Jul 2007 07:24:47 -0000
@@ -65,11 +65,11 @@
static void db_mach_pagemap(db_expr_t, bool, db_expr_t, const char *);
const struct db_command db_machine_command_table[] = {
- { "abort", db_mach_abort, 0, 0 },
- { "halt", db_mach_halt, 0, 0 },
- { "pgmap", db_mach_pagemap, CS_SET_DOT, 0 },
- { "reboot", db_mach_reboot, 0, 0 },
- { (char *)0, }
+ { DDB_ADD_CMD("abort", db_mach_abort, 0, NULL,NULL) },
+ { DDB_ADD_CMD("halt", db_mach_halt, 0, NULL,NULL) },
+ { DDB_ADD_CMD("pgmap", db_mach_pagemap, CS_SET_DOT, NULL,NULL) },
+ { DDB_ADD_CMD("reboot", db_mach_reboot, 0, NULL,NULL) },
+ { DDB_ADD_CMD( NULL,NULL,0,NULL,NULL) }
};
/*
Index: arch/sun3/sun3/db_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3/db_machdep.c,v
retrieving revision 1.23
diff -u -r1.23 db_machdep.c
--- arch/sun3/sun3/db_machdep.c 22 Feb 2007 14:39:34 -0000 1.23
+++ arch/sun3/sun3/db_machdep.c 18 Jul 2007 07:24:47 -0000
@@ -64,11 +64,11 @@
static void db_mach_pagemap(db_expr_t, bool, db_expr_t, const char *);
const struct db_command db_machine_command_table[] = {
- { "abort", db_mach_abort, 0, NULL },
- { "halt", db_mach_halt, 0, NULL },
- { "pgmap", db_mach_pagemap, CS_SET_DOT, NULL },
- { "reboot", db_mach_reboot, 0, NULL },
- { NULL }
+ { DDB_ADD_CMD("abort", db_mach_abort, 0, NULL,NULL) },
+ { DDB_ADD_CMD("halt", db_mach_halt, 0, NULL,NULL) },
+ { DDB_ADD_CMD("pgmap", db_mach_pagemap, CS_SET_DOT, NULL,NULL) },
+ { DDB_ADD_CMD("reboot", db_mach_reboot, 0, NULL,NULL) },
+ { DDB_ADD_CMD(NULL,NULL,0,NULL,NULL)}
};
/*
Index: arch/vax/vax/db_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/db_machdep.c,v
retrieving revision 1.46
diff -u -r1.46 db_machdep.c
--- arch/vax/vax/db_machdep.c 4 Mar 2007 06:00:58 -0000 1.46
+++ arch/vax/vax/db_machdep.c 18 Jul 2007 07:24:50 -0000
@@ -658,7 +658,7 @@
const struct db_command db_machine_command_table[] = {
#ifdef MULTIPROCESSOR
- { "cpu", db_mach_cpu, 0, 0 },
+ { DDB_ADD_CMD("cpu", db_mach_cpu, 0, NULL,NULL) },
#endif
- { NULL },
+ { DDB_ADD_CMD(NULL,NULL,0,NULL,NULL)},
};
Index: ddb/db_command.c
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_command.c,v
retrieving revision 1.96
diff -u -r1.96 db_command.c
--- ddb/db_command.c 30 Apr 2007 14:44:30 -0000 1.96
+++ ddb/db_command.c 18 Jul 2007 07:24:53 -0000
@@ -1,4 +1,39 @@
/* $NetBSD: db_command.c,v 1.96 2007/04/30 14:44:30 rmind Exp $ */
+/*
+ * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Adam Hamsik.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/*
* Mach Operating System
@@ -51,6 +86,9 @@
#include <sys/lockdebug.h>
#include <sys/sleepq.h>
+/*include queue macros*/
+#include <sys/queue.h>
+
#include <machine/db_machdep.h> /* type definitions */
#if defined(_KERNEL_OPT)
@@ -70,6 +108,7 @@
#include <ddb/db_interface.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
+#include <ddb/db_command_list.h>
#include <uvm/uvm_extern.h>
#include <uvm/uvm_ddb.h>
@@ -83,7 +122,23 @@
#define CMD_FOUND 1
#define CMD_NONE 2
#define CMD_AMBIGUOUS 3
-#define CMD_HELP 4
+
+#define CMD_SWITCH(result) do { \
+ switch (result) { \
+ case CMD_NONE: \
+ db_printf("No such command\n"); \
+ db_flush_lex(); \
+ return; \
+ case CMD_AMBIGUOUS: \
+ db_printf("Ambiguous\n"); \
+ db_flush_lex(); \
+ return; \
+ default: \
+ break; \
+ } \
+ } while(/* CONSTCOND */ 0)
+
+
/*
* Exported global variables
@@ -95,6 +150,23 @@
db_addr_t db_prev;
db_addr_t db_next;
+
+/*
+ New DDB api for adding and removing commands uses two lists, because
+ we use two types of commands
+ a) standard commands without subcommands -> reboot
+ b) show commands which are subcommands of show command -> show aio_jobs
+
+ ddb_add_cmd, ddb_rem_cmd use type (DDB_SHOW_CMD||DDB_BASE_CMD)argument to add them
+ to representativ lists.
+*/
+
+/*head of base commands list*/
+static struct db_cmd_tbl_en_head db_base_cmd_list=TAILQ_HEAD_INITIALIZER(db_base_cmd_list);
+
+/*head of show commands list*/
+static struct db_cmd_tbl_en_head db_show_cmd_list=TAILQ_HEAD_INITIALIZER(db_show_cmd_list);
+
/*
* if 'ed' style: 'dot' is set at start of last item printed,
* and '+' points to next line.
@@ -102,14 +174,19 @@
*/
static bool db_ed_style = true;
-static void db_buf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-static void db_cmd_list(const struct db_command *);
+static void db_cmd_list(const struct db_cmd_tbl_en_head *);
static int db_cmd_search(const char *, const struct db_command *,
- const struct db_command **);
-static void db_command(const struct db_command **,
- const struct db_command *);
+ const struct db_command **);
+static void db_command(const struct db_command **);
+static void db_buf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_event_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_fncall(db_expr_t, bool, db_expr_t, const char *);
+static int db_get_list_type(const char *);
+static void db_help_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_init_commands(void);
+static void db_lock_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_mount_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_mbuf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_malloc_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_map_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_namecache_print_cmd(db_expr_t, bool, db_expr_t, const char *);
@@ -122,47 +199,57 @@
static void db_stack_trace_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_sync_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_uvmexp_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_ui_compat_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_vnode_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-static void db_lock_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-static void db_mount_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-static void db_mbuf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-/*
- * 'show' commands
- */
-
-static const struct db_command db_show_all_cmds[] = {
- { "callout", db_show_callout, 0, NULL },
- { "pages", db_show_all_pages, 0, NULL },
- { "procs", db_show_all_procs, 0, NULL },
- { "pools", db_show_all_pools, 0, NULL },
- { NULL, NULL, 0, NULL }
-};
static const struct db_command db_show_cmds[] = {
- { "aio_jobs", db_show_aio_jobs, 0, NULL },
- { "all", NULL, 0, db_show_all_cmds },
+ /*added from all sub cmds*/
+ { DDB_ADD_CMD("callout", db_show_callout, 0,NULL,NULL) },
+ { DDB_ADD_CMD("pages", db_show_all_pages, 0,NULL,NULL) },
+ { DDB_ADD_CMD("procs", db_show_all_procs, 0,NULL,NULL) },
+ { DDB_ADD_CMD("pools", db_show_all_pools, 0,NULL,NULL) },
+ /*added from all sub cmds*/
+ { DDB_ADD_CMD("aio_jobs", db_show_aio_jobs, 0,"Show aio jobs",
+ NULL) },
+ { DDB_ADD_CMD("all", db_ui_compat_cmd, CS_OWN, NULL, NULL) },
#if defined(INET) && (NARP > 0)
- { "arptab", db_show_arptab, 0, NULL },
+ { DDB_ADD_CMD("arptab", db_show_arptab, 0,NULL,NULL) },
#endif
- { "breaks", db_listbreak_cmd, 0, NULL },
- { "buf", db_buf_print_cmd, 0, NULL },
- { "event", db_event_print_cmd, 0, NULL },
- { "lock", db_lock_print_cmd, 0, NULL },
- { "malloc", db_malloc_print_cmd, 0, NULL },
- { "map", db_map_print_cmd, 0, NULL },
- { "mount", db_mount_print_cmd, 0, NULL },
- { "mbuf", db_mbuf_print_cmd, 0, NULL },
- { "ncache", db_namecache_print_cmd, 0, NULL },
- { "object", db_object_print_cmd, 0, NULL },
- { "page", db_page_print_cmd, 0, NULL },
- { "pool", db_pool_print_cmd, 0, NULL },
- { "registers", db_show_regs, 0, NULL },
- { "sched_qs", db_show_sched_qs, 0, NULL },
- { "uvmexp", db_uvmexp_print_cmd, 0, NULL },
- { "vnode", db_vnode_print_cmd, 0, NULL },
- { "watches", db_listwatch_cmd, 0, NULL },
- { NULL, NULL, 0, NULL }
+ { DDB_ADD_CMD("breaks", db_listbreak_cmd, 0,"Display all breaks.",
+ NULL) },
+ { DDB_ADD_CMD("buf", db_buf_print_cmd, 0,
+ "Print the struct buf at address.", "[/f] address") },
+ { DDB_ADD_CMD("event", db_event_print_cmd, 0,
+ "Print all the non-zero evcnt(9) event counters.", "[/f]") },
+ { DDB_ADD_CMD("lock", db_lock_print_cmd, 0,NULL,NULL) },
+ { DDB_ADD_CMD("malloc", db_malloc_print_cmd,0,NULL,NULL) },
+ { DDB_ADD_CMD("map", db_map_print_cmd, 0,
+ "Print the vm_map at address.", "[/f] address") },
+ { DDB_ADD_CMD("mount", db_mount_print_cmd, 0,
+ "Print the mount structure at address.", "[/f] address") },
+ { DDB_ADD_CMD("mbuf", db_mbuf_print_cmd, 0,NULL,NULL) },
+ { DDB_ADD_CMD("ncache", db_namecache_print_cmd, 0,
+ "Dump the namecache list.", "address") },
+ { DDB_ADD_CMD("object", db_object_print_cmd, 0,
+ "Print the vm_object at address.", "[/f] address") },
+ { DDB_ADD_CMD("page", db_page_print_cmd, 0,
+ "Print the vm_page at address.", "[/f] address") },
+ { DDB_ADD_CMD("pool", db_pool_print_cmd, 0,
+ "Print the pool at address.", "[/clp] address") },
+ { DDB_ADD_CMD("registers", db_show_regs, 0,
+ "Display the register set.", "[/u]") },
+ { DDB_ADD_CMD("sched_qs", db_show_sched_qs, 0,
+ "Print the state of the scheduler's run queues.",
+ NULL) },
+ { DDB_ADD_CMD("uvmexp", db_uvmexp_print_cmd, 0,
+ "Print a selection of UVM counters and statistics.",
+ NULL) },
+ { DDB_ADD_CMD("vnode", db_vnode_print_cmd, 0,
+ "Print the vnode at address.", "[/f] address") },
+ { DDB_ADD_CMD("watches", db_listwatch_cmd, 0,
+ "Display all watchpoints.", NULL) },
+ { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL) }
};
/* arch/<arch>/<arch>/db_interface.c */
@@ -171,45 +258,83 @@
#endif
static const struct db_command db_command_table[] = {
- { "b", db_breakpoint_cmd, 0, NULL },
- { "break", db_breakpoint_cmd, 0, NULL },
- { "bt", db_stack_trace_cmd, 0, NULL },
- { "c", db_continue_cmd, 0, NULL },
- { "call", db_fncall, CS_OWN, NULL },
- { "callout", db_show_callout, 0, NULL },
- { "continue", db_continue_cmd, 0, NULL },
- { "d", db_delete_cmd, 0, NULL },
- { "delete", db_delete_cmd, 0, NULL },
- { "dmesg", db_dmesg, 0, NULL },
- { "dwatch", db_deletewatch_cmd, 0, NULL },
- { "examine", db_examine_cmd, CS_SET_DOT, NULL },
- { "kill", db_kill_proc, CS_OWN, NULL },
+ { DDB_ADD_CMD("b", db_breakpoint_cmd, 0,
+ "Set a breakpoint at address", "[/u] address[,count].") },
+ { DDB_ADD_CMD("break", db_breakpoint_cmd, 0,
+ "Set a breakpoint at address", "[/u] address[,count].") },
+ { DDB_ADD_CMD("bt", db_stack_trace_cmd, 0,
+ "Show backtrace.", "See help trace.") },
+ { DDB_ADD_CMD("c", db_continue_cmd, 0,"Continue execution.", "[/c]") },
+ { DDB_ADD_CMD("call", db_fncall, CS_OWN,
+ "Call the function", "address[(expression[,...])]") },
+ { DDB_ADD_CMD("callout", db_show_callout, 0, NULL,
+ NULL) },
+ { DDB_ADD_CMD("continue", db_continue_cmd, 0,
+ "Continue execution.", "[/c]") },
+ { DDB_ADD_CMD("d", db_delete_cmd, 0,
+ "Delete a breakpoint.", "address | #number") },
+ { DDB_ADD_CMD("delete", db_delete_cmd, 0,
+ "Delete a breakpoint.", "address | #number") },
+ { DDB_ADD_CMD("dmesg", db_dmesg, 0,
+ "Show kernel message buffer.", "[count]") },
+ { DDB_ADD_CMD("dwatch", db_deletewatch_cmd, 0,
+ "Delete the watchpoint.", "address") },
+ { DDB_ADD_CMD("examine", db_examine_cmd, CS_SET_DOT,
+ "Display the address locations.",
+ "[/modifier] address[,count]") },
+ { DDB_ADD_CMD("help", db_help_print_cmd, CS_OWN,
+ "Display help about commands",
+ "Use other commands as arguments.") },
+ { DDB_ADD_CMD("kill", db_kill_proc, CS_OWN,
+ "Send a signal to the process","pid[,signal_number]") },
#ifdef KGDB
- { "kgdb", db_kgdb_cmd, 0, NULL },
-#endif
-#ifdef DB_MACHINE_COMMANDS
- { "machine", NULL, 0, db_machine_command_table },
+ { DDB_ADD_CMD("kgdb", db_kgdb_cmd, 0, NULL) },
#endif
- { "match", db_trace_until_matching_cmd,0, NULL },
- { "next", db_trace_until_matching_cmd,0, NULL },
- { "p", db_print_cmd, 0, NULL },
- { "print", db_print_cmd, 0, NULL },
- { "ps", db_show_all_procs, 0, NULL },
- { "reboot", db_reboot_cmd, CS_OWN, NULL },
- { "s", db_single_step_cmd, 0, NULL },
- { "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL },
- { "set", db_set_cmd, CS_OWN, NULL },
- { "show", NULL, 0, db_show_cmds },
- { "sifting", db_sifting_cmd, CS_OWN, NULL },
- { "step", db_single_step_cmd, 0, NULL },
- { "sync", db_sync_cmd, CS_OWN, NULL },
- { "trace", db_stack_trace_cmd, 0, NULL },
- { "until", db_trace_until_call_cmd,0, NULL },
- { "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
- { "watch", db_watchpoint_cmd, CS_MORE, NULL },
- { "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
- { "x", db_examine_cmd, CS_SET_DOT, NULL },
- { NULL, NULL, 0, NULL }
+ { DDB_ADD_CMD("match", db_trace_until_matching_cmd,0,
+ "Stop at the matching return instruction.","See help next") },
+ { DDB_ADD_CMD("next", db_trace_until_matching_cmd,0,
+ "Stop at the matching return instruction.","[/p]") },
+ { DDB_ADD_CMD("p", db_print_cmd, 0,
+ "Print address according to the format.",
+ "[/axzodurc] address [address ...]") },
+ { DDB_ADD_CMD("print", db_print_cmd, 0,
+ "Print address according to the format.",
+ "[/axzodurc] address [address ...]") },
+ { DDB_ADD_CMD("ps", db_show_all_procs, 0,
+ "Print all processes.","See show all procs") },
+ { DDB_ADD_CMD("reboot", db_reboot_cmd, CS_OWN,
+ "Reboot","0x1 RB_ASKNAME, 0x2 RB_SINGLE, 0x4 RB_NOSYNC, 0x8 RB_HALT,"
+ "0x40 RB_KDB, 0x100 RB_DUMP, 0x808 RB_POWERDOWN") },
+ { DDB_ADD_CMD("s", db_single_step_cmd, 0,
+ "Single-step count times.","[/p] [,count]") },
+ { DDB_ADD_CMD("search", db_search_cmd, CS_OWN|CS_SET_DOT,
+ "Search memory from address for value.",
+ "[/bhl] address value [mask] [,count]") },
+ { DDB_ADD_CMD("set", db_set_cmd, CS_OWN,
+ "Set the named variable","$variable [=] expression") },
+ { DDB_ADD_CMD("show", NULL, 0,"Show kernel stats.", NULL) },
+ { DDB_ADD_CMD("sifting", db_sifting_cmd, CS_OWN,
+ "Search the symbol tables ","[/F] string") },
+ { DDB_ADD_CMD("step", db_single_step_cmd, 0,
+ "Single-step count times.","[/p] [,count]") },
+ { DDB_ADD_CMD("sync", db_sync_cmd, CS_OWN,
+ "Force a crash dump, and then reboot.",NULL) },
+ { DDB_ADD_CMD("trace", db_stack_trace_cmd, 0,
+ "Stack trace from frame-address.",
+ "[/u[l]] [frame-address][,count]") },
+ { DDB_ADD_CMD("until", db_trace_until_call_cmd,0,
+ "Stop at the next call or return instruction.","[/p]") },
+ { DDB_ADD_CMD("w", db_write_cmd, CS_MORE|CS_SET_DOT,
+ "Set a watchpoint for a region. ","address[,size]") },
+ { DDB_ADD_CMD("watch", db_watchpoint_cmd, CS_MORE,
+ "Set a watchpoint for a region. ","address[,size]") },
+ { DDB_ADD_CMD("write", db_write_cmd, CS_MORE|CS_SET_DOT,
+ "Write the expressions at succeeding locations.",
+ "[/bhl] address expression [expression ...]") },
+ { DDB_ADD_CMD("x", db_examine_cmd, CS_SET_DOT,
+ "Display the address locations.",
+ "[/modifier] address[,count]") },
+ { DDB_ADD_CMD(NULL, NULL, 0, NULL, NULL) }
};
static const struct db_command *db_last_command = NULL;
@@ -224,474 +349,864 @@
* Utility routine - discard tokens through end-of-line.
*/
void
-db_skip_to_eol(void)
-{
- int t;
-
- do {
+db_skip_to_eol(void){
+
+ int t;
+ do {
t = db_read_token();
} while (t != tEOL);
}
void
-db_error(const char *s)
-{
+db_error(const char *s){
- if (s)
+ if (s)
db_printf("%s", s);
- db_flush_lex();
- longjmp(db_recover);
+ db_flush_lex();
+ longjmp(db_recover);
}
+/*Execute commandlist after ddb start*/
static void
-db_execute_commandlist(const char *cmdlist)
-{
- const char *cmd = cmdlist;
- const struct db_command *dummy = NULL;
+db_execute_commandlist(const char *cmdlist){
+
+ const char *cmd = cmdlist;
+ const struct db_command *dummy = NULL;
- while (*cmd != '\0') {
+ while (*cmd != '\0') {
const char *ep = cmd;
- while (*ep != '\0' && *ep != DB_LINE_SEP) {
- ep++;
- }
- db_set_line(cmd, ep);
- db_command(&dummy, db_command_table);
- cmd = ep;
- if (*cmd == DB_LINE_SEP) {
- cmd++;
+ while (*ep != '\0' && *ep != DB_LINE_SEP) {
+ ep++;
}
- }
+ db_set_line(cmd, ep);
+ db_command(&dummy);
+ cmd = ep;
+ if (*cmd == DB_LINE_SEP) {
+ cmd++;
+ }
+ }
}
-void
-db_command_loop(void)
-{
- label_t db_jmpbuf;
- label_t *savejmp;
+/*Initialize ddb command tables*/
+static void
+db_init_commands(void){
+ struct db_cmd_tbl_en *list_ent;
+
+
+/* TAILQ_INIT(&db_base_cmd_list);
+ TAILQ_INIT(&db_show_cmd_list);*/
+
+ TAILQ_FOREACH(list_ent,&db_base_cmd_list,db_cmd_next)
+ if (list_ent->db_cmd == db_command_table)
+ return;
+
+ TAILQ_FOREACH(list_ent,&db_show_cmd_list,db_cmd_next)
+ if (list_ent->db_cmd == db_show_cmds)
+ return;
+
+ printf("Initialize command tables\n");
+
+ (void)db_add_command_tbl(DDB_BASE_CMD,db_command_table);
+ (void)db_add_command_tbl(DDB_BASE_CMD,db_machine_command_table);
+
+ (void)db_add_command_tbl(DDB_SHOW_CMD,db_show_cmds);
+
+
+ /* (void)db_rem_command_tbl(DDB_BASE_CMD,db_command_table);
+ (void)db_rem_command_tbl(DDB_SHOW_CMD,db_show_cmds);*/
+ return;
+}
+
+
+/*
+ * Add command table to the specified list
+ * Arg:
+ * int type specifies type of command DDB_SHOW_CMD|DDB_BASE_CMD
+ * *cmd_tbl poiter to static allocated db_command table
+ *
+ *Command talbe have to be NULL terminated array of struct db_command
+ */
+int
+db_add_command_tbl(uint8_t type, const struct db_command *cmd_tbl){
+ /*XXX what is better count number of elements here or use num argument ?*/
+ uint32_t i=0;
+ struct db_cmd_tbl_en *list_ent;
+ const struct db_command *cmd;
+ /*I have to check this because e.g. machine commands can be NULL*/
+ if (cmd_tbl->name != 0) {
+
+ if ((list_ent = malloc (sizeof(struct db_cmd_tbl_en),M_TEMP,M_ZERO))
+ == NULL)
+ return (ENOMEM);
+
+ list_ent->db_cmd=cmd_tbl;
+
+
+ for (cmd = cmd_tbl; cmd->name != 0; cmd++)
+ i++;
+
+ list_ent->db_cmd_num=i;
+ printf("Number of elements :%d \n",i);
+
+ /*Type specify list*/
+ if (type == DDB_BASE_CMD){
+ printf("Adding base cmds\n");
+ if (TAILQ_EMPTY(&db_base_cmd_list))
+ /*If head is empty we add first table here*/
+ TAILQ_INSERT_HEAD(&db_base_cmd_list,
+ list_ent,db_cmd_next);
+
+ else
+ /*new commands go to the end*/
+ TAILQ_INSERT_TAIL(&db_base_cmd_list,
+ list_ent,db_cmd_next);
+
+ } else if (type == DDB_SHOW_CMD){
+ printf("Adding Show cmds\n");
+
+ if (TAILQ_EMPTY(&db_show_cmd_list))
+ /*If head is empty we add first table here*/
+ TAILQ_INSERT_HEAD(&db_show_cmd_list,
+ list_ent,db_cmd_next);
+
+ else
+ /*new commands go to the end*/
+ TAILQ_INSERT_TAIL(&db_show_cmd_list,
+ list_ent,db_cmd_next);
+
+
+ } else
+ return (ENOENT);
+ }
+ return 0;
+}
+/*
+ *Remove command table specified with db_cmd address == cmd_tbl
+ */
+int
+db_rem_command_tbl(uint8_t type,const struct db_command *cmd_tbl){
- /*
- * Initialize 'prev' and 'next' to dot.
- */
- db_prev = db_dot;
- db_next = db_dot;
+ struct db_cmd_tbl_en *list_ent;
+ int error=ENOENT;
+
+ if (db_base_cmd_list.tqh_first == NULL)
+ return (error);
+ printf("Removing command table\n");
+
+ /*I go through the list, selected with type and look for
+ cmd_tbl address in list entries.*/
+ if (type == DDB_BASE_CMD){
+
+ TAILQ_FOREACH(list_ent,&db_base_cmd_list,db_cmd_next){
+ if (list_ent->db_cmd == cmd_tbl){
+ /*first I need to remove command table from
+ TAILQ list and then I can freed it*/
+ TAILQ_REMOVE(&db_base_cmd_list,
+ list_ent,db_cmd_next);
+ free(list_ent,M_TEMP);
+ error=0;/*I succefully find address so I return 0*/
+ }
+ }
- db_cmd_loop_done = 0;
+ }else if (type == DDB_SHOW_CMD){
- savejmp = db_recover;
- db_recover = &db_jmpbuf;
- (void) setjmp(&db_jmpbuf);
+ TAILQ_FOREACH(list_ent,&db_show_cmd_list,db_cmd_next){
+ if (list_ent->db_cmd == cmd_tbl){
+ TAILQ_REMOVE(&db_show_cmd_list,
+ list_ent,db_cmd_next);
+ free(list_ent,M_TEMP);
+ error=0;
+ }
+ }
- db_execute_commandlist(db_cmd_on_enter);
+ } else
+ error=EINVAL;
- while (!db_cmd_loop_done) {
- if (db_print_position() != 0)
- db_printf("\n");
- db_output_line = 0;
+ return (error);
+}
+
+
+void
+db_command_loop(void){
+
+ label_t db_jmpbuf;
+ label_t *savejmp;
+
+ /*
+ * Initialize 'prev' and 'next' to dot.
+ */
+ db_prev = db_dot;
+ db_next = db_dot;
+
+ db_cmd_loop_done = 0;
+
+ /*save context for return from ddb*/
+ savejmp = db_recover;
+ db_recover = &db_jmpbuf;
+ (void) setjmp(&db_jmpbuf);
+
+ /*Init default command tables add machine, base,
+ show command tables to the list*/
+ (void) db_init_commands();
+
+ /*Execute default ddb start commands*/
+ db_execute_commandlist(db_cmd_on_enter);
+
+ while (!db_cmd_loop_done) {
+ if (db_print_position() != 0)
+ db_printf("\n");
+ db_output_line = 0;
#ifdef MULTIPROCESSOR
- db_printf("db{%ld}> ", (long)cpu_number());
+ db_printf("db{%ld}> ", (long)cpu_number());
#else
- db_printf("db> ");
+ db_printf("db> ");
#endif
- (void) db_read_line();
+ (void) db_read_line();
- db_command(&db_last_command, db_command_table);
- }
+ db_command(&db_last_command);
+ }
- db_recover = savejmp;
+ db_recover = savejmp;
}
/*
- * Search for command prefix.
+ * Search for command table for command prefix
+ * ret: CMD_UNIQUE -> completly match cmd prefix
+ * CMD_FOUND -> partialy match cmd prefix
+ * CMD_AMBIGIOUS ->more partialy matches
+ * CMD_NONE -> command not found
*/
static int
-db_cmd_search(const char *name, const struct db_command *table,
- const struct db_command **cmdp)
-{
- const struct db_command *cmd;
- int result = CMD_NONE;
+db_cmd_search(const char *name,const struct db_command *table,
+ const struct db_command **cmdp){
+
+ const struct db_command *cmd;
+ int result = CMD_NONE;
+
+ for (cmd = table; cmd->name != 0; cmd++) {
+ const char *lp;
+ const char *rp;
+ int c;
+
+ lp = name;
+ rp = cmd->name;
+ while ((c = *lp) == *rp) {
+ if (c == 0) {
+ /* complete match */
+ *cmdp = cmd;
+ return (CMD_UNIQUE);
+ }
+ lp++;
+ rp++;
+ }
+ if (c == 0) {
+ /* end of name, not end of command -
+ partial match */
+ if (result == CMD_FOUND) {
+ result = CMD_AMBIGUOUS;
+ /* but keep looking for a full match -
+ this lets us match single letters */
+ } else {
+ *cmdp = cmd;
+ result = CMD_FOUND;
+ }
+ }
+ }
+ return (result);
+}
- for (cmd = table; cmd->name != 0; cmd++) {
- const char *lp;
- const char *rp;
- int c;
-
- lp = name;
- rp = cmd->name;
- while ((c = *lp) == *rp) {
- if (c == 0) {
- /* complete match */
- *cmdp = cmd;
- return (CMD_UNIQUE);
- }
- lp++;
- rp++;
- }
- if (c == 0) {
- /* end of name, not end of command -
- partial match */
- if (result == CMD_FOUND) {
- result = CMD_AMBIGUOUS;
- /* but keep looking for a full match -
- this lets us match single letters */
- } else {
- *cmdp = cmd;
- result = CMD_FOUND;
- }
- }
- }
- if (result == CMD_NONE) {
- /* check for 'help' */
- if (name[0] == 'h' && name[1] == 'e'
- && name[2] == 'l' && name[3] == 'p')
- result = CMD_HELP;
- }
- return (result);
-}
-
-static void
-db_cmd_list(const struct db_command *table)
-{
- int i, j, w, columns, lines, width=0, numcmds;
- const char *p;
-
- for (numcmds = 0; table[numcmds].name != NULL; numcmds++) {
- w = strlen(table[numcmds].name);
- if (w > width)
- width = w;
- }
- width = DB_NEXT_TAB(width);
-
- columns = db_max_width / width;
- if (columns == 0)
- columns = 1;
- lines = (numcmds + columns - 1) / columns;
- for (i = 0; i < lines; i++) {
- for (j = 0; j < columns; j++) {
- p = table[j * lines + i].name;
- if (p)
- db_printf("%s", p);
- if (j * lines + i + lines >= numcmds) {
- db_putchar('\n');
- break;
- }
- if (p) {
- w = strlen(p);
- while (w < width) {
- w = DB_NEXT_TAB(w);
- db_putchar('\t');
- }
- }
- }
- }
-}
-
-static void
-db_command(const struct db_command **last_cmdp,
- const struct db_command *cmd_table)
-{
- const struct db_command *cmd;
- int t;
- char modif[TOK_STRING_SIZE];
- db_expr_t addr, count;
- bool have_addr = false;
- int result;
- static db_expr_t last_count = 0;
+static void
+db_cmd_list(const struct db_cmd_tbl_en_head *list){
- cmd = NULL; /* XXX gcc */
+ struct db_cmd_tbl_en *list_ent;
+ const struct db_command *table;
+ int i, j, w, columns, lines, width=0, numcmds=0;
+ const char *p;
- t = db_read_token();
- if ((t == tEOL) || (t == tCOMMA)) {
- /*
- * An empty line repeats last command, at 'next'.
- * Only a count repeats the last command with the new count.
- */
- cmd = *last_cmdp;
- addr = (db_expr_t)db_next;
- if (t == tCOMMA) {
- if (!db_expression(&count)) {
- db_printf("Count missing\n");
- db_flush_lex();
- return;
- }
- } else
- count = last_count;
- have_addr = false;
- modif[0] = '\0';
- db_skip_to_eol();
- } else if (t == tEXCL) {
- db_fncall(0, 0, 0, NULL);
- return;
- } else if (t != tIDENT) {
- db_printf("?\n");
- db_flush_lex();
+ TAILQ_FOREACH(list_ent,list,db_cmd_next){
+ numcmds+=list_ent->db_cmd_num;
+ table=list_ent->db_cmd;
+
+ for (i = 0; i<list_ent->db_cmd_num; i++) {
+ w = strlen(table[i].name);
+ if (w > width)
+ width = w;
+ }
+ }
+
+ width = DB_NEXT_TAB(width);
+
+ columns = db_max_width / width;
+ if (columns == 0)
+ columns = 1;
+
+
+ TAILQ_FOREACH(list_ent,list,db_cmd_next){
+ table=list_ent->db_cmd;
+
+ lines = (list_ent->db_cmd_num + columns - 1) / columns;
+
+ for (i = 0; i < lines; i++) {
+ for (j = 0; j < columns; j++) {
+ p = table[j * lines + i].name;
+ if (p)
+ db_printf("%s", p);
+ if (j * lines + i + lines >= list_ent->db_cmd_num){
+ db_putchar('\n');
+ break;
+ }
+ if (p) {
+ w = strlen(p);
+ while (w < width) {
+ w = DB_NEXT_TAB(w);
+ db_putchar('\t');
+ }
+ }
+ }
+ }
+ }
return;
- } else {
- /*
- * Search for command
- */
- while (cmd_table) {
- result = db_cmd_search(db_tok_string, cmd_table, &cmd);
- switch (result) {
- case CMD_NONE:
- db_printf("No such command\n");
- db_flush_lex();
+}
+
+static int
+db_get_list_type(const char *name){
+
+ const struct db_command *cmd;
+ struct db_cmd_tbl_en *list_ent;
+ int error,ret=-1;
+
+ /*I go through base cmd list and search command with name(form cmd line)*/
+ TAILQ_FOREACH(list_ent,&db_base_cmd_list,db_cmd_next){
+ /*cmd_search returns CMD_UNIQUE, CMD_FOUND ...
+ *CMD_UNIQUE when name was completly matched to cmd->name
+ *CMD_FOUND when name was only partially matched to cmd->name
+ *CMD_NONE command not found in a list
+ *CMD_AMBIGIOUS ->more partialy matches
+ */
+
+ error=db_cmd_search(name,list_ent->db_cmd,&cmd);
+ /*because I can't have better result then CMD_UNIQUE I break*/
+ if (error == CMD_UNIQUE){
+ if (strncmp(cmd->name,"show",4) == 0){
+ ret=DDB_SHOW_CMD;
+ break;
+ } else {
+ ret=DDB_BASE_CMD;
+ break;
+ }
+ /*I have only partially matched name so I continue search*/
+ } else if (error == CMD_FOUND){
+ if (strncmp(cmd->name,"show",4) == 0)
+ ret=DDB_SHOW_CMD;
+ else
+ ret=DDB_BASE_CMD;
+ }
+ }
+
+ return(ret);
+}
+
+/*
+ *Parse command line and execute apropriate function.
+ */
+static void
+db_command(const struct db_command **last_cmdp){
+ const struct db_command *command;
+ struct db_cmd_tbl_en *list_ent;
+ struct db_cmd_tbl_en_head *list;
+
+ int t;
+ char modif[TOK_STRING_SIZE];
+ db_expr_t addr, count;
+ bool have_addr = false;
+ int result;
+ static db_expr_t last_count = 0;
+
+ command = NULL; /* XXX gcc */
+
+ t = db_read_token();
+ if ((t == tEOL) || (t == tCOMMA)) {
+ /*
+ * An empty line repeats last command, at 'next'.
+ * Only a count repeats the last command with the new count.
+ */
+ command = *last_cmdp;
+ addr = (db_expr_t)db_next;
+ if (t == tCOMMA) {
+ if (!db_expression(&count)) {
+ db_printf("Count missing\n");
+ db_flush_lex();
+ return;
+ }
+ } else
+ count = last_count;
+ have_addr = false;
+ modif[0] = '\0';
+ db_skip_to_eol();
+
+ } else if (t == tEXCL) {
+ db_fncall(0, 0, 0, NULL);
return;
- case CMD_AMBIGUOUS:
- db_printf("Ambiguous\n");
+
+ } else if (t != tIDENT) {
+ db_printf("?\n");
db_flush_lex();
return;
- case CMD_HELP:
- db_cmd_list(cmd_table);
- db_flush_lex();
+
+ } else {
+
+ switch(db_get_list_type(db_tok_string)){
+
+ case DDB_BASE_CMD:
+ list=&db_base_cmd_list;
+ break;
+ case DDB_SHOW_CMD:
+ list=&db_show_cmd_list;
+ /*I need to read show subcommand If show command list is used.*/
+ t = db_read_token();
+
+ if (t != tIDENT) {
+ /*if only show command is executed I print all subcommands*/
+ db_cmd_list(&db_show_cmd_list);
+ db_flush_lex();
+ return;
+ }
+
+ break;
+ default:
+ db_printf("No such command\n");
+ db_flush_lex();
+ return;
+ }
+
+
+ TAILQ_FOREACH(list_ent,list,db_cmd_next){
+ result = db_cmd_search(db_tok_string, list_ent->db_cmd, &command);
+ /*after CMD_UNIQUE in cmd_list only one same command name is possible*/
+ if (result == CMD_UNIQUE)
+ break;
+ }
+
+ if ((command->flag & CS_OWN) == 0) {
+
+ /*
+ * Standard syntax:
+ * command [/modifier] [addr] [,count]
+ */
+ t = db_read_token(); /*get modifier*/
+ if (t == tSLASH) {
+ t = db_read_token();
+ if (t != tIDENT) {
+ db_printf("Bad modifier\n");
+ db_flush_lex();
+ return;
+ }
+ strlcpy(modif, db_tok_string, sizeof(modif)); /*save modifier*/
+
+ } else {
+ db_unread_token(t);
+ modif[0] = '\0';
+ }
+
+ if (db_expression(&addr)) { /*get address*/
+ db_dot = (db_addr_t) addr;
+ db_last_addr = db_dot;
+ have_addr = true;
+ } else {
+ addr = (db_expr_t) db_dot;
+ have_addr = false;
+ }
+
+ t = db_read_token();
+ if (t == tCOMMA) { /*Get count*/
+ if (!db_expression(&count)) {
+ db_printf("Count missing\n");
+ db_flush_lex();
+ return;
+ }
+ } else {
+ db_unread_token(t);
+ count = -1;
+ }
+ if ((command->flag & CS_MORE) == 0) {
+ db_skip_to_eol();
+ }
+ }
+ }
+
+ *last_cmdp = command;
+ last_count = count;
+
+ if (command != 0) {
+ /*
+ * Execute the command.
+ */
+ (*command->fcn)(addr, have_addr, count, modif);
+
+ if (command->flag & CS_SET_DOT) {
+ /*
+ * If command changes dot, set dot to
+ * previous address displayed (if 'ed' style).
+ */
+ if (db_ed_style)
+ db_dot = db_prev;
+ else
+ db_dot = db_next;
+ } else {
+ /*
+ * If command does not change dot,
+ * set 'next' location to be the same.
+ */
+ db_next = db_dot;
+ }
+ }
+}
+
+/*
+ *Print help for commands
+ */
+static void
+db_help_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
+ const char *modif){
+
+ const struct db_cmd_tbl_en_head *list;
+ const struct db_cmd_tbl_en *list_ent;
+ const struct db_command *help;
+ int t,result;
+
+ t=db_read_token();
+ /*I have also another command not only help*/
+ if (t == tIDENT){
+
+ switch(db_get_list_type(db_tok_string)){
+
+ case DDB_BASE_CMD:
+ list=&db_base_cmd_list;
+ break;
+ case DDB_SHOW_CMD:
+ list=&db_show_cmd_list;
+ /*I need to read show subcommand If show command list is used.*/
+ t = db_read_token();
+
+ if (t != tIDENT) {
+ /*if only show command is executed I print all subcommands*/
+ db_cmd_list(&db_show_cmd_list);
+ db_flush_lex();
+ return;
+ }
+
+ if (strncmp("all",db_tok_string,3) == 0){
+ t = db_read_token();
+
+ if (t != tIDENT) {
+ /*if only show command is executed I print all subcommands*/
+ db_printf("callout, pages, polls, procs\n");
+ db_flush_lex();
+ return;
+ }
+
+ }
+
+
+ break;
+ default:
+ db_printf("No such command\n");
+ db_flush_lex();
+ return;
+ }
+
+ TAILQ_FOREACH(list_ent,list,db_cmd_next){
+ result = db_cmd_search(db_tok_string, list_ent->db_cmd, &help);
+ /*after CMD_UNIQUE in cmd_list only one same command name is possible*/
+ if (result == CMD_UNIQUE)
+ break;
+ }
+
+ /*print help*/
+ if (help->cmd_arg != NULL)
+ db_printf("Command: %s Arguments: %s\n Descr: %s\n",
+ help->name,help->cmd_arg,help->cmd_descr);
+ else
+ db_printf("Command: %s Doesn't have any help message included.\n",
+ help->name);
+
+ } else
+ /*print base commands*/
+ db_cmd_list(&db_base_cmd_list);
+
+ return;
+}
+
+/*
+ *Keep DDB interface backward compatible with old versions
+ */
+static void
+db_ui_compat_cmd(db_expr_t ar_addr, bool ar_have_addr, db_expr_t ar_count,
+ const char *ar_modif){
+
+ const struct db_command *command;
+ struct db_cmd_tbl_en *list_ent;
+
+ int t;
+ char modif[TOK_STRING_SIZE];
+ db_expr_t addr, count;
+ bool have_addr = false;
+ int result;
+ static db_expr_t last_count = 0;
+
+ /*read next command behind all*/
+ t = db_read_token();
+
+ if (t != tIDENT){
+ printf("callout,pages,procs,pools are show all subcommands\n");
return;
- default:
- break;
- }
- if ((cmd_table = cmd->more) != 0) {
- t = db_read_token();
- if (t != tIDENT) {
- db_cmd_list(cmd_table);
- db_flush_lex();
- return;
- }
- }
}
- if ((cmd->flag & CS_OWN) == 0) {
- /*
- * Standard syntax:
- * command [/modifier] [addr] [,count]
- */
- t = db_read_token();
- if (t == tSLASH) {
- t = db_read_token();
- if (t != tIDENT) {
- db_printf("Bad modifier\n");
- db_flush_lex();
- return;
- }
- strlcpy(modif, db_tok_string, sizeof(modif));
- } else {
- db_unread_token(t);
- modif[0] = '\0';
- }
+ /*XXX Search inserted command we support no show all whatever show command*/
+ TAILQ_FOREACH(list_ent,&db_show_cmd_list,db_cmd_next){
+ result = db_cmd_search(db_tok_string, list_ent->db_cmd, &command);
+ /*after CMD_UNIQUE in cmd_list only one same command name is possible*/
+ if (result == CMD_UNIQUE)
+ break;
+ }
- if (db_expression(&addr)) {
- db_dot = (db_addr_t) addr;
- db_last_addr = db_dot;
- have_addr = true;
- } else {
- addr = (db_expr_t) db_dot;
- have_addr = false;
- }
- t = db_read_token();
- if (t == tCOMMA) {
- if (!db_expression(&count)) {
- db_printf("Count missing\n");
- db_flush_lex();
- return;
- }
- } else {
- db_unread_token(t);
- count = -1;
- }
- if ((cmd->flag & CS_MORE) == 0) {
- db_skip_to_eol();
- }
+ if ((command->flag & CS_OWN) == 0) {
+
+ /*
+ * Standard syntax:
+ * command [/modifier] [addr] [,count]
+ */
+ t = db_read_token(); /*get modifier*/
+ if (t == tSLASH) {
+ t = db_read_token();
+ if (t != tIDENT) {
+ db_printf("Bad modifier\n");
+ db_flush_lex();
+ return;
+ }
+ strlcpy(modif, db_tok_string, sizeof(modif)); /*save modifier*/
+
+ } else {
+ db_unread_token(t);
+ modif[0] = '\0';
+ }
+
+ if (db_expression(&addr)) { /*get address*/
+ db_dot = (db_addr_t) addr;
+ db_last_addr = db_dot;
+ have_addr = true;
+ } else {
+ addr = (db_expr_t) db_dot;
+ have_addr = false;
+ }
+
+ t = db_read_token();
+ if (t == tCOMMA) { /*Get count*/
+ if (!db_expression(&count)) {
+ db_printf("Count missing\n");
+ db_flush_lex();
+ return;
+ }
+ } else {
+ db_unread_token(t);
+ count = -1;
+ }
+ if ((command->flag & CS_MORE) == 0) {
+ db_skip_to_eol();
+ }
}
- }
- *last_cmdp = cmd;
- last_count = count;
- if (cmd != 0) {
- /*
- * Execute the command.
- */
- (*cmd->fcn)(addr, have_addr, count, modif);
- if (cmd->flag & CS_SET_DOT) {
- /*
- * If command changes dot, set dot to
- * previous address displayed (if 'ed' style).
- */
- if (db_ed_style)
- db_dot = db_prev;
- else
- db_dot = db_next;
- } else {
- /*
- * If command does not change dot,
- * set 'next' location to be the same.
- */
- db_next = db_dot;
+
+ last_count = count;
+
+ if (command != 0) {
+ /*
+ * Execute the command.
+ */
+ (*command->fcn)(addr, have_addr, count, modif);
+
+ if (command->flag & CS_SET_DOT) {
+ /*
+ * If command changes dot, set dot to
+ * previous address displayed (if 'ed' style).
+ */
+ if (db_ed_style)
+ db_dot = db_prev;
+ else
+ db_dot = db_next;
+ } else {
+ /*
+ * If command does not change dot,
+ * set 'next' location to be the same.
+ */
+ db_next = db_dot;
+ }
+
+
}
- }
+ return;
}
/*ARGSUSED*/
static void
db_map_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
- const char *modif)
-{
- bool full = false;
-
- if (modif[0] == 'f')
- full = true;
+ const char *modif){
+ bool full = false;
+
+ if (modif[0] == 'f')
+ full = true;
- if (have_addr == false)
- addr = (db_expr_t)(intptr_t) kernel_map;
+ if (have_addr == false)
+ addr = (db_expr_t)(intptr_t) kernel_map;
- uvm_map_printit((struct vm_map *)(intptr_t) addr, full, db_printf);
+ uvm_map_printit((struct vm_map *)(intptr_t) addr, full, db_printf);
}
/*ARGSUSED*/
static void
db_malloc_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
-{
+ db_expr_t count, const char *modif){
#ifdef MALLOC_DEBUG
- if (!have_addr)
- addr = 0;
+ if (!have_addr)
+ addr = 0;
- debug_malloc_printit(db_printf, (vaddr_t) addr);
+ debug_malloc_printit(db_printf, (vaddr_t) addr);
#else
- db_printf("The kernel is not built with the MALLOC_DEBUG option.\n");
+ db_printf("The kernel is not built with the MALLOC_DEBUG option.\n");
#endif /* MALLOC_DEBUG */
}
/*ARGSUSED*/
static void
db_object_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
-{
- bool full = false;
+ db_expr_t count, const char *modif){
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- uvm_object_printit((struct uvm_object *)(intptr_t) addr, full,
- db_printf);
+ uvm_object_printit((struct uvm_object *)(intptr_t) addr, full,
+ db_printf);
}
/*ARGSUSED*/
static void
db_page_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
-{
- bool full = false;
+ db_expr_t count, const char *modif){
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- uvm_page_printit((struct vm_page *)(intptr_t) addr, full, db_printf);
+ uvm_page_printit((struct vm_page *)(intptr_t) addr, full, db_printf);
}
/*ARGSUSED*/
static void
db_show_all_pages(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
-
- uvm_page_printall(db_printf);
+ uvm_page_printall(db_printf);
}
/*ARGSUSED*/
static void
db_buf_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- bool full = false;
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- vfs_buf_print((struct buf *)(intptr_t) addr, full, db_printf);
+ vfs_buf_print((struct buf *)(intptr_t) addr, full, db_printf);
}
/*ARGSUSED*/
static void
db_event_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- bool full = false;
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- event_print(full, db_printf);
+ event_print(full, db_printf);
}
/*ARGSUSED*/
static void
db_vnode_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- bool full = false;
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- vfs_vnode_print((struct vnode *)(intptr_t) addr, full, db_printf);
+ vfs_vnode_print((struct vnode *)(intptr_t) addr, full, db_printf);
}
static void
db_mount_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- bool full = false;
+ bool full = false;
- if (modif[0] == 'f')
- full = true;
+ if (modif[0] == 'f')
+ full = true;
- vfs_mount_print((struct mount *)(intptr_t) addr, full, db_printf);
+ vfs_mount_print((struct mount *)(intptr_t) addr, full, db_printf);
}
/*ARGSUSED*/
static void
db_mbuf_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- m_print((const struct mbuf *)(intptr_t) addr, modif, db_printf);
+ m_print((const struct mbuf *)(intptr_t) addr, modif, db_printf);
}
/*ARGSUSED*/
static void
db_pool_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- pool_printit((struct pool *)(intptr_t) addr, modif, db_printf);
+ pool_printit((struct pool *)(intptr_t) addr, modif, db_printf);
}
/*ARGSUSED*/
static void
db_namecache_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- namecache_print((struct vnode *)(intptr_t) addr, db_printf);
+ namecache_print((struct vnode *)(intptr_t) addr, db_printf);
}
/*ARGSUSED*/
static void
db_uvmexp_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- uvmexp_print(db_printf);
+ uvmexp_print(db_printf);
}
/*ARGSUSED*/
static void
db_lock_print_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- lockdebug_lock_print((void *)addr, db_printf);
+ lockdebug_lock_print((void *)addr, db_printf);
}
/*
@@ -701,140 +1216,141 @@
/*ARGSUSED*/
static void
db_fncall(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- db_expr_t fn_addr;
+ db_expr_t fn_addr;
#define MAXARGS 11
- db_expr_t args[MAXARGS];
- int nargs = 0;
- db_expr_t retval;
- db_expr_t (*func)(db_expr_t, ...);
- int t;
-
- if (!db_expression(&fn_addr)) {
- db_printf("Bad function\n");
- db_flush_lex();
- return;
- }
- func = (db_expr_t (*)(db_expr_t, ...))(intptr_t) fn_addr;
+ db_expr_t args[MAXARGS];
+ int nargs = 0;
+ db_expr_t retval;
+ db_expr_t (*func)(db_expr_t, ...);
+ int t;
+
+ if (!db_expression(&fn_addr)) {
+ db_printf("Bad function\n");
+ db_flush_lex();
+ return;
+ }
+ func = (db_expr_t (*)(db_expr_t, ...))(intptr_t) fn_addr;
+
+ t = db_read_token();
+ if (t == tLPAREN) {
+ if (db_expression(&args[0])) {
+ nargs++;
+ while ((t = db_read_token()) == tCOMMA) {
+ if (nargs == MAXARGS) {
+ db_printf("Too many arguments\n");
+ db_flush_lex();
+ return;
+ }
+ if (!db_expression(&args[nargs])) {
+ db_printf("Argument missing\n");
+ db_flush_lex();
+ return;
+ }
+ nargs++;
+ }
+ db_unread_token(t);
+ }
+ if (db_read_token() != tRPAREN) {
+ db_printf("?\n");
+ db_flush_lex();
+ return;
+ }
+ }
+ db_skip_to_eol();
+
+ while (nargs < MAXARGS) {
+ args[nargs++] = 0;
+ }
- t = db_read_token();
- if (t == tLPAREN) {
- if (db_expression(&args[0])) {
- nargs++;
- while ((t = db_read_token()) == tCOMMA) {
- if (nargs == MAXARGS) {
- db_printf("Too many arguments\n");
- db_flush_lex();
- return;
- }
- if (!db_expression(&args[nargs])) {
- db_printf("Argument missing\n");
- db_flush_lex();
- return;
- }
- nargs++;
- }
- db_unread_token(t);
- }
- if (db_read_token() != tRPAREN) {
- db_printf("?\n");
- db_flush_lex();
- return;
- }
- }
- db_skip_to_eol();
-
- while (nargs < MAXARGS) {
- args[nargs++] = 0;
- }
-
- retval = (*func)(args[0], args[1], args[2], args[3], args[4],
- args[5], args[6], args[7], args[8], args[9]);
- db_printf("%s\n", db_num_to_str(retval));
+ retval = (*func)(args[0], args[1], args[2], args[3], args[4],
+ args[5], args[6], args[7], args[8], args[9]);
+ db_printf("%s\n", db_num_to_str(retval));
}
static void
db_reboot_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- db_expr_t bootflags;
+ db_expr_t bootflags;
- /* Flags, default to RB_AUTOBOOT */
- if (!db_expression(&bootflags))
- bootflags = (db_expr_t)RB_AUTOBOOT;
- if (db_read_token() != tEOL) {
- db_error("?\n");
- /*NOTREACHED*/
- }
- /*
- * We are leaving DDB, never to return upward.
- * Clear db_recover so that we can debug faults in functions
- * called from cpu_reboot.
- */
- db_recover = 0;
- cpu_reboot((int)bootflags, NULL);
+ /* Flags, default to RB_AUTOBOOT */
+ if (!db_expression(&bootflags))
+ bootflags = (db_expr_t)RB_AUTOBOOT;
+ if (db_read_token() != tEOL) {
+ db_error("?\n");
+ /*NOTREACHED*/
+ }
+ /*
+ * We are leaving DDB, never to return upward.
+ * Clear db_recover so that we can debug faults in functions
+ * called from cpu_reboot.
+ */
+ db_recover = 0;
+ cpu_reboot((int)bootflags, NULL);
}
static void
db_sifting_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- int mode, t;
+ int mode, t;
- t = db_read_token();
- if (t == tSLASH) {
- t = db_read_token();
- if (t != tIDENT) {
- bad_modifier:
- db_printf("Bad modifier\n");
- db_flush_lex();
- return;
- }
- if (!strcmp(db_tok_string, "F"))
- mode = 'F';
- else
- goto bad_modifier;
t = db_read_token();
- } else
- mode = 0;
+ if (t == tSLASH) {
+ t = db_read_token();
+ if (t != tIDENT) {
+ bad_modifier:
+ db_printf("Bad modifier\n");
+ db_flush_lex();
+ return;
+ }
+ if (!strcmp(db_tok_string, "F"))
+ mode = 'F';
+ else
+ goto bad_modifier;
+ t = db_read_token();
+ } else
+ mode = 0;
- if (t == tIDENT)
- db_sifting(db_tok_string, mode);
- else {
- db_printf("Bad argument (non-string)\n");
- db_flush_lex();
- }
+ if (t == tIDENT)
+ db_sifting(db_tok_string, mode);
+ else {
+ db_printf("Bad argument (non-string)\n");
+ db_flush_lex();
+ }
}
static void
-db_stack_trace_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
+db_stack_trace_cmd(db_expr_t addr, bool have_addr,
+ db_expr_t count, const char *modif)
{
- register const char *cp = modif;
- register char c;
- void (*pr)(const char *, ...);
+ register const char *cp = modif;
+ register char c;
+ void (*pr)(const char *, ...);
+
+ pr = db_printf;
+ while ((c = *cp++) != 0)
+ if (c == 'l')
+ pr = printf;
- pr = db_printf;
- while ((c = *cp++) != 0)
- if (c == 'l')
- pr = printf;
+ if (count == -1)
+ count = 65535;
- if (count == -1)
- count = 65535;
-
- db_stack_trace_print(addr, have_addr, count, modif, pr);
+ db_stack_trace_print(addr, have_addr, count, modif, pr);
}
static void
db_sync_cmd(db_expr_t addr, bool have_addr,
- db_expr_t count, const char *modif)
+ db_expr_t count, const char *modif)
{
- /*
- * We are leaving DDB, never to return upward.
- * Clear db_recover so that we can debug faults in functions
- * called from cpu_reboot.
- */
- db_recover = 0;
- cpu_reboot(RB_DUMP, NULL);
+ /*
+ * We are leaving DDB, never to return upward.
+ * Clear db_recover so that we can debug faults in functions
+ * called from cpu_reboot.
+ */
+ db_recover = 0;
+ cpu_reboot(RB_DUMP, NULL);
}
Index: ddb/db_command.h
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_command.h,v
retrieving revision 1.27
diff -u -r1.27 db_command.h
--- ddb/db_command.h 22 Feb 2007 04:38:05 -0000 1.27
+++ ddb/db_command.h 18 Jul 2007 07:24:54 -0000
@@ -1,5 +1,41 @@
/* $NetBSD: db_command.h,v 1.27 2007/02/22 04:38:05 matt Exp $ */
+/*-
+ * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Adam Hamsik.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@@ -29,10 +65,8 @@
* Date: 7/90
*/
-/*
- * Command loop declarations.
- */
-struct db_command;
+#ifndef _DDB_COMMAND_
+#define _DDB_COMMAND_
void db_skip_to_eol(void);
void db_command_loop(void);
@@ -41,23 +75,60 @@
extern db_addr_t db_dot; /* current location */
extern db_addr_t db_last_addr; /* last explicit address typed */
extern db_addr_t db_prev; /* last address examined
- or written */
+ or written */
extern db_addr_t db_next; /* next address to be examined
- or written */
+ or written */
extern char db_cmd_on_enter[];
+struct db_command;
+
+
+
+/*
+ * Macro include help when DDB_VERBOSE_HELP option(9) is used
+ */
+#if defined(DDB_VERBOSE_HELP)
+#define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg)\
+ name,funct,type,cmd_descr,cmd_arg
+#else
+#define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg)\
+ name,funct,type,NULL,NULL
+#endif
+
+
+
+/*
+ * we have two types of lists one for base commands like reboot
+ * and another list for show subcommands.
+ */
+
+#define DDB_BASE_CMD 0
+#define DDB_SHOW_CMD 1
+
+
+int db_add_command_tbl(uint8_t, const struct db_command *);
+int db_rem_command_tbl(uint8_t, const struct db_command *);
+
/*
* Command table
*/
struct db_command {
- const char *name; /* command name */
- /* function to call */
- void (*fcn)(db_expr_t, bool, db_expr_t, const char *);
- int flag; /* extra info: */
+ const char *name; /* command name */
+
+ /* function to call */
+ void (*fcn)(db_expr_t, bool, db_expr_t, const char *);
+ uint16_t flag; /* extra info: */
#define CS_OWN 0x1 /* non-standard syntax */
#define CS_MORE 0x2 /* standard syntax, but may have other
- words at end */
+ words at end */
#define CS_SET_DOT 0x100 /* set dot after command */
- const struct db_command *more; /* another level of command */
+
+ const char *cmd_descr; /*description of command*/
+ const char *cmd_arg; /*command arguments*/
+
};
+
+#endif /*_DDB_COMMAND_*/
+
+
Index: ddb/files.ddb
===================================================================
RCS file: /cvsroot/src/sys/ddb/files.ddb,v
retrieving revision 1.1
diff -u -r1.1 files.ddb
--- ddb/files.ddb 27 Nov 2005 22:44:35 -0000 1.1
+++ ddb/files.ddb 18 Jul 2007 07:24:54 -0000
@@ -3,10 +3,10 @@
#
# DDB options
#
-defflag opt_ddb.h DDB
+defflag opt_ddb.h DDB
defparam opt_ddbparam.h DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE
DDB_BREAK_CHAR DDB_KEYCODE SYMTAB_SPACE
- DDB_COMMANDONENTER
+ DDB_COMMANDONENTER DDB_VERBOSE_HELP
file ddb/db_access.c ddb | kgdb # XXX kgdb reference
file ddb/db_aout.c ddb
--Apple-Mail-6-283254789
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Regards
-----------------------------------------
Adam Hamsik
jabber: haad@jabber.org
icq: 249727910
Proud NetBSD user.
We program to have fun.
Even when we program for money, we want to have fun as well.
~~ Yukihiro Matsumoto
--Apple-Mail-6-283254789--
--Apple-Mail-7-283254841
content-type: application/pgp-signature; x-mac-type=70674453;
name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iD8DBQFGndVVlIxPgX3Go0MRAs3KAKClPi4nm7HcJS23N+CQRGF0fq8EbgCgiXA3
shuYaOnVA+avLgwEHZznjog=
=/z4c
-----END PGP SIGNATURE-----
--Apple-Mail-7-283254841--