2007-10-08 19:06:26 +04:00
|
|
|
/* $NetBSD: db_command.c,v 1.106 2007/10/08 15:06:26 martin Exp $ */
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1991,1990 Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* 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.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1999-04-13 00:38:17 +04:00
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
1993-03-21 12:45:37 +03:00
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Carnegie Mellon requests users of this software to return to
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
2007-09-22 22:40:20 +04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1993-08-02 21:48:44 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Command dispatcher.
|
|
|
|
*/
|
2001-11-13 01:54:03 +03:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2007-10-08 19:06:26 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.106 2007/10/08 15:06:26 martin Exp $");
|
2001-11-13 01:54:03 +03:00
|
|
|
|
|
|
|
#include "opt_ddb.h"
|
2003-04-28 06:49:54 +04:00
|
|
|
#include "opt_kgdb.h"
|
2001-11-13 01:54:03 +03:00
|
|
|
#include "opt_inet.h"
|
2005-11-26 15:16:44 +03:00
|
|
|
#include "opt_ddbparam.h"
|
2001-11-13 01:54:03 +03:00
|
|
|
|
1993-12-18 07:46:25 +03:00
|
|
|
#include <sys/param.h>
|
1996-03-07 17:33:39 +03:00
|
|
|
#include <sys/systm.h>
|
1997-09-11 10:55:56 +04:00
|
|
|
#include <sys/reboot.h>
|
2002-02-15 14:18:26 +03:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
2006-01-24 16:02:57 +03:00
|
|
|
#include <sys/mbuf.h>
|
2002-02-15 14:18:26 +03:00
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/pool.h>
|
1993-12-18 07:46:25 +03:00
|
|
|
#include <sys/proc.h>
|
2000-04-10 06:22:13 +04:00
|
|
|
#include <sys/vnode.h>
|
2007-02-10 00:55:00 +03:00
|
|
|
#include <sys/lockdebug.h>
|
|
|
|
#include <sys/sleepq.h>
|
1993-12-18 07:46:25 +03:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*include queue macros*/
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <machine/db_machdep.h> /* type definitions */
|
|
|
|
|
2001-05-30 15:40:35 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
2000-02-21 08:48:56 +03:00
|
|
|
#include "opt_multiprocessor.h"
|
|
|
|
#endif
|
|
|
|
#ifdef MULTIPROCESSOR
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#endif
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <ddb/db_lex.h>
|
|
|
|
#include <ddb/db_output.h>
|
1994-03-23 23:00:56 +03:00
|
|
|
#include <ddb/db_command.h>
|
1996-02-05 04:56:47 +03:00
|
|
|
#include <ddb/db_break.h>
|
|
|
|
#include <ddb/db_watch.h>
|
|
|
|
#include <ddb/db_run.h>
|
|
|
|
#include <ddb/db_variables.h>
|
|
|
|
#include <ddb/db_interface.h>
|
|
|
|
#include <ddb/db_sym.h>
|
|
|
|
#include <ddb/db_extern.h>
|
|
|
|
|
1998-02-05 10:59:28 +03:00
|
|
|
#include <uvm/uvm_extern.h>
|
1998-07-05 02:18:13 +04:00
|
|
|
#include <uvm/uvm_ddb.h>
|
1998-02-05 10:59:28 +03:00
|
|
|
|
2000-06-09 01:06:46 +04:00
|
|
|
#include "arp.h"
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
|
|
|
* Results of command search.
|
|
|
|
*/
|
|
|
|
#define CMD_UNIQUE 0
|
|
|
|
#define CMD_FOUND 1
|
|
|
|
#define CMD_NONE 2
|
|
|
|
#define CMD_AMBIGUOUS 3
|
2007-09-22 22:40:20 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Exported global variables
|
|
|
|
*/
|
2007-02-22 01:59:35 +03:00
|
|
|
bool db_cmd_loop_done;
|
1996-02-13 20:39:01 +03:00
|
|
|
label_t *db_recover;
|
2002-02-15 10:33:48 +03:00
|
|
|
db_addr_t db_dot;
|
|
|
|
db_addr_t db_last_addr;
|
|
|
|
db_addr_t db_prev;
|
|
|
|
db_addr_t db_next;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
New DDB api for adding and removing commands uses three 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
|
|
|
|
c) if defined machine specific commands
|
|
|
|
|
|
|
|
ddb_add_cmd, ddb_rem_cmd use type (DDB_SHOW_CMD||DDB_BASE_CMD)argument to
|
|
|
|
add them to representativ lists.
|
|
|
|
*/
|
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
static const struct db_command db_command_table[];
|
|
|
|
static const struct db_command db_show_cmds[];
|
|
|
|
#ifdef DB_MACHINE_COMMANDS
|
|
|
|
static const struct db_command db_machine_command_table[];
|
|
|
|
#endif
|
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
/* the global queue of all command tables */
|
|
|
|
TAILQ_HEAD(db_cmd_tbl_en_head, db_cmd_tbl_en);
|
|
|
|
|
|
|
|
/* TAILQ entry used to register command tables */
|
|
|
|
struct db_cmd_tbl_en {
|
|
|
|
const struct db_command *db_cmd; /* cmd table */
|
|
|
|
TAILQ_ENTRY(db_cmd_tbl_en) db_cmd_next;
|
|
|
|
};
|
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
/* head of base commands list */
|
2007-09-22 22:40:20 +04:00
|
|
|
static struct db_cmd_tbl_en_head db_base_cmd_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(db_base_cmd_list);
|
2007-10-02 02:01:38 +04:00
|
|
|
static struct db_cmd_tbl_en db_base_cmd_builtins =
|
|
|
|
{ .db_cmd = db_command_table };
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
/* head of show commands list */
|
2007-09-22 22:40:20 +04:00
|
|
|
static struct db_cmd_tbl_en_head db_show_cmd_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(db_show_cmd_list);
|
2007-10-02 02:01:38 +04:00
|
|
|
static struct db_cmd_tbl_en db_show_cmd_builtins =
|
|
|
|
{ .db_cmd = db_show_cmds };
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
/* head of machine commands list */
|
2007-09-22 22:40:20 +04:00
|
|
|
static struct db_cmd_tbl_en_head db_mach_cmd_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(db_mach_cmd_list);
|
2007-10-02 02:01:38 +04:00
|
|
|
#ifdef DB_MACHINE_COMMANDS
|
|
|
|
static struct db_cmd_tbl_en db_mach_cmd_builtins =
|
|
|
|
{ .db_cmd = db_machine_command_table };
|
2007-09-22 22:40:20 +04:00
|
|
|
#endif
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* if 'ed' style: 'dot' is set at start of last item printed,
|
|
|
|
* and '+' points to next line.
|
|
|
|
* Otherwise: 'dot' points to next item, '..' points to last.
|
|
|
|
*/
|
2007-02-22 09:34:42 +03:00
|
|
|
static bool db_ed_style = true;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2007-10-02 02:05:15 +04:00
|
|
|
static void db_init_commands(void);
|
2007-10-02 02:01:38 +04:00
|
|
|
static int db_register_tbl_entry(uint8_t type,
|
|
|
|
struct db_cmd_tbl_en *list_ent);
|
2007-09-22 22:40:20 +04:00
|
|
|
static void db_cmd_list(const struct db_cmd_tbl_en_head *);
|
2002-02-15 10:33:48 +03:00
|
|
|
static int db_cmd_search(const char *, const struct db_command *,
|
2007-09-22 22:40:20 +04:00
|
|
|
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 *);
|
2007-02-22 07:38:02 +03:00
|
|
|
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 *);
|
2007-09-22 22:40:20 +04:00
|
|
|
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_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 *);
|
2007-02-22 07:38:02 +03:00
|
|
|
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 *);
|
2007-09-22 22:40:20 +04:00
|
|
|
static void db_namecache_print_cmd(db_expr_t, bool, db_expr_t,
|
|
|
|
const char *);
|
2007-02-22 07:38:02 +03:00
|
|
|
static void db_object_print_cmd(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
static void db_page_print_cmd(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
static void db_show_all_pages(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
static void db_pool_print_cmd(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
static void db_reboot_cmd(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
static void db_sifting_cmd(db_expr_t, bool, db_expr_t, const char *);
|
|
|
|
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_vnode_print_cmd(db_expr_t, bool, db_expr_t, const char *);
|
2002-02-15 10:33:48 +03:00
|
|
|
|
|
|
|
static const struct db_command db_show_cmds[] = {
|
2007-09-22 22:40:20 +04:00
|
|
|
/*added from all sub cmds*/
|
|
|
|
{ DDB_ADD_CMD("callout", db_show_callout,
|
|
|
|
0 ,"List all used callout functions.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("pages", db_show_all_pages,
|
|
|
|
0 ,"List all used memory pages.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("procs", db_show_all_procs,
|
|
|
|
0 ,"List all processes.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("pools", db_show_all_pools,
|
|
|
|
0 ,"Show all poolS",NULL,NULL) },
|
|
|
|
/*added from all sub cmds*/
|
|
|
|
{ DDB_ADD_CMD("aio_jobs", db_show_aio_jobs, 0,
|
|
|
|
"Show aio jobs",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("all", NULL,
|
|
|
|
CS_COMPAT, NULL,NULL,NULL) },
|
2002-02-15 10:33:48 +03:00
|
|
|
#if defined(INET) && (NARP > 0)
|
2007-09-22 22:40:20 +04:00
|
|
|
{ DDB_ADD_CMD("arptab", db_show_arptab, 0,NULL,NULL,NULL) },
|
2002-02-15 10:33:48 +03:00
|
|
|
#endif
|
2007-09-22 22:40:20 +04:00
|
|
|
{ DDB_ADD_CMD("breaks", db_listbreak_cmd, 0,
|
|
|
|
"Display all breaks.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("buf", db_buf_print_cmd, 0,
|
|
|
|
"Print the struct buf at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("event", db_event_print_cmd, 0,
|
|
|
|
"Print all the non-zero evcnt(9) event counters.", "[/f]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("lock", db_lock_print_cmd, 0,NULL,NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("malloc", db_malloc_print_cmd,0,NULL,NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("map", db_map_print_cmd, 0,
|
|
|
|
"Print the vm_map at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("mount", db_mount_print_cmd, 0,
|
|
|
|
"Print the mount structure at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("mbuf", db_mbuf_print_cmd, 0,NULL,NULL,
|
|
|
|
"-c prints all mbuf chains") },
|
|
|
|
{ DDB_ADD_CMD("ncache", db_namecache_print_cmd, 0,
|
|
|
|
"Dump the namecache list.", "address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("object", db_object_print_cmd, 0,
|
|
|
|
"Print the vm_object at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("page", db_page_print_cmd, 0,
|
|
|
|
"Print the vm_page at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("pool", db_pool_print_cmd, 0,
|
|
|
|
"Print the pool at address.", "[/clp] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("registers", db_show_regs, 0,
|
|
|
|
"Display the register set.", "[/u]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("sched_qs", db_show_sched_qs, 0,
|
|
|
|
"Print the state of the scheduler's run queues.",
|
|
|
|
NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("uvmexp", db_uvmexp_print_cmd, 0,
|
|
|
|
"Print a selection of UVM counters and statistics.",
|
|
|
|
NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("vnode", db_vnode_print_cmd, 0,
|
|
|
|
"Print the vnode at address.", "[/f] address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("watches", db_listwatch_cmd, 0,
|
|
|
|
"Display all watchpoints.", NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL,NULL) }
|
2002-02-15 10:33:48 +03:00
|
|
|
};
|
|
|
|
|
2005-04-29 14:40:16 +04:00
|
|
|
/* arch/<arch>/<arch>/db_interface.c */
|
|
|
|
#ifdef DB_MACHINE_COMMANDS
|
|
|
|
extern const struct db_command db_machine_command_table[];
|
|
|
|
#endif
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static const struct db_command db_command_table[] = {
|
2007-09-22 22:40:20 +04:00
|
|
|
{ DDB_ADD_CMD("b", db_breakpoint_cmd, 0,
|
|
|
|
"Set a breakpoint at address", "[/u] address[,count].",NULL) },
|
|
|
|
{ DDB_ADD_CMD("break", db_breakpoint_cmd, 0,
|
|
|
|
"Set a breakpoint at address", "[/u] address[,count].",NULL) },
|
|
|
|
{ DDB_ADD_CMD("bt", db_stack_trace_cmd, 0,
|
|
|
|
"Show backtrace.", "See help trace.",NULL) },
|
|
|
|
{ DDB_ADD_CMD("c", db_continue_cmd, 0,
|
|
|
|
"Continue execution.", "[/c]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("call", db_fncall, CS_OWN,
|
|
|
|
"Call the function", "address[(expression[,...])]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("callout", db_show_callout, 0, NULL,
|
|
|
|
NULL,NULL ) },
|
|
|
|
{ DDB_ADD_CMD("continue", db_continue_cmd, 0,
|
|
|
|
"Continue execution.", "[/c]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("d", db_delete_cmd, 0,
|
|
|
|
"Delete a breakpoint.", "address | #number",NULL) },
|
|
|
|
{ DDB_ADD_CMD("delete", db_delete_cmd, 0,
|
|
|
|
"Delete a breakpoint.", "address | #number",NULL) },
|
|
|
|
{ DDB_ADD_CMD("dmesg", db_dmesg, 0,
|
|
|
|
"Show kernel message buffer.", "[count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("dwatch", db_deletewatch_cmd, 0,
|
|
|
|
"Delete the watchpoint.", "address",NULL) },
|
|
|
|
{ DDB_ADD_CMD("examine", db_examine_cmd, CS_SET_DOT,
|
|
|
|
"Display the address locations.",
|
|
|
|
"[/modifier] address[,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("help", db_help_print_cmd, CS_OWN|CS_NOREPEAT,
|
|
|
|
"Display help about commands",
|
|
|
|
"Use other commands as arguments.",NULL) },
|
|
|
|
{ DDB_ADD_CMD("kill", db_kill_proc, CS_OWN,
|
|
|
|
"Send a signal to the process","pid[,signal_number]",
|
|
|
|
" pid:\t\t\tthe process id (may need 0t prefix for decimal)\n"
|
|
|
|
" signal_number:\tthe signal to send") },
|
2003-04-28 06:49:54 +04:00
|
|
|
#ifdef KGDB
|
2007-09-23 14:26:06 +04:00
|
|
|
{ DDB_ADD_CMD("kgdb", db_kgdb_cmd, 0, NULL,NULL,NULL) },
|
2003-04-28 06:49:54 +04:00
|
|
|
#endif
|
2007-09-22 22:40:20 +04:00
|
|
|
{ DDB_ADD_CMD("machine",NULL,CS_MACH,
|
|
|
|
"Architecture specific functions.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("match", db_trace_until_matching_cmd,0,
|
|
|
|
"Stop at the matching return instruction.","See help next",NULL) },
|
|
|
|
{ DDB_ADD_CMD("next", db_trace_until_matching_cmd,0,
|
|
|
|
"Stop at the matching return instruction.","[/p]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("p", db_print_cmd, 0,
|
|
|
|
"Print address according to the format.",
|
|
|
|
"[/axzodurc] address [address ...]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("print", db_print_cmd, 0,
|
|
|
|
"Print address according to the format.",
|
|
|
|
"[/axzodurc] address [address ...]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("ps", db_show_all_procs, 0,
|
|
|
|
"Print all processes.","See show all procs",NULL) },
|
|
|
|
{ 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",NULL) },
|
|
|
|
{ DDB_ADD_CMD("s", db_single_step_cmd, 0,
|
|
|
|
"Single-step count times.","[/p] [,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("search", db_search_cmd, CS_OWN|CS_SET_DOT,
|
|
|
|
"Search memory from address for value.",
|
|
|
|
"[/bhl] address value [mask] [,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("set", db_set_cmd, CS_OWN,
|
|
|
|
"Set the named variable","$variable [=] expression",NULL) },
|
|
|
|
{ DDB_ADD_CMD("show", NULL ,CS_SHOW,
|
|
|
|
"Show kernel stats.", NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("sifting", db_sifting_cmd, CS_OWN,
|
|
|
|
"Search the symbol tables ","[/F] string",NULL) },
|
|
|
|
{ DDB_ADD_CMD("step", db_single_step_cmd, 0,
|
|
|
|
"Single-step count times.","[/p] [,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("sync", db_sync_cmd, CS_OWN,
|
|
|
|
"Force a crash dump, and then reboot.",NULL,NULL) },
|
|
|
|
{ DDB_ADD_CMD("trace", db_stack_trace_cmd, 0,
|
|
|
|
"Stack trace from frame-address.",
|
|
|
|
"[/u[l]] [frame-address][,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("until", db_trace_until_call_cmd,0,
|
|
|
|
"Stop at the next call or return instruction.","[/p]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("w", db_write_cmd, CS_MORE|CS_SET_DOT,
|
|
|
|
"Set a watchpoint for a region. ","address[,size]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("watch", db_watchpoint_cmd, CS_MORE,
|
|
|
|
"Set a watchpoint for a region. ","address[,size]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("write", db_write_cmd, CS_MORE|CS_SET_DOT,
|
|
|
|
"Write the expressions at succeeding locations.",
|
|
|
|
"[/bhl] address expression [expression ...]",NULL) },
|
|
|
|
{ DDB_ADD_CMD("x", db_examine_cmd, CS_SET_DOT,
|
|
|
|
"Display the address locations.",
|
|
|
|
"[/modifier] address[,count]",NULL) },
|
|
|
|
{ DDB_ADD_CMD(NULL, NULL, 0, NULL, NULL, NULL) }
|
2002-02-15 10:33:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct db_command *db_last_command = NULL;
|
2005-11-26 15:16:44 +03:00
|
|
|
#if defined(DDB_COMMANDONENTER)
|
2005-11-27 16:05:28 +03:00
|
|
|
char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = ___STRING(DDB_COMMANDONENTER);
|
|
|
|
#else /* defined(DDB_COMMANDONENTER) */
|
|
|
|
char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = "";
|
2005-11-26 15:16:44 +03:00
|
|
|
#endif /* defined(DDB_COMMANDONENTER) */
|
|
|
|
#define DB_LINE_SEP ';'
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Utility routine - discard tokens through end-of-line.
|
|
|
|
*/
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_skip_to_eol(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
int t;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
do {
|
2002-02-15 10:33:48 +03:00
|
|
|
t = db_read_token();
|
1993-03-21 12:45:37 +03:00
|
|
|
} while (t != tEOL);
|
|
|
|
}
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
void
|
2006-09-06 01:56:44 +04:00
|
|
|
db_error(const char *s)
|
2002-02-15 10:33:48 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
db_printf("%s", s);
|
|
|
|
db_flush_lex();
|
|
|
|
longjmp(db_recover);
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*Execute commandlist after ddb start
|
|
|
|
*This function goes through the command list created from commands and ';'
|
|
|
|
*/
|
|
|
|
|
2005-11-27 16:05:28 +03:00
|
|
|
static void
|
|
|
|
db_execute_commandlist(const char *cmdlist)
|
|
|
|
{
|
|
|
|
const char *cmd = cmdlist;
|
|
|
|
const struct db_command *dummy = NULL;
|
|
|
|
|
|
|
|
while (*cmd != '\0') {
|
|
|
|
const char *ep = cmd;
|
|
|
|
|
|
|
|
while (*ep != '\0' && *ep != DB_LINE_SEP) {
|
|
|
|
ep++;
|
|
|
|
}
|
|
|
|
db_set_line(cmd, ep);
|
2007-09-22 22:40:20 +04:00
|
|
|
db_command(&dummy);
|
2005-11-27 16:05:28 +03:00
|
|
|
cmd = ep;
|
|
|
|
if (*cmd == DB_LINE_SEP) {
|
|
|
|
cmd++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*Initialize ddb command tables*/
|
2007-09-24 03:55:54 +04:00
|
|
|
void
|
2007-09-22 22:40:20 +04:00
|
|
|
db_init_commands(void)
|
|
|
|
{
|
2007-09-23 23:51:20 +04:00
|
|
|
static bool done = false;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-09-23 23:51:20 +04:00
|
|
|
if (done) return;
|
|
|
|
done = true;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
/* register command tables */
|
|
|
|
(void)db_register_tbl_entry(DDB_BASE_CMD, &db_base_cmd_builtins);
|
2007-09-22 22:40:20 +04:00
|
|
|
#ifdef DB_MACHINE_COMMANDS
|
2007-10-02 02:01:38 +04:00
|
|
|
(void)db_register_tbl_entry(DDB_MACH_CMD, &db_mach_cmd_builtins);
|
2007-09-22 22:40:20 +04:00
|
|
|
#endif
|
2007-10-02 02:01:38 +04:00
|
|
|
(void)db_register_tbl_entry(DDB_SHOW_CMD, &db_show_cmd_builtins);
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add command table to the specified list
|
|
|
|
* Arg:
|
|
|
|
* int type specifies type of command table DDB_SHOW_CMD|DDB_BASE_CMD|DDB_MAC_CMD
|
|
|
|
* *cmd_tbl poiter to static allocated db_command table
|
|
|
|
*
|
|
|
|
*Command table must be NULL terminated array of struct db_command
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
db_register_tbl(uint8_t type, const struct db_command *cmd_tbl)
|
|
|
|
{
|
|
|
|
struct db_cmd_tbl_en *list_ent;
|
2007-10-02 02:01:38 +04:00
|
|
|
|
|
|
|
if (cmd_tbl->name == 0)
|
|
|
|
/* empty list - ignore */
|
|
|
|
return 0;
|
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
/* force builtin commands to be registered first */
|
|
|
|
db_init_commands();
|
|
|
|
|
|
|
|
/* now create a list entry for this table */
|
2007-10-02 02:01:38 +04:00
|
|
|
list_ent = malloc(sizeof(struct db_cmd_tbl_en), M_TEMP, M_ZERO);
|
|
|
|
if (list_ent == NULL)
|
|
|
|
return ENOMEM;
|
|
|
|
list_ent->db_cmd=cmd_tbl;
|
2007-10-02 12:47:26 +04:00
|
|
|
|
|
|
|
/* and register it */
|
2007-10-02 02:01:38 +04:00
|
|
|
return db_register_tbl_entry(type, list_ent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
db_register_tbl_entry(uint8_t type, struct db_cmd_tbl_en *list_ent)
|
|
|
|
{
|
2007-09-22 22:40:20 +04:00
|
|
|
struct db_cmd_tbl_en_head *list;
|
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
switch(type) {
|
|
|
|
case DDB_BASE_CMD:
|
|
|
|
list = &db_base_cmd_list;
|
|
|
|
break;
|
|
|
|
case DDB_SHOW_CMD:
|
|
|
|
list = &db_show_cmd_list;
|
|
|
|
break;
|
|
|
|
case DDB_MACH_CMD:
|
|
|
|
list = &db_mach_cmd_list;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ENOENT;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
2007-10-02 02:01:38 +04:00
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(list, list_ent, db_cmd_next);
|
2007-10-02 12:47:26 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2007-10-02 02:01:38 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*
|
2007-10-02 02:01:38 +04:00
|
|
|
* Remove command table specified with db_cmd address == cmd_tbl
|
2007-09-22 22:40:20 +04:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
db_unregister_tbl(uint8_t type,const struct db_command *cmd_tbl)
|
|
|
|
{
|
|
|
|
struct db_cmd_tbl_en *list_ent;
|
|
|
|
struct db_cmd_tbl_en_head *list;
|
|
|
|
|
2007-10-02 02:01:38 +04:00
|
|
|
/* find list on which the entry should live */
|
|
|
|
switch (type) {
|
2007-09-22 22:40:20 +04:00
|
|
|
case DDB_BASE_CMD:
|
|
|
|
list=&db_base_cmd_list;
|
|
|
|
break;
|
|
|
|
case DDB_SHOW_CMD:
|
|
|
|
list=&db_show_cmd_list;
|
|
|
|
break;
|
|
|
|
case DDB_MACH_CMD:
|
|
|
|
list=&db_mach_cmd_list;
|
|
|
|
break;
|
|
|
|
default:
|
2007-10-02 02:01:38 +04:00
|
|
|
return EINVAL;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
2007-10-02 02:01:38 +04:00
|
|
|
|
|
|
|
TAILQ_FOREACH (list_ent,list,db_cmd_next) {
|
2007-09-22 22:40:20 +04:00
|
|
|
if (list_ent->db_cmd == cmd_tbl){
|
|
|
|
TAILQ_REMOVE(list,
|
|
|
|
list_ent,db_cmd_next);
|
|
|
|
free(list_ent,M_TEMP);
|
2007-10-02 12:47:26 +04:00
|
|
|
return 0;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
2007-10-02 02:01:38 +04:00
|
|
|
}
|
2007-10-02 12:47:26 +04:00
|
|
|
return ENOENT;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
2007-10-02 02:01:38 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*This function is called from machine trap code.*/
|
2002-02-15 10:33:48 +03:00
|
|
|
void
|
|
|
|
db_command_loop(void)
|
|
|
|
{
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
label_t db_jmpbuf;
|
|
|
|
label_t *savejmp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize 'prev' and 'next' to dot.
|
|
|
|
*/
|
|
|
|
db_prev = db_dot;
|
|
|
|
db_next = db_dot;
|
|
|
|
|
2007-09-24 03:55:54 +04:00
|
|
|
db_cmd_loop_done = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2007-09-23 23:51:20 +04:00
|
|
|
/*Init default command tables add machine, base,
|
|
|
|
show command tables to the list*/
|
2007-09-24 03:55:54 +04:00
|
|
|
db_init_commands();
|
2007-09-23 23:51:20 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*save context for return from ddb*/
|
2002-02-15 10:33:48 +03:00
|
|
|
savejmp = db_recover;
|
|
|
|
db_recover = &db_jmpbuf;
|
|
|
|
(void) setjmp(&db_jmpbuf);
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*Execute default ddb start commands*/
|
2005-11-27 16:05:28 +03:00
|
|
|
db_execute_commandlist(db_cmd_on_enter);
|
2005-11-26 15:16:44 +03:00
|
|
|
|
2007-10-08 19:06:26 +04:00
|
|
|
(void) setjmp(&db_jmpbuf);
|
2002-02-15 10:33:48 +03:00
|
|
|
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());
|
|
|
|
#else
|
|
|
|
db_printf("db> ");
|
|
|
|
#endif
|
|
|
|
(void) db_read_line();
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
db_command(&db_last_command);
|
2002-02-15 10:33:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
db_recover = savejmp;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
2007-09-22 22:40:20 +04:00
|
|
|
* 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
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static int
|
2007-09-22 22:40:20 +04:00
|
|
|
db_cmd_search(const char *name,const struct db_command *table,
|
2002-02-15 10:33:48 +03:00
|
|
|
const struct db_command **cmdp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2001-01-17 22:50:03 +03:00
|
|
|
const struct db_command *cmd;
|
1994-03-23 23:00:56 +03:00
|
|
|
int result = CMD_NONE;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
for (cmd = table; cmd->name != 0; cmd++) {
|
2002-02-15 10:33:48 +03:00
|
|
|
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++;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2002-02-15 10:33:48 +03:00
|
|
|
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;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*
|
|
|
|
*List commands to the console.
|
|
|
|
*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-09-22 22:40:20 +04:00
|
|
|
db_cmd_list(const struct db_cmd_tbl_en_head *list)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
struct db_cmd_tbl_en *list_ent;
|
|
|
|
const struct db_command *table;
|
2007-10-02 12:47:26 +04:00
|
|
|
size_t i, j, w, columns, lines, numcmds, width=0;
|
2001-01-17 22:50:03 +03:00
|
|
|
const char *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
TAILQ_FOREACH(list_ent,list,db_cmd_next) {
|
|
|
|
table = list_ent->db_cmd;
|
|
|
|
for (i = 0; table[i].name != NULL; i++) {
|
2007-09-22 22:40:20 +04:00
|
|
|
w = strlen(table[i].name);
|
|
|
|
if (w > width)
|
|
|
|
width = w;
|
|
|
|
}
|
1999-10-28 10:37:32 +04:00
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
|
1999-10-28 10:37:32 +04:00
|
|
|
width = DB_NEXT_TAB(width);
|
|
|
|
|
|
|
|
columns = db_max_width / width;
|
|
|
|
if (columns == 0)
|
|
|
|
columns = 1;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
TAILQ_FOREACH(list_ent,list,db_cmd_next) {
|
|
|
|
table = list_ent->db_cmd;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
for (numcmds = 0; table[numcmds].name != NULL; numcmds++)
|
|
|
|
;
|
|
|
|
lines = (numcmds + columns - 1) / columns;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
for (j = 0; j < columns; j++) {
|
|
|
|
p = table[j * lines + i].name;
|
|
|
|
if (p)
|
|
|
|
db_printf("%s", p);
|
2007-10-02 12:47:26 +04:00
|
|
|
if (j * lines + i + lines >= numcmds) {
|
2007-09-22 22:40:20 +04:00
|
|
|
db_putchar('\n');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p) {
|
|
|
|
w = strlen(p);
|
|
|
|
while (w < width) {
|
|
|
|
w = DB_NEXT_TAB(w);
|
|
|
|
db_putchar('\t');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*Returns type of list for command with name *name.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
/* search for the command name */
|
|
|
|
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
|
2007-09-22 22:40:20 +04:00
|
|
|
*/
|
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
error = db_cmd_search(name, list_ent->db_cmd, &cmd);
|
|
|
|
|
|
|
|
if (error == CMD_UNIQUE) {
|
|
|
|
/* exact match found */
|
|
|
|
if (cmd->flag == CS_SHOW) {
|
|
|
|
ret = DDB_SHOW_CMD;
|
1999-10-28 10:37:32 +04:00
|
|
|
break;
|
|
|
|
}
|
2007-10-02 12:47:26 +04:00
|
|
|
if (cmd->flag == CS_MACH) {
|
|
|
|
ret = DDB_MACH_CMD;
|
2007-09-22 22:40:20 +04:00
|
|
|
break;
|
|
|
|
} else {
|
2007-10-02 12:47:26 +04:00
|
|
|
ret = DDB_BASE_CMD;
|
2007-09-22 22:40:20 +04:00
|
|
|
break;
|
1999-10-28 10:37:32 +04:00
|
|
|
}
|
2007-10-02 12:47:26 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
} else if (error == CMD_FOUND){
|
2007-10-02 12:47:26 +04:00
|
|
|
/*
|
|
|
|
* partial match, search will continue, but
|
|
|
|
* note current result in case we won't
|
|
|
|
* find anything better.
|
|
|
|
*/
|
2007-09-22 22:40:20 +04:00
|
|
|
if (cmd->flag == CS_SHOW)
|
2007-10-02 12:47:26 +04:00
|
|
|
ret = DDB_SHOW_CMD;
|
2007-09-22 22:40:20 +04:00
|
|
|
if (cmd->flag == CS_MACH)
|
2007-10-02 12:47:26 +04:00
|
|
|
ret = DDB_MACH_CMD;
|
2007-09-22 22:40:20 +04:00
|
|
|
else
|
2007-10-02 12:47:26 +04:00
|
|
|
ret = DDB_BASE_CMD;
|
1999-10-28 10:37:32 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2007-09-24 03:55:54 +04:00
|
|
|
|
2007-10-02 12:47:26 +04:00
|
|
|
return ret;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*
|
|
|
|
*Parse command line and execute apropriate function.
|
|
|
|
*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-09-22 22:40:20 +04:00
|
|
|
db_command(const struct db_command **last_cmdp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2007-09-22 22:40:20 +04:00
|
|
|
const struct db_command *command;
|
|
|
|
struct db_cmd_tbl_en *list_ent;
|
|
|
|
struct db_cmd_tbl_en_head *list;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
int t;
|
2007-09-22 22:40:20 +04:00
|
|
|
int result;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
char modif[TOK_STRING_SIZE];
|
|
|
|
db_expr_t addr, count;
|
2007-02-22 09:34:42 +03:00
|
|
|
bool have_addr = false;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
static db_expr_t last_count = 0;
|
|
|
|
|
|
|
|
command = NULL; /* XXX gcc */
|
2006-05-11 01:53:14 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
t = db_read_token();
|
2000-04-14 02:48:29 +04:00
|
|
|
if ((t == tEOL) || (t == tCOMMA)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
2002-02-15 10:33:48 +03:00
|
|
|
* An empty line repeats last command, at 'next'.
|
|
|
|
* Only a count repeats the last command with the new count.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2007-09-22 22:40:20 +04:00
|
|
|
command = *last_cmdp;
|
|
|
|
|
|
|
|
if (!command)
|
|
|
|
return;
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
addr = (db_expr_t)db_next;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (t == tCOMMA) {
|
2002-02-15 10:33:48 +03:00
|
|
|
if (!db_expression(&count)) {
|
|
|
|
db_printf("Count missing\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
count = last_count;
|
2007-02-22 09:34:42 +03:00
|
|
|
have_addr = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
modif[0] = '\0';
|
|
|
|
db_skip_to_eol();
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
} else if (t == tEXCL) {
|
|
|
|
db_fncall(0, 0, 0, NULL);
|
|
|
|
return;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
} else if (t != tIDENT) {
|
|
|
|
db_printf("?\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
} else {
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
/* need to read show subcommand if show command list
|
|
|
|
is used. */
|
|
|
|
t = db_read_token();
|
|
|
|
|
|
|
|
if (t != tIDENT) {
|
|
|
|
/* if only show command is executed, print
|
|
|
|
all subcommands */
|
|
|
|
db_cmd_list(list);
|
2002-02-15 10:33:48 +03:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DDB_MACH_CMD:
|
|
|
|
list=&db_mach_cmd_list;
|
|
|
|
/* need to read machine subcommand if
|
|
|
|
machine level 2 command list is used. */
|
|
|
|
t = db_read_token();
|
|
|
|
|
|
|
|
if (t != tIDENT) {
|
|
|
|
/* if only show command is executed, print
|
|
|
|
all subcommands */
|
|
|
|
db_cmd_list(list);
|
2002-02-15 10:33:48 +03:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
2007-09-22 22:40:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
db_printf("No such command\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
COMPAT_RET:
|
|
|
|
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 a single command
|
|
|
|
name is possible */
|
|
|
|
if (result == CMD_UNIQUE)
|
2002-02-15 10:33:48 +03:00
|
|
|
break;
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
}
|
2007-09-23 23:51:20 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*check compatibility flag*/
|
2007-09-23 23:51:20 +04:00
|
|
|
if (command && command->flag & CS_COMPAT){
|
2007-09-22 22:40:20 +04:00
|
|
|
t = db_read_token();
|
|
|
|
if (t != tIDENT) {
|
|
|
|
db_cmd_list(list);
|
2002-02-15 10:33:48 +03:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/* support only level 2 commands here */
|
|
|
|
goto COMPAT_RET;
|
2007-09-23 23:51:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!command) {
|
|
|
|
db_printf("No such command\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
if ((command->flag & CS_OWN) == 0) {
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
|
|
|
* Standard syntax:
|
|
|
|
* command [/modifier] [addr] [,count]
|
|
|
|
*/
|
2007-09-22 22:40:20 +04:00
|
|
|
t = db_read_token(); /* get modifier */
|
|
|
|
if (t == tSLASH) {
|
2002-02-15 10:33:48 +03:00
|
|
|
t = db_read_token();
|
|
|
|
if (t != tIDENT) {
|
|
|
|
db_printf("Bad modifier\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
/* save modifier */
|
2003-05-16 20:28:30 +04:00
|
|
|
strlcpy(modif, db_tok_string, sizeof(modif));
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
} else {
|
|
|
|
db_unread_token(t);
|
|
|
|
modif[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
if (db_expression(&addr)) { /*get address*/
|
2002-02-15 10:33:48 +03:00
|
|
|
db_dot = (db_addr_t) addr;
|
|
|
|
db_last_addr = db_dot;
|
2007-02-22 09:34:42 +03:00
|
|
|
have_addr = true;
|
2002-02-15 10:33:48 +03:00
|
|
|
} else {
|
|
|
|
addr = (db_expr_t) db_dot;
|
2007-02-22 09:34:42 +03:00
|
|
|
have_addr = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
t = db_read_token();
|
2007-09-22 22:40:20 +04:00
|
|
|
if (t == tCOMMA) { /*Get count*/
|
2002-02-15 10:33:48 +03:00
|
|
|
if (!db_expression(&count)) {
|
|
|
|
db_printf("Count missing\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
} else {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_unread_token(t);
|
|
|
|
count = -1;
|
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
if ((command->flag & CS_MORE) == 0) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_skip_to_eol();
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
2007-09-22 22:40:20 +04:00
|
|
|
|
|
|
|
if (command->flag & CS_NOREPEAT) {
|
|
|
|
*last_cmdp = NULL;
|
|
|
|
last_count = 0;
|
|
|
|
} else {
|
|
|
|
*last_cmdp = command;
|
|
|
|
last_count = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command != NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
2002-02-15 10:33:48 +03:00
|
|
|
* Execute the command.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2007-09-22 22:40:20 +04:00
|
|
|
(*command->fcn)(addr, have_addr, count, modif);
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
if (command->flag & CS_SET_DOT) {
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
|
|
|
* 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;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
/*
|
|
|
|
* 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();
|
|
|
|
/* is there another command after the "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;
|
|
|
|
/* read the show subcommand */
|
|
|
|
t = db_read_token();
|
|
|
|
|
|
|
|
if (t != tIDENT) {
|
|
|
|
/* no subcommand, print the list */
|
|
|
|
db_cmd_list(list);
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case DDB_MACH_CMD:
|
|
|
|
list=&db_mach_cmd_list;
|
|
|
|
/* read machine subcommand */
|
|
|
|
t = db_read_token();
|
|
|
|
|
|
|
|
if (t != tIDENT) {
|
|
|
|
/* no subcommand - just print the list */
|
|
|
|
db_cmd_list(list);
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2007-10-02 02:01:38 +04:00
|
|
|
|
2007-09-22 22:40:20 +04:00
|
|
|
default:
|
|
|
|
db_printf("No such command\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
COMPAT_RET:
|
|
|
|
TAILQ_FOREACH(list_ent,list,db_cmd_next){
|
|
|
|
result = db_cmd_search(db_tok_string, list_ent->db_cmd,
|
|
|
|
&help);
|
|
|
|
/* after CMD_UNIQUE only a single command
|
|
|
|
name is possible */
|
|
|
|
if (result == CMD_UNIQUE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef DDB_VERBOSE_HELP
|
|
|
|
/*print help*/
|
|
|
|
|
|
|
|
db_printf("Command: %s\n",help->name);
|
|
|
|
|
|
|
|
if (help->cmd_descr != NULL)
|
|
|
|
db_printf(" Description: %s\n",help->cmd_descr);
|
|
|
|
|
|
|
|
if (help->cmd_arg != NULL)
|
|
|
|
db_printf(" Arguments: %s\n",help->cmd_arg);
|
|
|
|
|
|
|
|
if (help->cmd_arg_help != NULL)
|
|
|
|
db_printf(" Arguments description:\n%s\n",
|
|
|
|
help->cmd_arg_help);
|
|
|
|
|
|
|
|
if ((help->cmd_arg == NULL) && (help->cmd_descr == NULL))
|
|
|
|
db_printf("%s Doesn't have any help message included.\n",
|
|
|
|
help->name);
|
|
|
|
#endif
|
|
|
|
/* check compatibility flag */
|
|
|
|
/*
|
|
|
|
* The "show all" command table has been merged with the
|
|
|
|
* "show" command table - but we want to keep the old UI
|
|
|
|
* available. So if we find a CS_COMPAT entry, we read
|
|
|
|
* the next token and try again.
|
|
|
|
*/
|
|
|
|
if (help->flag == CS_COMPAT){
|
|
|
|
t = db_read_token();
|
|
|
|
|
|
|
|
if (t != tIDENT){
|
|
|
|
db_cmd_list(list);
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto COMPAT_RET;
|
|
|
|
/* support only level 2 commands here */
|
|
|
|
} else {
|
|
|
|
db_skip_to_eol();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else /* t != tIDENT */
|
|
|
|
/* print base commands */
|
|
|
|
db_cmd_list(&db_base_cmd_list);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
1993-07-15 22:35:00 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_map_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
|
2006-10-12 05:30:41 +04:00
|
|
|
const char *modif)
|
1993-07-15 22:35:00 +04:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
1993-07-15 22:35:00 +04:00
|
|
|
|
2007-02-22 09:34:42 +03:00
|
|
|
if (have_addr == false)
|
2002-08-26 15:34:27 +04:00
|
|
|
addr = (db_expr_t)(intptr_t) kernel_map;
|
2001-06-03 04:32:25 +04:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
uvm_map_printit((struct vm_map *)(intptr_t) addr, full, db_printf);
|
1993-07-15 22:35:00 +04:00
|
|
|
}
|
|
|
|
|
2001-08-17 05:00:10 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_malloc_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2001-08-17 05:00:10 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2001-08-17 05:00:10 +04:00
|
|
|
#ifdef MALLOC_DEBUG
|
|
|
|
if (!have_addr)
|
|
|
|
addr = 0;
|
|
|
|
|
|
|
|
debug_malloc_printit(db_printf, (vaddr_t) addr);
|
|
|
|
#else
|
|
|
|
db_printf("The kernel is not built with the MALLOC_DEBUG option.\n");
|
|
|
|
#endif /* MALLOC_DEBUG */
|
|
|
|
}
|
|
|
|
|
1993-07-15 22:35:00 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_object_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1993-07-15 22:35:00 +04:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
1993-07-15 22:35:00 +04:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
uvm_object_printit((struct uvm_object *)(intptr_t) addr, full,
|
|
|
|
db_printf);
|
1998-02-05 10:59:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_page_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1998-02-05 10:59:28 +03:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
1998-02-05 10:59:28 +03:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
uvm_page_printit((struct vm_page *)(intptr_t) addr, full, db_printf);
|
1993-07-15 22:35:00 +04:00
|
|
|
}
|
|
|
|
|
2006-02-19 21:52:29 +03:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_show_all_pages(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2006-02-19 21:52:29 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
uvm_page_printall(db_printf);
|
|
|
|
}
|
|
|
|
|
2000-04-10 06:22:13 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_buf_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2000-04-10 06:22:13 +04:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2000-04-10 06:22:13 +04:00
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
2000-04-10 06:22:13 +04:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
vfs_buf_print((struct buf *)(intptr_t) addr, full, db_printf);
|
2000-04-10 06:22:13 +04:00
|
|
|
}
|
|
|
|
|
2002-02-15 14:18:26 +03:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_event_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2002-02-15 14:18:26 +03:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 14:18:26 +03:00
|
|
|
|
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
2002-02-15 14:18:26 +03:00
|
|
|
|
|
|
|
event_print(full, db_printf);
|
|
|
|
}
|
|
|
|
|
2000-04-10 06:22:13 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_vnode_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2000-04-10 06:22:13 +04:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2000-04-10 06:22:13 +04:00
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
2000-04-10 06:22:13 +04:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
vfs_vnode_print((struct vnode *)(intptr_t) addr, full, db_printf);
|
2000-04-10 06:22:13 +04:00
|
|
|
}
|
|
|
|
|
2003-11-18 21:26:18 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_mount_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2003-11-18 21:26:18 +03:00
|
|
|
{
|
2007-02-22 09:34:42 +03:00
|
|
|
bool full = false;
|
2003-11-18 21:26:18 +03:00
|
|
|
|
|
|
|
if (modif[0] == 'f')
|
2007-02-22 09:34:42 +03:00
|
|
|
full = true;
|
2003-11-18 21:26:18 +03:00
|
|
|
|
|
|
|
vfs_mount_print((struct mount *)(intptr_t) addr, full, db_printf);
|
|
|
|
}
|
|
|
|
|
2006-01-24 16:02:57 +03:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_mbuf_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2006-01-24 16:02:57 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
m_print((const struct mbuf *)(intptr_t) addr, modif, db_printf);
|
|
|
|
}
|
|
|
|
|
1999-05-11 01:13:05 +04:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_pool_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1999-05-11 01:13:05 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
pool_printit((struct pool *)(intptr_t) addr, modif, db_printf);
|
2000-11-24 10:25:50 +03:00
|
|
|
}
|
1999-05-11 01:13:05 +04:00
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_namecache_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2000-11-24 10:25:50 +03:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2002-08-26 15:34:27 +04:00
|
|
|
namecache_print((struct vnode *)(intptr_t) addr, db_printf);
|
2000-11-24 10:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_uvmexp_print_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
uvmexp_print(db_printf);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2007-02-10 00:55:00 +03:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_lock_print_cmd(db_expr_t addr, bool have_addr,
|
2007-02-10 00:55:00 +03:00
|
|
|
db_expr_t count, const char *modif)
|
|
|
|
{
|
|
|
|
|
|
|
|
lockdebug_lock_print((void *)addr, db_printf);
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Call random function:
|
|
|
|
* !expr(arg,arg,arg)
|
|
|
|
*/
|
1996-02-05 04:56:47 +03:00
|
|
|
/*ARGSUSED*/
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_fncall(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
db_expr_t fn_addr;
|
|
|
|
#define MAXARGS 11
|
|
|
|
db_expr_t args[MAXARGS];
|
|
|
|
int nargs = 0;
|
|
|
|
db_expr_t retval;
|
2002-02-15 10:33:48 +03:00
|
|
|
db_expr_t (*func)(db_expr_t, ...);
|
1993-03-21 12:45:37 +03:00
|
|
|
int t;
|
|
|
|
|
|
|
|
if (!db_expression(&fn_addr)) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_printf("Bad function\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2002-08-26 15:34:27 +04:00
|
|
|
func = (db_expr_t (*)(db_expr_t, ...))(intptr_t) fn_addr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
t = db_read_token();
|
|
|
|
if (t == tLPAREN) {
|
2002-02-15 10:33:48 +03:00
|
|
|
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");
|
1993-03-21 12:45:37 +03:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
db_skip_to_eol();
|
|
|
|
|
|
|
|
while (nargs < MAXARGS) {
|
2002-02-15 10:33:48 +03:00
|
|
|
args[nargs++] = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
retval = (*func)(args[0], args[1], args[2], args[3], args[4],
|
1996-03-31 01:30:03 +03:00
|
|
|
args[5], args[6], args[7], args[8], args[9]);
|
2000-06-06 09:06:25 +04:00
|
|
|
db_printf("%s\n", db_num_to_str(retval));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-09-11 10:55:56 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_reboot_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1997-09-11 10:55:56 +04:00
|
|
|
{
|
|
|
|
db_expr_t bootflags;
|
|
|
|
|
|
|
|
/* Flags, default to RB_AUTOBOOT */
|
|
|
|
if (!db_expression(&bootflags))
|
|
|
|
bootflags = (db_expr_t)RB_AUTOBOOT;
|
|
|
|
if (db_read_token() != tEOL) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_error("?\n");
|
|
|
|
/*NOTREACHED*/
|
1997-09-11 10:55:56 +04:00
|
|
|
}
|
2000-06-10 20:31:42 +04:00
|
|
|
/*
|
|
|
|
* 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;
|
1997-09-11 10:55:56 +04:00
|
|
|
cpu_reboot((int)bootflags, NULL);
|
|
|
|
}
|
1999-10-28 10:37:32 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_sifting_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
2000-05-22 18:49:10 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
if (t == tIDENT)
|
2000-05-22 18:49:10 +04:00
|
|
|
db_sifting(db_tok_string, mode);
|
|
|
|
else {
|
|
|
|
db_printf("Bad argument (non-string)\n");
|
|
|
|
db_flush_lex();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_stack_trace_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
|
2000-05-26 07:34:24 +04:00
|
|
|
{
|
2005-06-01 16:25:27 +04:00
|
|
|
register const char *cp = modif;
|
2003-05-15 17:18:18 +04:00
|
|
|
register char c;
|
|
|
|
void (*pr)(const char *, ...);
|
|
|
|
|
|
|
|
pr = db_printf;
|
|
|
|
while ((c = *cp++) != 0)
|
|
|
|
if (c == 'l')
|
|
|
|
pr = printf;
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2000-05-26 07:34:24 +04:00
|
|
|
if (count == -1)
|
|
|
|
count = 65535;
|
|
|
|
|
2003-05-15 17:18:18 +04:00
|
|
|
db_stack_trace_print(addr, have_addr, count, modif, pr);
|
2000-05-26 07:34:24 +04:00
|
|
|
}
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static void
|
2007-02-22 07:38:02 +03:00
|
|
|
db_sync_cmd(db_expr_t addr, bool have_addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
db_expr_t count, const char *modif)
|
1999-10-28 10:37:32 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
2000-06-10 20:31:42 +04:00
|
|
|
/*
|
|
|
|
* 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;
|
1999-10-28 10:37:32 +04:00
|
|
|
cpu_reboot(RB_DUMP, NULL);
|
|
|
|
}
|