DDB prototype changes.

This commit is contained in:
christos 1996-02-05 01:56:47 +00:00
parent bcabcefdcd
commit 8c2e3b4b11
25 changed files with 423 additions and 175 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_aout.c,v 1.12 1994/10/09 08:19:31 mycroft Exp $ */
/* $NetBSD: db_aout.c,v 1.13 1996/02/05 01:56:47 christos Exp $ */
/*
* Mach Operating System
@ -34,6 +34,8 @@
#include <machine/db_machdep.h> /* data types */
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
#include <ddb/db_extern.h>
#ifndef DB_NO_AOUT
@ -62,18 +64,19 @@ int db_symtab[SYMTAB_SPACE/sizeof(int)] = { 0, 1 };
/*
* Find the symbol table and strings; tell ddb about them.
*/
void
X_db_sym_init(symtab, esymtab, name)
int * symtab; /* pointer to start of symbol table */
char * esymtab; /* pointer to end of string table,
int *symtab; /* pointer to start of symbol table */
char *esymtab; /* pointer to end of string table,
for checking - rounded up to integer
boundary */
char * name;
char *name;
{
register struct nlist *sym_start, *sym_end;
register struct nlist *sp;
register char * strtab;
register int strlen;
char * estrtab;
register char *strtab;
register int slen;
char *estrtab;
#ifdef SYMTAB_SPACE
if (*symtab < sizeof(int)) {
@ -90,17 +93,17 @@ X_db_sym_init(symtab, esymtab, name)
sym_end = (struct nlist *)((char *)sym_start + *symtab);
strtab = (char *)sym_end;
strlen = *(int *)strtab;
slen = *(int *)strtab;
#ifdef SYMTAB_SPACE
printf("DDB: found symbols [%d + %d bytes]\n",
*symtab, strlen);
if ((*symtab + strlen) > db_symtabsize) {
*symtab, slen);
if ((*symtab + slen) > db_symtabsize) {
printf("DDB: symbols larger than SYMTAB_SPACE?\n");
return;
}
#else
estrtab = strtab + strlen;
estrtab = strtab + slen;
#define round_to_size(x) \
(((vm_offset_t)(x) + sizeof(vm_size_t) - 1) & ~(sizeof(vm_size_t) - 1))
@ -117,7 +120,7 @@ X_db_sym_init(symtab, esymtab, name)
register int strx;
strx = sp->n_un.n_strx;
if (strx != 0) {
if (strx > strlen) {
if (strx > slen) {
db_printf("Bad string table index (%#x)\n", strx);
sp->n_un.n_name = 0;
continue;
@ -183,10 +186,10 @@ X_db_search_symbol(symtab, off, strategy, diffp)
diff = off - sp->n_value;
symp = sp;
if (diff == 0 &&
(strategy == DB_STGY_PROC &&
sp->n_type == (N_TEXT|N_EXT) ||
strategy == DB_STGY_ANY &&
(sp->n_type & N_EXT)))
((strategy == DB_STGY_PROC &&
sp->n_type == (N_TEXT|N_EXT)) ||
(strategy == DB_STGY_ANY &&
(sp->n_type & N_EXT))))
break;
}
else if (off - sp->n_value == diff) {
@ -235,7 +238,6 @@ X_db_line_at_pc(symtab, cursym, filename, linenum, off)
db_expr_t off;
{
register struct nlist *sp, *ep;
register struct nlist *sym = (struct nlist *)cursym;
unsigned long sodiff = -1UL, lndiff = -1UL, ln = 0;
char *fname = NULL;
@ -333,6 +335,7 @@ X_db_sym_numargs(symtab, cursym, nargp, argnamep)
/*
* Initialization routine for a.out files.
*/
void
ddb_init()
{
#ifndef SYMTAB_SPACE

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_break.c,v 1.5 1994/10/09 08:19:32 mycroft Exp $ */
/* $NetBSD: db_break.c,v 1.6 1996/02/05 01:56:50 christos Exp $ */
/*
* Mach Operating System
@ -38,10 +38,10 @@
#include <machine/db_machdep.h> /* type definitions */
#include <ddb/db_lex.h>
#include <ddb/db_break.h>
#include <ddb/db_access.h>
#include <ddb/db_sym.h>
#include <ddb/db_break.h>
#include <ddb/db_output.h>
#define NBREAKPOINTS 100
struct db_breakpoint db_break_table[NBREAKPOINTS];
@ -286,8 +286,13 @@ db_breakpoint_cmd(addr, have_addr, count, modif)
}
/* list breakpoints */
/*ARGSUSED*/
void
db_listbreak_cmd()
db_listbreak_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
db_list_breakpoints();
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_break.h,v 1.7 1994/10/09 08:29:58 mycroft Exp $ */
/* $NetBSD: db_break.h,v 1.8 1996/02/05 01:56:52 christos Exp $ */
/*
* Mach Operating System
@ -49,16 +49,22 @@ typedef struct db_breakpoint {
struct db_breakpoint *link; /* link in in-use or free chain */
} *db_breakpoint_t;
db_breakpoint_t db_find_breakpoint __P((vm_map_t, db_addr_t));
db_breakpoint_t db_find_breakpoint_here __P((db_addr_t));
db_breakpoint_t db_breakpoint_alloc __P((void));
void db_breakpoint_free __P((db_breakpoint_t));
void db_set_breakpoint __P((vm_map_t, db_addr_t, int));
void db_delete_breakpoint __P((vm_map_t, db_addr_t));
db_breakpoint_t db_find_breakpoint __P((vm_map_t, db_addr_t));
db_breakpoint_t db_find_breakpoint_here __P((db_addr_t));
void db_set_breakpoints __P((void));
void db_clear_breakpoints __P((void));
db_breakpoint_t db_set_temp_breakpoint __P((db_addr_t));
db_breakpoint_t db_set_temp_breakpoint __P((db_addr_t));
void db_delete_temp_breakpoint __P((db_breakpoint_t));
void db_list_breakpoints __P((void));
void db_delete_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_breakpoint_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_listbreak_cmd __P((db_expr_t, int, db_expr_t, char *));
boolean_t db_map_equal __P((vm_map_t, vm_map_t));
boolean_t db_map_current __P((vm_map_t));
vm_map_t db_map_addr __P((vm_offset_t));
#endif _DDB_DB_BREAK_H_
#endif /* _DDB_DB_BREAK_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_command.c,v 1.15 1995/10/26 14:52:33 gwr Exp $ */
/* $NetBSD: db_command.c,v 1.16 1996/02/05 01:56:53 christos Exp $ */
/*
* Mach Operating System
@ -32,13 +32,20 @@
#include <sys/param.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <machine/db_machdep.h> /* type definitions */
#include <ddb/db_lex.h>
#include <ddb/db_output.h>
#include <ddb/db_command.h>
#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>
#include <vm/vm.h>
#include <setjmp.h>
@ -148,7 +155,7 @@ db_command(last_cmdp, cmd_table)
int t;
char modif[TOK_STRING_SIZE];
db_expr_t addr, count;
boolean_t have_addr;
boolean_t have_addr = FALSE;
int result;
t = db_read_token();
@ -161,8 +168,7 @@ db_command(last_cmdp, cmd_table)
modif[0] = '\0';
}
else if (t == tEXCL) {
void db_fncall();
db_fncall();
db_fncall(0, 0, 0, NULL);
return;
}
else if (t != tIDENT) {
@ -287,13 +293,12 @@ db_map_print_cmd(addr, have_addr, count, modif)
db_expr_t count;
char * modif;
{
extern void _vm_map_print();
boolean_t full = FALSE;
if (modif[0] == 'f')
full = TRUE;
_vm_map_print((vm_map_t)addr, full, db_printf);
_vm_map_print((vm_map_t) addr, full, db_printf);
}
/*ARGSUSED*/
@ -304,82 +309,64 @@ db_object_print_cmd(addr, have_addr, count, modif)
db_expr_t count;
char * modif;
{
extern void _vm_object_print();
boolean_t full = FALSE;
if (modif[0] == 'f')
full = TRUE;
_vm_object_print((vm_object_t)addr, full, db_printf);
_vm_object_print((vm_object_t) addr, full, db_printf);
}
/*
* 'show' commands
*/
extern void db_show_all_procs();
extern void db_show_callout();
extern void db_listbreak_cmd();
extern void db_listwatch_cmd();
extern void db_show_regs();
void db_show_help();
struct db_command db_show_all_cmds[] = {
{ "procs", db_show_all_procs,0, 0 },
{ "callout", db_show_callout,0, 0 },
{ (char *)0 }
{ "procs", db_show_all_procs, 0, NULL },
{ "callout", db_show_callout, 0, NULL },
{ NULL, NULL, 0, NULL }
};
struct db_command db_show_cmds[] = {
{ "all", 0, 0, db_show_all_cmds },
{ "registers", db_show_regs, 0, 0 },
{ "breaks", db_listbreak_cmd, 0, 0 },
{ "watches", db_listwatch_cmd, 0, 0 },
{ "map", db_map_print_cmd, 0, 0 },
{ "object", db_object_print_cmd, 0, 0 },
{ (char *)0, }
{ "all", NULL, 0, db_show_all_cmds },
{ "registers", db_show_regs, 0, NULL },
{ "breaks", db_listbreak_cmd, 0, NULL },
{ "watches", db_listwatch_cmd, 0, NULL },
{ "map", db_map_print_cmd, 0, NULL },
{ "object", db_object_print_cmd, 0, NULL },
{ NULL, NULL, 0, NULL, }
};
extern void db_print_cmd(), db_examine_cmd(), db_set_cmd();
extern void db_search_cmd();
extern void db_write_cmd();
extern void db_delete_cmd(), db_breakpoint_cmd();
extern void db_deletewatch_cmd(), db_watchpoint_cmd();
extern void db_single_step_cmd(), db_trace_until_call_cmd(),
db_trace_until_matching_cmd(), db_continue_cmd();
extern void db_stack_trace_cmd();
void db_help_cmd();
void db_fncall();
struct db_command db_command_table[] = {
#ifdef DB_MACHINE_COMMANDS
/* this must be the first entry, if it exists */
{ "machine", 0, 0, 0},
{ "machine", NULL, 0, NULL},
#endif
{ "print", db_print_cmd, 0, 0 },
{ "examine", db_examine_cmd, CS_SET_DOT, 0 },
{ "x", db_examine_cmd, CS_SET_DOT, 0 },
{ "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 },
{ "set", db_set_cmd, CS_OWN, 0 },
{ "write", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
{ "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
{ "delete", db_delete_cmd, 0, 0 },
{ "d", db_delete_cmd, 0, 0 },
{ "break", db_breakpoint_cmd, 0, 0 },
{ "dwatch", db_deletewatch_cmd, 0, 0 },
{ "watch", db_watchpoint_cmd, CS_MORE, 0 },
{ "step", db_single_step_cmd, 0, 0 },
{ "s", db_single_step_cmd, 0, 0 },
{ "continue", db_continue_cmd, 0, 0 },
{ "c", db_continue_cmd, 0, 0 },
{ "until", db_trace_until_call_cmd,0, 0 },
{ "next", db_trace_until_matching_cmd,0, 0 },
{ "match", db_trace_until_matching_cmd,0, 0 },
{ "trace", db_stack_trace_cmd, 0, 0 },
{ "call", db_fncall, CS_OWN, 0 },
{ "ps", db_show_all_procs, 0, 0 },
{ "callout", db_show_callout, 0, 0 },
{ "show", 0, 0, db_show_cmds },
{ (char *)0, }
{ "print", db_print_cmd, 0, NULL },
{ "examine", db_examine_cmd, CS_SET_DOT, NULL },
{ "x", db_examine_cmd, CS_SET_DOT, NULL },
{ "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL },
{ "set", db_set_cmd, CS_OWN, NULL },
{ "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
{ "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
{ "delete", db_delete_cmd, 0, NULL },
{ "d", db_delete_cmd, 0, NULL },
{ "break", db_breakpoint_cmd, 0, NULL },
{ "dwatch", db_deletewatch_cmd, 0, NULL },
{ "watch", db_watchpoint_cmd, CS_MORE, NULL },
{ "step", db_single_step_cmd, 0, NULL },
{ "s", db_single_step_cmd, 0, NULL },
{ "continue", db_continue_cmd, 0, NULL },
{ "c", db_continue_cmd, 0, NULL },
{ "until", db_trace_until_call_cmd,0, NULL },
{ "next", db_trace_until_matching_cmd,0, NULL },
{ "match", db_trace_until_matching_cmd,0, NULL },
{ "trace", db_stack_trace_cmd, 0, NULL },
{ "call", db_fncall, CS_OWN, NULL },
{ "ps", db_show_all_procs, 0, NULL },
{ "callout", db_show_callout, 0, NULL },
{ "show", NULL, 0, db_show_cmds },
{ NULL, NULL, 0, NULL }
};
#ifdef DB_MACHINE_COMMANDS
@ -454,15 +441,20 @@ db_error(s)
* Call random function:
* !expr(arg,arg,arg)
*/
/*ARGSUSED*/
void
db_fncall()
db_fncall(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
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 (*func) __P((db_expr_t, ...));
int t;
if (!db_expression(&fn_addr)) {
@ -470,7 +462,7 @@ db_fncall()
db_flush_lex();
return;
}
func = (db_expr_t (*) ()) fn_addr;
func = (db_expr_t (*) __P((db_expr_t, ...))) fn_addr;
t = db_read_token();
if (t == tLPAREN) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_command.h,v 1.7 1994/10/09 08:30:00 mycroft Exp $ */
/* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */
/*
* Mach Operating System
@ -32,10 +32,18 @@
/*
* Command loop declarations.
*/
void db_command_loop __P((void));
void db_skip_to_eol __P((void));
void db_error __P((char *)); /* report error */
struct db_command;
int db_cmd_search __P((char *, struct db_command *, struct db_command **));
void db_cmd_list __P((struct db_command *));
void db_command __P((struct db_command **, struct db_command *));
void db_map_print_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_object_print_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_machine_commands_install __P((struct db_command *));
void db_help_cmd __P((void));
void db_command_loop __P((void));
void db_error __P((char *));
void db_fncall __P((db_expr_t, int, db_expr_t, char *));
db_addr_t db_dot; /* current location */
db_addr_t db_last_addr; /* last explicit address typed */
@ -49,7 +57,8 @@ db_addr_t db_next; /* next address to be examined
*/
struct db_command {
char *name; /* command name */
void (*fcn)(); /* function to call */
/* function to call */
void (*fcn) __P((db_expr_t, int, db_expr_t, char *));
int flag; /* extra info: */
#define CS_OWN 0x1 /* non-standard syntax */
#define CS_MORE 0x2 /* standard syntax, but may have other

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_examine.c,v 1.9 1994/11/17 04:51:50 gwr Exp $ */
/* $NetBSD: db_examine.c,v 1.10 1996/02/05 01:56:57 christos Exp $ */
/*
* Mach Operating System
@ -38,12 +38,12 @@
#include <ddb/db_output.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_access.h>
#include <ddb/db_extern.h>
#include <ddb/db_interface.h>
char db_examine_format[TOK_STRING_SIZE] = "x";
extern db_addr_t db_disasm(/* db_addr_t, boolean_t */);
/* instruction disassembler */
/*
* Examine (print) data. Syntax is:
* x/[bhl][cdiorsuxz]*
@ -69,9 +69,10 @@ db_examine_cmd(addr, have_addr, count, modif)
db_examine((db_addr_t) addr, db_examine_format, count);
}
void
db_examine(addr, fmt, count)
register
db_addr_t addr;
db_addr_t addr;
char * fmt; /* format string */
int count; /* repeat count */
{
@ -225,6 +226,7 @@ db_print_cmd(addr, have_addr, count, modif)
db_printf("\n");
}
void
db_print_loc_and_inst(loc)
db_addr_t loc;
{
@ -233,11 +235,12 @@ db_print_loc_and_inst(loc)
(void) db_disasm(loc, FALSE);
}
void
db_strcpy(dst, src)
register char *dst;
register char *src;
{
while (*dst++ = *src++)
while ((*dst++ = *src++) != '\0')
;
}
@ -245,8 +248,13 @@ db_strcpy(dst, src)
* Search for a value in memory.
* Syntax: search [/bhl] addr value [mask] [,count]
*/
/*ARGSUSED*/
void
db_search_cmd()
db_search_cmd(daddr, have_addr, dcount, modif)
db_expr_t daddr;
int have_addr;
db_expr_t dcount;
char * modif;
{
int t;
db_addr_t addr;
@ -278,11 +286,12 @@ db_search_cmd()
size = 4;
}
if (!db_expression(&addr)) {
if (!db_expression(&value)) {
db_printf("Address missing\n");
db_flush_lex();
return;
}
addr = (db_addr_t) value;
if (!db_expression(&value)) {
db_printf("Value missing\n");
@ -291,7 +300,7 @@ db_search_cmd()
}
if (!db_expression(&mask))
mask = 0xffffffff;
mask = (int) ~0;
t = db_read_token();
if (t == tCOMMA) {
@ -309,6 +318,7 @@ db_search_cmd()
db_search(addr, size, value, mask, count);
}
void
db_search(addr, size, value, mask, count)
register
db_addr_t addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_expr.c,v 1.4 1994/06/29 06:31:06 cgd Exp $ */
/* $NetBSD: db_expr.c,v 1.5 1996/02/05 01:56:58 christos Exp $ */
/*
* Mach Operating System
@ -37,6 +37,9 @@
#include <ddb/db_lex.h>
#include <ddb/db_access.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#include <ddb/db_variables.h>
boolean_t
db_term(valuep)

80
sys/ddb/db_extern.h Normal file
View File

@ -0,0 +1,80 @@
/* $NetBSD: db_extern.h,v 1.1 1996/02/05 01:57:00 christos Exp $ */
/*
* Copyright (c) 1995 Christos Zoulas. All rights reserved.
*
* 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 Christos Zoulas.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#ifndef _DDB_DB_EXTERN_H_
#define _DDB_DB_EXTERN_H_
/* db_aout.c */
void X_db_sym_init __P((int *, char *, char *));
db_sym_t X_db_lookup __P((db_symtab_t *, char *));
db_sym_t X_db_search_symbol __P((db_symtab_t *, db_addr_t, db_strategy_t,
db_expr_t *));
void X_db_symbol_values __P((db_sym_t, char **, db_expr_t *));
void db_printsym __P((db_expr_t, db_strategy_t));
boolean_t X_db_line_at_pc __P((db_symtab_t *, db_sym_t, char **,
int *, db_expr_t));
int X_db_sym_numargs __P((db_symtab_t *, db_sym_t, int *, char **));
void ddb_init __P((void));
/* db_examine.c */
void db_examine_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_examine __P((db_addr_t, char *, int));
void db_print_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_print_loc_and_inst __P((db_addr_t));
void db_strcpy __P((char *, char *));
void db_search_cmd __P((db_expr_t, boolean_t, db_expr_t, char *));
void db_search __P((db_addr_t, int, db_expr_t, db_expr_t, unsigned int));
/* db_expr.c */
boolean_t db_term __P((db_expr_t *));
boolean_t db_unary __P((db_expr_t *));
boolean_t db_mult_expr __P((db_expr_t *));
boolean_t db_add_expr __P((db_expr_t *));
boolean_t db_shift_expr __P((db_expr_t *));
int db_expression __P((db_expr_t *));
/* db_input.c */
void db_putstring __P((char *, int));
void db_putnchars __P((int, int));
void db_delete __P((int, int));
int db_inputchar __P((int));
int db_readline __P((char *, int));
void db_check_interrupt __P((void));
/* db_print.c */
void db_show_regs __P((db_expr_t, boolean_t, db_expr_t, char *));
/* db_trap.c */
void db_trap(int, int);
/* db_write_cmd.c */
void db_write_cmd __P((db_expr_t, boolean_t, db_expr_t, char *));
#endif /* _DDB_DB_EXTERN_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_input.c,v 1.6 1994/10/26 17:57:50 mycroft Exp $ */
/* $NetBSD: db_input.c,v 1.7 1996/02/05 01:57:02 christos Exp $ */
/*
* Mach Operating System
@ -32,7 +32,14 @@
#include <sys/param.h>
#include <sys/proc.h>
#include <machine/db_machdep.h>
#include <ddb/db_output.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#include <dev/cons.h>
/*
* Character input and editing.
@ -53,6 +60,8 @@ char * db_le; /* one past last character */
#define BLANK ' '
#define BACKUP '\b'
static int cnmaygetc __P((void));
void
db_putstring(s, count)
char *s;
@ -240,6 +249,7 @@ db_check_interrupt()
}
}
static int
cnmaygetc ()
{
return (-1);

49
sys/ddb/db_interface.h Normal file
View File

@ -0,0 +1,49 @@
/* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */
/*
* Copyright (c) 1995 Christos Zoulas. All rights reserved.
*
* 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 Christos Zoulas.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#ifndef _DDB_DB_INTERFACE_H_
#define _DDB_DB_INTERFACE_H_
/* arch/<arch>/<arch>/db_trace.c */
void db_stack_trace_cmd __P((db_expr_t, int, db_expr_t, char *));
/* arch/<arch>/<arch>/db_disasm.c */
db_addr_t db_disasm __P((db_addr_t, boolean_t));
/* kern/kern_synch.c */
void db_show_all_procs __P((db_expr_t, int, db_expr_t, char *));
/* kern/kern_clock.c */
void db_show_callout __P((db_expr_t, int, db_expr_t, char *));
/* arch/<arch>/<arch>/db_interface.c */
void db_machine_init __P((void));
#endif /* _DDB_DB_INTERFACE_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_lex.c,v 1.7 1994/10/09 08:56:25 mycroft Exp $ */
/* $NetBSD: db_lex.c,v 1.8 1996/02/05 01:57:05 christos Exp $ */
/*
* Mach Operating System
@ -34,7 +34,13 @@
*/
#include <sys/param.h>
#include <machine/db_machdep.h>
#include <ddb/db_lex.h>
#include <ddb/db_output.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
char db_line[120];
char * db_lp, *db_endlp;
@ -131,7 +137,7 @@ db_lex()
if (c >= '0' && c <= '9') {
/* number */
int r, digit;
int r, digit = 0;
if (c > '0')
r = db_radix;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_lex.h,v 1.6 1994/10/09 08:30:06 mycroft Exp $ */
/* $NetBSD: db_lex.h,v 1.7 1996/02/05 01:57:07 christos Exp $ */
/*
* Mach Operating System
@ -36,9 +36,10 @@ int db_read_line __P((void));
void db_flush_line __P((void));
int db_read_char __P((void));
void db_unread_char __P((int));
int db_read_token __P((void));
void db_unread_token __P((int));
int db_read_token __P((void));
void db_flush_lex __P((void));
int db_lex __P((void));
int db_tok_number;
#define TOK_STRING_SIZE 120

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_output.c,v 1.9 1995/10/16 05:28:16 mycroft Exp $ */
/* $NetBSD: db_output.c,v 1.10 1996/02/05 01:57:08 christos Exp $ */
/*
* Mach Operating System
@ -33,6 +33,16 @@
#include <machine/stdarg.h>
#include <dev/cons.h>
#include <machine/db_machdep.h>
#include <ddb/db_command.h>
#include <ddb/db_output.h>
#include <ddb/db_interface.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
/*
* Character output - tracks position in line.
* To do this correctly, we should know how wide
@ -64,7 +74,9 @@ int db_tab_stop_width = 8; /* how wide are tab stops? */
int db_max_line = DB_MAX_LINE; /* output max lines */
int db_max_width = DB_MAX_WIDTH; /* output line width */
extern void db_check_interrupt();
static void db_more __P((void));
static char *db_ksprintn __P((u_long, int, int *));
static void db_printf_guts __P((const char *, va_list));
/*
* Force pending whitespace.
@ -124,6 +136,7 @@ db_more()
/*
* Output character. Buffer whitespace.
*/
void
db_putchar(c)
int c; /* character to output */
{
@ -187,11 +200,14 @@ extern int db_radix;
/*VARARGS1*/
void
#ifdef __STDC__
db_printf(char *fmt, ...)
#if __STDC__
db_printf(const char *fmt, ...)
#else
db_printf(fmt, va_alist)
char *fmt;
/*###207 [cc] warning: type of `va_alist' defaults to `int'%%%*/
const char *fmt;
/*###208 [cc] parse error before `va_dcl'%%%*/
va_dcl
#endif
{
va_list listp;
@ -204,11 +220,12 @@ db_printf(fmt, va_alist)
/*VARARGS1*/
void
#ifdef __STDC__
kdbprintf(char *fmt, ...)
#if __STDC__
kdbprintf(const char *fmt, ...)
#else
kdbprintf(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list listp;
@ -249,6 +266,7 @@ db_ksprintn(ul, base, lenp)
return (p);
}
static void
db_printf_guts(fmt, ap)
register const char *fmt;
va_list ap;
@ -299,13 +317,14 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 'b':
ul = va_arg(ap, int);
p = va_arg(ap, char *);
for (p = db_ksprintn(ul, *p++, NULL); ch = *p--;)
for (p = db_ksprintn(ul, *p++, NULL);
(ch = *p--) !='\0';)
db_putchar(ch);
if (!ul)
break;
for (tmp = 0; n = *p++;) {
for (tmp = 0; (n = *p++) != '\0';) {
if (ul & (1 << (n - 1))) {
db_putchar(tmp ? ',' : '<');
for (; (n = *p) > ' '; ++p)
@ -333,7 +352,7 @@ reswitch: switch (ch = *(u_char *)fmt++) {
if (!ladjust && width > 0)
while (width--)
db_putchar (padc);
while (ch = *p++)
while ((ch = *p++) != '\0')
db_putchar(ch);
if (ladjust && width > 0)
while (width--)
@ -409,7 +428,7 @@ number: p = (char *)db_ksprintn(ul, base, &tmp);
while (width--)
db_putchar(padc);
while (ch = *p--)
while ((ch = *p--) != '\0')
db_putchar(ch);
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_output.h,v 1.6 1995/10/16 05:28:17 mycroft Exp $ */
/* $NetBSD: db_output.h,v 1.7 1996/02/05 01:57:09 christos Exp $ */
/*
* Mach Operating System
@ -33,6 +33,8 @@
* Printing routines for kernel debugger.
*/
void db_force_whitespace __P((void));
void db_putchar __P((int));
int db_print_position __P((void));
void db_end_line __P((void));
void db_printf __P((const char *, ...));
void kdbprintf __P((const char *, ...));
void db_end_line __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_print.c,v 1.4 1994/06/29 06:31:15 cgd Exp $ */
/* $NetBSD: db_print.c,v 1.5 1996/02/05 01:57:11 christos Exp $ */
/*
* Mach Operating System
@ -40,13 +40,19 @@
#include <ddb/db_lex.h>
#include <ddb/db_variables.h>
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
#include <ddb/db_extern.h>
extern unsigned int db_maxoff;
/*ARGSUSED*/
void
db_show_regs()
db_show_regs(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
int (*func)();
register struct db_variable *regp;
db_expr_t value, offset;
char * name;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_run.c,v 1.7 1994/10/09 08:30:08 mycroft Exp $ */
/* $NetBSD: db_run.c,v 1.8 1996/02/05 01:57:12 christos Exp $ */
/*
* Mach Operating System
@ -41,6 +41,10 @@
#include <ddb/db_lex.h>
#include <ddb/db_break.h>
#include <ddb/db_access.h>
#include <ddb/db_watch.h>
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
int db_run_mode;
#define STEP_NONE 0
@ -255,7 +259,6 @@ db_set_single_step(regs)
*/
inst = db_get_value(pc, sizeof(int), FALSE);
if (inst_branch(inst) || inst_call(inst)) {
extern unsigned getreg_val();
brpc = branch_taken(inst, pc, getreg_val, regs);
if (brpc != pc) { /* self-branches are hopeless */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_run.h,v 1.2 1994/10/09 08:30:12 mycroft Exp $ */
/* $NetBSD: db_run.h,v 1.3 1996/02/05 01:57:14 christos Exp $ */
/*
* Mach Operating System
@ -39,13 +39,18 @@ int db_inst_count;
int db_load_count;
int db_store_count;
boolean_t db_stop_at_pc __P((db_regs_t *, boolean_t *));
void db_restart_at_pc __P((db_regs_t *, boolean_t));
void db_single_step __P((db_regs_t *));
#ifndef db_set_single_step
void db_set_single_step __P((db_regs_t *));
#endif
#ifndef db_clear_single_step
void db_clear_single_step __P((db_regs_t *));
#endif
void db_restart_at_pc __P((db_regs_t *, boolean_t));
boolean_t db_stop_at_pc __P((db_regs_t *, boolean_t *));
void db_single_step_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_trace_until_call_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_trace_until_matching_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_continue_cmd __P((db_expr_t, int, db_expr_t, char *));
#endif _DDB_DB_RUN_

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_sym.c,v 1.11 1995/11/24 22:13:08 cgd Exp $ */
/* $NetBSD: db_sym.c,v 1.12 1996/02/05 01:57:15 christos Exp $ */
/*
* Mach Operating System
@ -32,14 +32,9 @@
#include <machine/db_machdep.h>
#include <ddb/db_sym.h>
/*
* We import from the symbol-table dependent routines:
*/
extern db_sym_t X_db_lookup();
extern db_sym_t X_db_search_symbol();
extern boolean_t X_db_line_at_pc();
extern void X_db_symbol_values();
#include <ddb/db_output.h>
#include <ddb/db_extern.h>
#include <ddb/db_command.h>
/*
* Multiple symbol tables
@ -56,7 +51,7 @@ db_symtab_t db_symtabs[MAXNOSYMTABS] = {{0,},};
db_symtab_t *db_last_symtab;
db_sym_t db_lookup(); /* forward */
static char *db_qualify __P((db_sym_t, char *));
/*
* Add symbol table, with given name, to list of symbol tables.
@ -75,7 +70,7 @@ db_add_symbol_table(start, end, name, ref)
break;
}
if (slot >= MAXNOSYMTABS) {
printf ("No slots left for %s symbol table", name);
db_printf("No slots left for %s symbol table", name);
return(-1);
}
@ -102,7 +97,7 @@ db_del_symbol_table(name)
break;
}
if (slot >= MAXNOSYMTABS) {
printf ("Unable to find symbol table slot for %s.", name);
db_printf("Unable to find symbol table slot for %s.", name);
return;
}
@ -129,11 +124,11 @@ db_qualify(sym, symtabname)
db_symbol_values(sym, &symname, 0);
s = tmp;
while (*s++ = *symtabname++) {
}
while ((*s++ = *symtabname++) != '\0')
;
s[-1] = ':';
while (*s++ = *symname++) {
}
while ((*s++ = *symname++) != '\0')
;
return tmp;
}
@ -142,7 +137,7 @@ boolean_t
db_eqname(src, dst, c)
char *src;
char *dst;
char c;
int c;
{
if (!strcmp(src, dst))
return (TRUE);
@ -324,10 +319,9 @@ db_symbol_values(sym, namep, valuep)
* The variable db_lastsym is used instead of "end" in case we
* add support for symbols in loadable driver modules.
*/
extern char end[];
unsigned long db_lastsym = (long)end;
db_expr_t db_maxoff = 0x10000000;
unsigned int db_lastsym = (unsigned long)end;
db_expr_t db_maxoff = 0x10000000;
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_sym.h,v 1.6 1994/10/09 08:19:41 mycroft Exp $ */
/* $NetBSD: db_sym.h,v 1.7 1996/02/05 01:57:16 christos Exp $ */
/*
* Mach Operating System
@ -75,9 +75,16 @@ int db_add_symbol_table __P((char *, char *, char *, char *));
void db_del_symbol_table __P((char *));
/* remove a symbol table from list */
boolean_t db_eqname __P((char *, char *, int));
/* strcmp, modulo leading char */
int db_value_of_name __P((char *, db_expr_t *));
/* find symbol value given name */
db_sym_t db_lookup __P((char *));
boolean_t db_symbol_is_ambiguous __P((db_sym_t));
db_sym_t db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *));
/* find symbol given value */
@ -92,8 +99,9 @@ void db_symbol_values __P((db_sym_t, char **, db_expr_t *));
db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
/* ditto, but no locals */
int db_eqname __P((char *, char *, char));
/* strcmp, modulo leading char */
void db_printsym __P((db_expr_t, db_strategy_t));
/* print closest symbol to a value */
boolean_t db_line_at_pc __P((db_sym_t, char **, int *, db_expr_t));
int db_sym_numargs __P((db_sym_t, int *, char **));

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_trap.c,v 1.8 1994/12/02 06:07:37 gwr Exp $ */
/* $NetBSD: db_trap.c,v 1.9 1996/02/05 01:57:18 christos Exp $ */
/*
* Mach Operating System
@ -40,7 +40,11 @@
#include <ddb/db_run.h>
#include <ddb/db_command.h>
#include <ddb/db_break.h>
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
void
db_trap(type, code)
int type, code;
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_variables.c,v 1.7 1994/10/09 08:56:28 mycroft Exp $ */
/* $NetBSD: db_variables.c,v 1.8 1996/02/05 01:57:19 christos Exp $ */
/*
* Mach Operating System
@ -33,6 +33,9 @@
#include <ddb/db_lex.h>
#include <ddb/db_variables.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
extern unsigned int db_maxoff;
@ -74,6 +77,7 @@ db_find_variable(varp)
}
db_error("Unknown variable\n");
/*NOTREACHED*/
return 0;
}
int
@ -105,11 +109,12 @@ db_set_variable(value)
}
void
db_read_variable(vp, valuep)
struct db_variable *vp;
db_expr_t *valuep;
{
int (*func)() = vp->fcn;
int (*func) __P((struct db_variable *, db_expr_t *, int)) = vp->fcn;
if (func == FCN_NULL)
*valuep = *(vp->valuep);
@ -117,11 +122,12 @@ db_read_variable(vp, valuep)
(*func)(vp, valuep, DB_VAR_GET);
}
void
db_write_variable(vp, valuep)
struct db_variable *vp;
db_expr_t *valuep;
{
int (*func)() = vp->fcn;
int (*func) __P((struct db_variable *, db_expr_t *, int)) = vp->fcn;
if (func == FCN_NULL)
*(vp->valuep) = *valuep;
@ -129,11 +135,15 @@ db_write_variable(vp, valuep)
(*func)(vp, valuep, DB_VAR_SET);
}
/*ARGSUSED*/
void
db_set_cmd()
db_set_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
db_expr_t value;
int (*func)();
struct db_variable *vp;
int t;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_variables.h,v 1.4 1994/06/29 06:31:24 cgd Exp $ */
/* $NetBSD: db_variables.h,v 1.5 1996/02/05 01:57:21 christos Exp $ */
/*
* Mach Operating System
@ -39,15 +39,22 @@ struct db_variable {
char *name; /* Name of variable */
int *valuep; /* value of variable */
/* function to call when reading/writing */
int (*fcn)(/* db_variable *vp, db_expr_t *valuep, int op */);
int (*fcn) __P((struct db_variable *, db_expr_t *, int));
#define DB_VAR_GET 0
#define DB_VAR_SET 1
};
#define FCN_NULL ((int (*)())0)
#define FCN_NULL ((int (*) __P((struct db_variable *, db_expr_t *, int)))0)
extern struct db_variable db_vars[]; /* debugger variables */
extern struct db_variable *db_evars;
extern struct db_variable db_regs[]; /* machine registers */
extern struct db_variable *db_eregs;
int db_find_variable __P((struct db_variable **));
int db_get_variable __P((db_expr_t *));
int db_set_variable __P((db_expr_t));
void db_read_variable __P((struct db_variable *, db_expr_t *));
void db_write_variable __P((struct db_variable *, db_expr_t *));
void db_set_cmd __P((db_expr_t, int, db_expr_t, char *));
#endif /* _DB_VARIABLES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_watch.c,v 1.7 1994/10/09 08:30:15 mycroft Exp $ */
/* $NetBSD: db_watch.c,v 1.8 1996/02/05 01:57:22 christos Exp $ */
/*
* Mach Operating System
@ -38,7 +38,11 @@
#include <ddb/db_watch.h>
#include <ddb/db_lex.h>
#include <ddb/db_access.h>
#include <ddb/db_run.h>
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
#include <ddb/db_command.h>
#include <ddb/db_extern.h>
/*
* Watchpoints.
@ -198,8 +202,13 @@ db_watchpoint_cmd(addr, have_addr, count, modif)
}
/* list watchpoints */
/*ARGSUSED*/
void
db_listwatch_cmd()
db_listwatch_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
db_list_watchpoints();
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_watch.h,v 1.8 1994/10/09 08:41:20 mycroft Exp $ */
/* $NetBSD: db_watch.h,v 1.9 1996/02/05 01:57:24 christos Exp $ */
/*
* Mach Operating System
@ -42,12 +42,16 @@ typedef struct db_watchpoint {
struct db_watchpoint *link; /* link in in-use or free chain */
} *db_watchpoint_t;
boolean_t db_find_watchpoint __P((vm_map_t, db_addr_t, db_regs_t *));
void db_set_watchpoints __P((void));
void db_clear_watchpoints __P((void));
db_watchpoint_t db_watchpoint_alloc __P((void));
void db_watchpoint_free __P((db_watchpoint_t));
void db_set_watchpoint __P((vm_map_t, db_addr_t, vm_size_t));
void db_delete_watchpoint __P((vm_map_t, db_addr_t));
void db_list_watchpoints __P((void));
void db_deletewatch_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_watchpoint_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_listwatch_cmd __P((db_expr_t, int, db_expr_t, char *));
void db_set_watchpoints __P((void));
void db_clear_watchpoints __P((void));
boolean_t db_find_watchpoint __P((vm_map_t, db_addr_t, db_regs_t *));
#endif _DDB_DB_WATCH_

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_write_cmd.c,v 1.5 1994/10/09 08:56:30 mycroft Exp $ */
/* $NetBSD: db_write_cmd.c,v 1.6 1996/02/05 01:57:25 christos Exp $ */
/*
* Mach Operating System
@ -38,6 +38,8 @@
#include <ddb/db_access.h>
#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#include <ddb/db_output.h>
/*
* Write to file.
@ -72,6 +74,7 @@ db_write_cmd(address, have_addr, count, modif)
size = 4;
break;
default:
size = -1;
db_error("Unknown size\n");
/*NOTREACHED*/
}