summaryrefslogtreecommitdiff
path: root/ddb
diff options
context:
space:
mode:
Diffstat (limited to 'ddb')
-rw-r--r--ddb/db_access.c50
-rw-r--r--ddb/db_access.h6
-rw-r--r--ddb/db_aout.c118
-rw-r--r--ddb/db_aout.h52
-rw-r--r--ddb/db_break.c124
-rw-r--r--ddb/db_break.h22
-rw-r--r--ddb/db_command.c118
-rw-r--r--ddb/db_command.h15
-rw-r--r--ddb/db_cond.c22
-rw-r--r--ddb/db_cond.h2
-rw-r--r--ddb/db_elf.c232
-rw-r--r--ddb/db_elf.h52
-rw-r--r--ddb/db_examine.c71
-rw-r--r--ddb/db_examine.h42
-rw-r--r--ddb/db_expr.c36
-rw-r--r--ddb/db_expr.h2
-rw-r--r--ddb/db_ext_symtab.c13
-rw-r--r--ddb/db_input.c44
-rw-r--r--ddb/db_input.h2
-rw-r--r--ddb/db_lex.c31
-rw-r--r--ddb/db_lex.h9
-rw-r--r--ddb/db_macro.c40
-rw-r--r--ddb/db_macro.h4
-rw-r--r--ddb/db_mp.c37
-rw-r--r--ddb/db_mp.h30
-rw-r--r--ddb/db_output.c30
-rw-r--r--ddb/db_output.h10
-rw-r--r--ddb/db_print.c120
-rw-r--r--ddb/db_print.h75
-rw-r--r--ddb/db_run.c77
-rw-r--r--ddb/db_run.h48
-rw-r--r--ddb/db_sym.c137
-rw-r--r--ddb/db_sym.h42
-rw-r--r--ddb/db_task_thread.c88
-rw-r--r--ddb/db_task_thread.h24
-rw-r--r--ddb/db_trap.c23
-rw-r--r--ddb/db_variables.c46
-rw-r--r--ddb/db_variables.h9
-rw-r--r--ddb/db_watch.c56
-rw-r--r--ddb/db_watch.h20
-rw-r--r--ddb/db_write_cmd.c8
-rw-r--r--ddb/db_write_cmd.h34
-rw-r--r--ddb/stab.h4
43 files changed, 1246 insertions, 779 deletions
diff --git a/ddb/db_access.c b/ddb/db_access.c
index f06f9502..16d4d3ef 100644
--- a/ddb/db_access.c
+++ b/ddb/db_access.c
@@ -32,6 +32,7 @@
#include <mach/boolean.h>
#include <machine/db_machdep.h> /* type definitions */
+#include <machine/db_interface.h> /* function definitions */
#include <machine/setjmp.h>
#include <kern/task.h>
#include <ddb/db_access.h>
@@ -43,9 +44,6 @@
* boundaries.
*/
-extern void db_read_bytes(); /* machine-dependent */
-extern void db_write_bytes(); /* machine-dependent */
-
int db_access_level = DB_ACCESS_LEVEL;
/*
@@ -64,17 +62,17 @@ static int db_extend[sizeof(int)+1] = { /* table for sign-extending */
};
db_expr_t
-db_get_task_value(addr, size, is_signed, task)
- db_addr_t addr;
- register int size;
- boolean_t is_signed;
- task_t task;
+db_get_task_value(
+ db_addr_t addr,
+ int size,
+ boolean_t is_signed,
+ task_t task)
{
char data[sizeof(db_expr_t)];
- register db_expr_t value;
- register int i;
+ db_expr_t value;
+ int i;
- db_read_bytes((void*)addr, size, data, task);
+ db_read_bytes(addr, size, data, task);
value = 0;
#if BYTE_MSF
@@ -94,14 +92,14 @@ db_get_task_value(addr, size, is_signed, task)
}
void
-db_put_task_value(addr, size, value, task)
- db_addr_t addr;
- register int size;
- register db_expr_t value;
- task_t task;
+db_put_task_value(
+ db_addr_t addr,
+ int size,
+ db_expr_t value,
+ task_t task)
{
char data[sizeof(db_expr_t)];
- register int i;
+ int i;
#if BYTE_MSF
for (i = size - 1; i >= 0; i--)
@@ -113,23 +111,23 @@ db_put_task_value(addr, size, value, task)
value >>= 8;
}
- db_write_bytes((void*)addr, size, data, task);
+ db_write_bytes(addr, size, data, task);
}
db_expr_t
-db_get_value(addr, size, is_signed)
- db_addr_t addr;
- int size;
- boolean_t is_signed;
+db_get_value(
+ db_addr_t addr,
+ int size,
+ boolean_t is_signed)
{
return(db_get_task_value(addr, size, is_signed, TASK_NULL));
}
void
-db_put_value(addr, size, value)
- db_addr_t addr;
- int size;
- db_expr_t value;
+db_put_value(
+ db_addr_t addr,
+ int size,
+ db_expr_t value)
{
db_put_task_value(addr, size, value, TASK_NULL);
}
diff --git a/ddb/db_access.h b/ddb/db_access.h
index 6cedf29f..3bda5a4a 100644
--- a/ddb/db_access.h
+++ b/ddb/db_access.h
@@ -30,6 +30,10 @@
/*
* Data access functions for debugger.
*/
+
+#ifndef _DDB_DB_ACCESS_H_
+#define _DDB_DB_ACCESS_H_
+
#include <mach/boolean.h>
#include <machine/db_machdep.h>
#include <ddb/db_task_thread.h>
@@ -71,3 +75,5 @@ extern void db_put_task_value( db_addr_t addr,
int size,
db_expr_t value,
task_t task );
+
+#endif /* _DDB_DB_ACCESS_H_ */
diff --git a/ddb/db_aout.c b/ddb/db_aout.c
index 42fa6f75..d3f2e31e 100644
--- a/ddb/db_aout.c
+++ b/ddb/db_aout.c
@@ -39,6 +39,7 @@
#include <machine/db_machdep.h> /* data types */
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
+#include <ddb/db_aout.h>
#ifndef DB_NO_AOUT
@@ -69,18 +70,18 @@
ep = (struct nlist *)((char *)sp + *((int*)symtab)))
boolean_t
-aout_db_sym_init(symtab, esymtab, name, task_addr)
- char * symtab; /* pointer to start of symbol table */
- char * esymtab; /* pointer to end of string table,
+aout_db_sym_init(
+ char * symtab, /* pointer to start of symbol table */
+ char * esymtab, /* pointer to end of string table,
for checking - may be rounded up to
integer boundary */
- char * name;
- char * task_addr; /* use for this task only */
+ char * name,
+ char * task_addr) /* use for this task only */
{
- register struct nlist *sym_start, *sym_end;
- register struct nlist *sp;
- register char * strtab;
- register int strlen;
+ struct nlist *sym_start, *sym_end;
+ struct nlist *sp;
+ char * strtab;
+ int strlen;
char * estrtab;
db_get_aout_symtab(symtab, sym_start, sym_end);
@@ -100,7 +101,7 @@ aout_db_sym_init(symtab, esymtab, name, task_addr)
#undef round_to_size
for (sp = sym_start; sp < sym_end; sp++) {
- register long strx;
+ long strx;
strx = sp->n_un.n_strx;
if (strx != 0) {
if (strx > strlen) {
@@ -131,9 +132,9 @@ aout_db_sym_init(symtab, esymtab, name, task_addr)
/*
* check file name or not (check xxxx.x pattern)
*/
-private boolean_t
+private boolean_t __attribute__ ((pure))
aout_db_is_filename(name)
- register char *name;
+ const char *name;
{
while (*name) {
if (*name == '.') {
@@ -148,12 +149,12 @@ aout_db_is_filename(name)
/*
* special name comparison routine with a name in the symbol table entry
*/
-private boolean_t
+private boolean_t __attribute__ ((pure))
aout_db_eq_name(sp, name)
- struct nlist *sp;
- char *name;
+ const struct nlist *sp;
+ const char *name;
{
- register char *s1, *s2;
+ const char *s1, *s2;
s1 = sp->n_un.n_name;
s2 = name;
@@ -185,11 +186,11 @@ aout_db_eq_name(sp, name)
*/
private struct nlist *
aout_db_search_name(sp, ep, name, type, fp)
- register struct nlist *sp;
- struct nlist *ep;
- char *name;
- int type;
- struct nlist **fp;
+ struct nlist *sp;
+ const struct nlist *ep;
+ const char *name;
+ int type;
+ struct nlist **fp;
{
struct nlist *file_sp = *fp;
struct nlist *found_sp = 0;
@@ -232,11 +233,11 @@ aout_db_search_name(sp, ep, name, type, fp)
private db_sym_t
aout_db_qualified_search(stab, file, sym, line)
db_symtab_t *stab;
- char *file;
- char *sym;
+ const char *file;
+ const char *sym;
int line;
{
- register struct nlist *sp = (struct nlist *)stab->start;
+ struct nlist *sp = (struct nlist *)stab->start;
struct nlist *ep = (struct nlist *)stab->end;
struct nlist *fp = 0;
struct nlist *found_sp;
@@ -244,19 +245,19 @@ aout_db_qualified_search(stab, file, sym, line)
boolean_t in_file;
if (file == 0 && sym == 0)
- return(0);
+ return(DB_SYM_NULL);
if (file) {
if ((sp = aout_db_search_name(sp, ep, file, N_TEXT, &fp)) == 0)
- return(0);
+ return(DB_SYM_NULL);
}
if (sym) {
sp = aout_db_search_name(sp, ep, sym, (line > 0)? N_FUN: 0, &fp);
if (sp == 0)
- return(0);
+ return(DB_SYM_NULL);
}
if (line > 0) {
if (file && !aout_db_eq_name(fp, file))
- return(0);
+ return(DB_SYM_NULL);
found_sp = 0;
if (sp->n_type == N_FUN) {
/*
@@ -278,7 +279,7 @@ aout_db_qualified_search(stab, file, sym, line)
}
}
if (sp->n_type != N_SLINE || sp->n_value < func_top)
- return(0);
+ return(DB_SYM_NULL);
} else {
/*
* qualified by only file name
@@ -312,26 +313,23 @@ aout_db_qualified_search(stab, file, sym, line)
* lookup symbol by name
*/
db_sym_t
-aout_db_lookup(stab, symstr)
- db_symtab_t *stab;
- char * symstr;
+aout_db_lookup(
+ db_symtab_t *stab,
+ char * symstr)
{
- db_sym_t db_sym_parse_and_lookup();
-
return(db_sym_parse_and_lookup(aout_db_qualified_search, stab, symstr));
}
db_sym_t
-aout_db_search_symbol(symtab, off, strategy, diffp)
- db_symtab_t * symtab;
- register
- db_addr_t off;
- db_strategy_t strategy;
- db_expr_t *diffp; /* in/out */
+aout_db_search_symbol(
+ db_symtab_t * symtab,
+ db_addr_t off,
+ db_strategy_t strategy,
+ db_expr_t *diffp) /* in/out */
{
- register unsigned long diff = *diffp;
- register struct nlist *symp = 0;
- register struct nlist *sp, *ep;
+ unsigned long diff = *diffp;
+ struct nlist *symp = 0;
+ struct nlist *sp, *ep;
sp = (struct nlist *)symtab->start;
ep = (struct nlist *)symtab->end;
@@ -376,13 +374,13 @@ aout_db_search_symbol(symtab, off, strategy, diffp)
* Return the name and value for a symbol.
*/
void
-aout_db_symbol_values(stab, sym, namep, valuep)
- db_symtab_t *stab;
- db_sym_t sym;
- char **namep;
- db_expr_t *valuep;
+aout_db_symbol_values(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **namep,
+ db_expr_t *valuep)
{
- register struct nlist *sp;
+ struct nlist *sp;
sp = (struct nlist *)sym;
if (namep)
@@ -398,16 +396,16 @@ aout_db_symbol_values(stab, sym, namep, valuep)
*/
private boolean_t
aout_db_search_by_addr(stab, addr, file, func, line, diff)
- db_symtab_t *stab;
- register vm_offset_t addr;
- char **file;
- char **func;
- int *line;
- unsigned long *diff;
+ const db_symtab_t *stab;
+ vm_offset_t addr;
+ char **file;
+ char **func;
+ int *line;
+ unsigned long *diff;
{
- register struct nlist *sp;
- register struct nlist *line_sp, *func_sp, *file_sp, *line_func;
- register vm_size_t func_diff, line_diff;
+ struct nlist *sp;
+ struct nlist *line_sp, *func_sp, *file_sp, *line_func;
+ vm_size_t func_diff, line_diff;
boolean_t found_line = FALSE;
struct nlist *ep = (struct nlist *)stab->end;
@@ -495,13 +493,13 @@ aout_db_line_at_pc(stab, sym, file, line, pc)
db_sym_t sym;
char **file;
int *line;
- db_expr_t pc;
+ db_addr_t pc;
{
char *func;
unsigned long diff;
boolean_t found;
- found = aout_db_search_by_addr(stab,(vm_offset_t)pc,file,&func,line,&diff);
+ found = aout_db_search_by_addr(stab, pc, file, &func, line, &diff);
return(found && func && *file);
}
diff --git a/ddb/db_aout.h b/ddb/db_aout.h
new file mode 100644
index 00000000..7c03d36d
--- /dev/null
+++ b/ddb/db_aout.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _DDB_DB_AOUT_H_
+#define _DDB_DB_AOUT_H_
+
+#include <ddb/db_sym.h>
+#include <machine/db_machdep.h>
+
+extern boolean_t
+aout_db_line_at_pc(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **file,
+ int *line,
+ db_addr_t pc);
+
+extern db_sym_t
+aout_db_lookup(
+ db_symtab_t *stab,
+ char * symstr);
+
+extern db_sym_t
+aout_db_search_symbol(
+ db_symtab_t * symtab,
+ db_addr_t off,
+ db_strategy_t strategy,
+ db_expr_t *diffp);
+
+extern void
+aout_db_symbol_values(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **namep,
+ db_expr_t *valuep);
+
+#endif /* _DDB_DB_AOUT_H_ */
diff --git a/ddb/db_break.c b/ddb/db_break.c
index 9b1d6049..c3a9e181 100644
--- a/ddb/db_break.c
+++ b/ddb/db_break.c
@@ -36,6 +36,7 @@
*/
#include <mach/boolean.h>
#include <machine/db_machdep.h>
+#include <machine/db_interface.h>
#include <ddb/db_lex.h>
#include <ddb/db_break.h>
#include <ddb/db_access.h>
@@ -63,7 +64,7 @@ static int db_breakpoint_number = 0;
db_breakpoint_t
db_breakpoint_alloc()
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
if ((bkpt = db_free_breakpoints) != 0) {
db_free_breakpoints = bkpt->link;
@@ -81,7 +82,7 @@ db_breakpoint_alloc()
void
db_breakpoint_free(bkpt)
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
{
bkpt->link = db_free_breakpoints;
db_free_breakpoints = bkpt;
@@ -89,11 +90,12 @@ db_breakpoint_free(bkpt)
static int
db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt)
- register db_breakpoint_t bkpt;
+ const db_breakpoint_t bkpt;
vm_offset_t task_thd;
+ int count;
boolean_t task_bpt;
{
- register db_thread_breakpoint_t tp;
+ db_thread_breakpoint_t tp;
if (db_thread_break_init == FALSE) {
for (tp = db_thread_break_list;
@@ -119,12 +121,12 @@ db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt)
}
static int
-db_delete_thread_breakpoint(bkpt, task_thd)
- register db_breakpoint_t bkpt;
- vm_offset_t task_thd;
+db_delete_thread_breakpoint(
+ db_breakpoint_t bkpt,
+ vm_offset_t task_thd)
{
- register db_thread_breakpoint_t tp;
- register db_thread_breakpoint_t *tpp;
+ db_thread_breakpoint_t tp;
+ db_thread_breakpoint_t *tpp;
if (task_thd == 0) {
/* delete all the thread-breakpoints */
@@ -152,13 +154,13 @@ db_delete_thread_breakpoint(bkpt, task_thd)
}
}
-static db_thread_breakpoint_t
+static db_thread_breakpoint_t __attribute__ ((pure))
db_find_thread_breakpoint(bkpt, thread)
- db_breakpoint_t bkpt;
- thread_t thread;
+ const db_breakpoint_t bkpt;
+ const thread_t thread;
{
- register db_thread_breakpoint_t tp;
- register task_t task = (thread == THREAD_NULL)? TASK_NULL: thread->task;
+ db_thread_breakpoint_t tp;
+ task_t task = (thread == THREAD_NULL)? TASK_NULL: thread->task;
for (tp = bkpt->threads; tp; tp = tp->tb_next) {
if (tp->tb_is_task) {
@@ -174,24 +176,24 @@ db_find_thread_breakpoint(bkpt, thread)
db_thread_breakpoint_t
db_find_thread_breakpoint_here(task, addr)
- task_t task;
+ const task_t task;
db_addr_t addr;
{
db_breakpoint_t bkpt;
- bkpt = db_find_breakpoint(task, (db_addr_t)addr);
+ bkpt = db_find_breakpoint(task, addr);
if (bkpt == 0)
return(0);
return(db_find_thread_breakpoint(bkpt, current_thread()));
}
db_thread_breakpoint_t
-db_find_breakpoint_number(num, bkptp)
- int num;
- db_breakpoint_t *bkptp;
+db_find_breakpoint_number(
+ int num,
+ db_breakpoint_t *bkptp)
{
- register db_thread_breakpoint_t tp;
- register db_breakpoint_t bkpt;
+ db_thread_breakpoint_t tp;
+ db_breakpoint_t bkpt;
for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) {
for (tp = bkpt->threads; tp; tp = tp->tb_next) {
@@ -206,10 +208,10 @@ db_find_breakpoint_number(num, bkptp)
}
static void
-db_force_delete_breakpoint(bkpt, task_thd, is_task)
- db_breakpoint_t bkpt;
- vm_offset_t task_thd;
- boolean_t is_task;
+db_force_delete_breakpoint(
+ db_breakpoint_t bkpt,
+ vm_offset_t task_thd,
+ boolean_t is_task)
{
db_printf("deleted a stale breakpoint at ");
if (bkpt->task == TASK_NULL || db_lookup_task(bkpt->task) >= 0)
@@ -225,10 +227,10 @@ db_force_delete_breakpoint(bkpt, task_thd, is_task)
}
void
-db_check_breakpoint_valid()
+db_check_breakpoint_valid(void)
{
- register db_thread_breakpoint_t tbp, tbp_next;
- register db_breakpoint_t bkpt, *bkptp;
+ db_thread_breakpoint_t tbp, tbp_next;
+ db_breakpoint_t bkpt, *bkptp;
bkptp = &db_breakpoint_list;
for (bkpt = *bkptp; bkpt; bkpt = *bkptp) {
@@ -266,13 +268,13 @@ db_check_breakpoint_valid()
db_breakpoint_t
db_set_breakpoint(task, addr, count, thread, task_bpt)
- task_t task;
+ const task_t task;
db_addr_t addr;
int count;
- thread_t thread;
+ const thread_t thread;
boolean_t task_bpt;
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
db_breakpoint_t alloc_bkpt = 0;
vm_offset_t task_thd;
@@ -319,12 +321,12 @@ db_set_breakpoint(task, addr, count, thread, task_bpt)
void
db_delete_breakpoint(task, addr, task_thd)
- task_t task;
+ const task_t task;
db_addr_t addr;
vm_offset_t task_thd;
{
- register db_breakpoint_t bkpt;
- register db_breakpoint_t *prev;
+ db_breakpoint_t bkpt;
+ db_breakpoint_t *prev;
for (prev = &db_breakpoint_list; (bkpt = *prev) != 0;
prev = &bkpt->link) {
@@ -348,12 +350,12 @@ db_delete_breakpoint(task, addr, task_thd)
}
}
-db_breakpoint_t
+db_breakpoint_t __attribute__ ((pure))
db_find_breakpoint(task, addr)
- task_t task;
+ const task_t task;
db_addr_t addr;
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) {
if ((bkpt->task == task
@@ -366,10 +368,10 @@ db_find_breakpoint(task, addr)
boolean_t
db_find_breakpoint_here(task, addr)
- task_t task;
+ const task_t task;
db_addr_t addr;
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) {
if ((bkpt->task == task
@@ -377,7 +379,7 @@ db_find_breakpoint_here(task, addr)
&& bkpt->address == addr)
return(TRUE);
if ((bkpt->flags & BKPT_USR_GLOBAL) == 0 &&
- DB_PHYS_EQ(task, (vm_offset_t)addr, bkpt->task, (vm_offset_t)bkpt->address))
+ DB_PHYS_EQ(task, addr, bkpt->task, bkpt->address))
return (TRUE);
}
return(FALSE);
@@ -388,8 +390,8 @@ boolean_t db_breakpoints_inserted = TRUE;
void
db_set_breakpoints(void)
{
- register db_breakpoint_t bkpt;
- register task_t task;
+ db_breakpoint_t bkpt;
+ task_t task;
db_expr_t inst;
task_t cur_task;
@@ -433,8 +435,8 @@ db_set_breakpoints(void)
void
db_clear_breakpoints(void)
{
- register db_breakpoint_t bkpt, *bkptp;
- register task_t task;
+ db_breakpoint_t bkpt, *bkptp;
+ task_t task;
task_t cur_task;
db_expr_t inst;
@@ -480,11 +482,11 @@ db_clear_breakpoints(void)
* so the breakpoint does not have to be on the breakpoint list.
*/
db_breakpoint_t
-db_set_temp_breakpoint(task, addr)
- task_t task;
- db_addr_t addr;
+db_set_temp_breakpoint(
+ task_t task,
+ db_addr_t addr)
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
bkpt = db_breakpoint_alloc();
if (bkpt == 0) {
@@ -509,9 +511,9 @@ db_set_temp_breakpoint(task, addr)
}
void
-db_delete_temp_breakpoint(task, bkpt)
- task_t task;
- db_breakpoint_t bkpt;
+db_delete_temp_breakpoint(
+ task_t task,
+ db_breakpoint_t bkpt)
{
db_put_task_value(bkpt->address, BKPT_SIZE, bkpt->bkpt_inst, task);
db_delete_thread_breakpoint(bkpt, 0);
@@ -522,9 +524,9 @@ db_delete_temp_breakpoint(task, bkpt)
* List breakpoints.
*/
void
-db_list_breakpoints()
+db_list_breakpoints(void)
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
if (db_breakpoint_list == 0) {
db_printf("No breakpoints set\n");
@@ -536,9 +538,9 @@ db_list_breakpoints()
bkpt != 0;
bkpt = bkpt->link)
{
- register db_thread_breakpoint_t tp;
- int task_id;
- int thread_id;
+ db_thread_breakpoint_t tp;
+ int task_id;
+ int thread_id;
if (bkpt->threads) {
for (tp = bkpt->threads; tp; tp = tp->tb_next) {
@@ -596,9 +598,9 @@ db_list_breakpoints()
/* Delete breakpoint */
/*ARGSUSED*/
void
-db_delete_cmd()
+db_delete_cmd(void)
{
- register int n;
+ int n;
thread_t thread;
vm_offset_t task_thd;
boolean_t user_global = FALSE;
@@ -679,9 +681,9 @@ db_breakpoint_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
- register int n;
+ int n;
thread_t thread;
boolean_t user_global = db_option(modif, 'U');
boolean_t task_bpt = db_option(modif, 'T');
@@ -729,7 +731,7 @@ db_breakpoint_cmd(addr, have_addr, count, modif)
/* list breakpoints */
void
-db_listbreak_cmd()
+db_listbreak_cmd(void)
{
db_list_breakpoints();
}
diff --git a/ddb/db_break.h b/ddb/db_break.h
index 20d74d26..610af2f8 100644
--- a/ddb/db_break.h
+++ b/ddb/db_break.h
@@ -71,12 +71,12 @@ struct db_breakpoint {
typedef struct db_breakpoint *db_breakpoint_t;
-extern db_breakpoint_t db_find_breakpoint( task_t task, db_addr_t addr);
-extern boolean_t db_find_breakpoint_here( task_t task, db_addr_t addr);
+extern db_breakpoint_t db_find_breakpoint( const task_t task, db_addr_t addr) __attribute__ ((pure));
+extern boolean_t db_find_breakpoint_here( const task_t task, db_addr_t addr);
extern void db_set_breakpoints(void);
extern void db_clear_breakpoints(void);
extern db_thread_breakpoint_t db_find_thread_breakpoint_here
- ( task_t task, db_addr_t addr );
+ ( const task_t task, db_addr_t addr );
extern db_thread_breakpoint_t db_find_breakpoint_number
( int num, db_breakpoint_t *bkptp);
@@ -84,8 +84,20 @@ extern db_breakpoint_t db_set_temp_breakpoint( task_t task, db_addr_t addr);
extern void db_delete_temp_breakpoint
( task_t task, db_breakpoint_t bkpt);
-extern db_breakpoint_t db_set_breakpoint(task_t task, db_addr_t addr,
- int count, thread_t thread,
+extern db_breakpoint_t db_set_breakpoint(const task_t task, db_addr_t addr,
+ int count, const thread_t thread,
boolean_t task_bpt);
+void db_listbreak_cmd(void);
+
+void db_delete_cmd(void);
+
+void db_breakpoint_cmd(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
+extern void db_check_breakpoint_valid(void);
+
#endif /* _DDB_DB_BREAK_H_ */
diff --git a/ddb/db_command.c b/ddb/db_command.c
index 1593e866..56516672 100644
--- a/ddb/db_command.c
+++ b/ddb/db_command.c
@@ -45,14 +45,24 @@
#include <ddb/db_macro.h>
#include <ddb/db_expr.h>
#include <ddb/db_examine.h>
+#include <ddb/db_print.h>
+#include <ddb/db_break.h>
+#include <ddb/db_watch.h>
+#include <ddb/db_variables.h>
+#include <ddb/db_write_cmd.h>
+#include <ddb/db_run.h>
+#include <ddb/db_cond.h>
#include <machine/setjmp.h>
+#include <machine/db_interface.h>
#include <kern/debug.h>
#include <kern/thread.h>
#include <ipc/ipc_pset.h> /* 4proto */
#include <ipc/ipc_port.h> /* 4proto */
-
+#include <vm/vm_print.h>
+#include <ipc/ipc_print.h>
+#include <kern/lock.h>
/*
* Exported global variables
@@ -85,17 +95,17 @@ boolean_t db_ed_style = TRUE;
*/
int
db_cmd_search(name, table, cmdp)
- char * name;
- struct db_command *table;
- struct db_command **cmdp; /* out */
+ const char * name;
+ const struct db_command *table;
+ const struct db_command **cmdp; /* out */
{
- struct db_command *cmd;
+ const struct db_command *cmd;
int result = CMD_NONE;
for (cmd = table; cmd->name != 0; cmd++) {
- register char *lp;
- register char *rp;
- register int c;
+ const char *lp;
+ char *rp;
+ int c;
lp = name;
rp = cmd->name;
@@ -132,9 +142,9 @@ db_cmd_search(name, table, cmdp)
void
db_cmd_list(table)
- struct db_command *table;
+ const struct db_command *table;
{
- register struct db_command *cmd;
+ const struct db_command *cmd;
for (cmd = table; cmd->name != 0; cmd++) {
db_printf("%-12s", cmd->name);
@@ -143,9 +153,9 @@ db_cmd_list(table)
}
void
-db_command(last_cmdp, cmd_table)
- struct db_command **last_cmdp; /* IN_OUT */
- struct db_command *cmd_table;
+db_command(
+ struct db_command **last_cmdp, /* IN_OUT */
+ struct db_command *cmd_table)
{
struct db_command *cmd;
int t;
@@ -166,7 +176,6 @@ db_command(last_cmdp, cmd_table)
db_unread_token(t);
}
else if (t == tEXCL) {
- void db_fncall();
db_fncall();
return;
}
@@ -284,34 +293,18 @@ db_command(last_cmdp, cmd_table)
}
void
-db_command_list(last_cmdp, cmd_table)
- struct db_command **last_cmdp; /* IN_OUT */
- struct db_command *cmd_table;
+db_command_list(
+ struct db_command **last_cmdp, /* IN_OUT */
+ struct db_command *cmd_table)
{
- void db_skip_to_eol();
-
do {
db_command(last_cmdp, cmd_table);
db_skip_to_eol();
- } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == 0);
+ } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == FALSE);
}
-/*
- * 'show' commands
- */
-extern void db_listbreak_cmd();
-extern void db_listwatch_cmd();
-extern void db_show_regs(), db_show_one_thread(), db_show_one_task();
-extern void db_show_all_threads();
-extern void db_show_macro();
-extern void vm_map_print(), vm_object_print(), vm_page_print();
-extern void vm_map_copy_print();
-extern void ipc_port_print(), ipc_pset_print(), db_show_all_slocks();
-extern void ipc_kmsg_print(), ipc_msg_print();
-extern void db_show_port_id();
-void db_show_help();
-
struct db_command db_show_all_cmds[] = {
+ { "tasks", db_show_all_tasks, 0, 0 },
{ "threads", db_show_all_threads, 0, 0 },
{ "slocks", db_show_all_slocks, 0, 0 },
{ (char *)0 }
@@ -337,20 +330,6 @@ struct db_command db_show_cmds[] = {
{ (char *)0, }
};
-extern void db_print_cmd(), db_examine_cmd(), db_set_cmd();
-extern void db_examine_forward(), db_examine_backward();
-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(), db_cond_cmd();
-void db_help_cmd();
-void db_def_macro_cmd(), db_del_macro_cmd();
-void db_fncall();
-extern void db_reset_cpu();
-
struct db_command db_command_table[] = {
#ifdef DB_MACHINE_COMMANDS
/* this must be the first entry, if it exists */
@@ -385,6 +364,7 @@ struct db_command db_command_table[] = {
{ "show", 0, 0, db_show_cmds },
{ "reset", db_reset_cpu, 0, 0 },
{ "reboot", db_reset_cpu, 0, 0 },
+ { "halt", db_halt_cpu, 0, 0 },
{ (char *)0, }
};
@@ -392,20 +372,19 @@ struct db_command db_command_table[] = {
/* this function should be called to install the machine dependent
commands. It should be called before the debugger is enabled */
-void db_machine_commands_install(ptr)
-struct db_command *ptr;
+void db_machine_commands_install(struct db_command *ptr)
{
db_command_table[0].more = ptr;
return;
}
-#endif
+#endif /* DB_MACHINE_COMMANDS */
struct db_command *db_last_command = 0;
void
-db_help_cmd()
+db_help_cmd(void)
{
struct db_command *cmd = db_command_table;
@@ -416,8 +395,6 @@ db_help_cmd()
}
}
-int (*ddb_display)();
-
void
db_command_loop(void)
{
@@ -432,10 +409,7 @@ db_command_loop(void)
db_prev = db_dot;
db_next = db_dot;
- if (ddb_display)
- (*ddb_display)();
-
- db_cmd_loop_done = 0;
+ db_cmd_loop_done = FALSE;
while (!db_cmd_loop_done) {
(void) _setjmp(db_recover = &db_jmpbuf);
db_macro_level = 0;
@@ -456,13 +430,13 @@ db_command_loop(void)
}
boolean_t
-db_exec_cmd_nest(cmd, size)
- char *cmd;
- int size;
+db_exec_cmd_nest(
+ char *cmd,
+ int size)
{
struct db_lex_context lex_context;
- db_cmd_loop_done = 0;
+ db_cmd_loop_done = FALSE;
if (cmd) {
db_save_lex_context(&lex_context);
db_switch_input(cmd, size /**OLD, &lex_context OLD**/);
@@ -470,15 +444,11 @@ db_exec_cmd_nest(cmd, size)
db_command_list(&db_last_command, db_command_table);
if (cmd)
db_restore_lex_context(&lex_context);
- return(db_cmd_loop_done == 0);
+ return(db_cmd_loop_done == FALSE);
}
-#ifdef __GNUC__
-extern __volatile__ void _longjmp();
-#endif
-
void db_error(s)
- char *s;
+ const char *s;
{
extern int db_macro_level;
@@ -502,7 +472,7 @@ void db_error(s)
* !expr(arg,arg,arg)
*/
void
-db_fncall()
+db_fncall(void)
{
db_expr_t fn_addr;
#define MAXARGS 11
@@ -553,12 +523,12 @@ db_fncall()
db_printf(" %#N\n", retval);
}
-boolean_t
+boolean_t __attribute__ ((pure))
db_option(modif, option)
- char *modif;
- int option;
+ const char *modif;
+ int option;
{
- register char *p;
+ const char *p;
for (p = modif; *p; p++)
if (*p == option)
diff --git a/ddb/db_command.h b/ddb/db_command.h
index 1c0d106f..4208bda8 100644
--- a/ddb/db_command.h
+++ b/ddb/db_command.h
@@ -28,6 +28,9 @@
* Date: 7/90
*/
+#ifndef _DDB_DB_COMMAND_H_
+#define _DDB_DB_COMMAND_H_
+
#if MACH_KDB
/*
@@ -38,9 +41,9 @@
#include <machine/setjmp.h>
extern void db_command_loop(void);
-extern boolean_t db_option(char *, int);
+extern boolean_t db_option(const char *, int) __attribute__ ((pure));
-extern void db_error(char *); /* report error */
+extern void db_error(const char *) __attribute__ ((noreturn)); /* report error */
extern db_addr_t db_dot; /* current location */
extern db_addr_t db_last_addr; /* last explicit address typed */
@@ -50,8 +53,6 @@ extern db_addr_t db_next; /* next address to be examined
or written */
extern jmp_buf_t * db_recover; /* error recovery */
-extern jmp_buf_t * db_recover; /* error recovery */
-
/*
* Command table
*/
@@ -68,4 +69,10 @@ struct db_command {
extern boolean_t db_exec_cmd_nest(char *cmd, int size);
+void db_fncall(void);
+
+void db_help_cmd(void);
+
#endif /* MACH_KDB */
+
+#endif /* _DDB_DB_COMMAND_H_ */
diff --git a/ddb/db_cond.c b/ddb/db_cond.c
index 60ea4735..31e1d241 100644
--- a/ddb/db_cond.c
+++ b/ddb/db_cond.c
@@ -48,8 +48,7 @@ struct db_cond {
} db_cond[DB_MAX_COND];
void
-db_cond_free(bkpt)
- db_thread_breakpoint_t bkpt;
+db_cond_free(db_thread_breakpoint_t bkpt)
{
if (bkpt->tb_cond > 0) {
db_cond[bkpt->tb_cond-1].c_size = 0;
@@ -59,10 +58,9 @@ db_cond_free(bkpt)
}
boolean_t
-db_cond_check(bkpt)
- db_thread_breakpoint_t bkpt;
+db_cond_check(db_thread_breakpoint_t bkpt)
{
- register struct db_cond *cp;
+ struct db_cond *cp;
db_expr_t value;
int t;
jmp_buf_t db_jmpbuf;
@@ -105,10 +103,10 @@ db_cond_check(bkpt)
void
db_cond_print(bkpt)
- db_thread_breakpoint_t bkpt;
+ const db_thread_breakpoint_t bkpt;
{
- register char *p, *ep;
- register struct db_cond *cp;
+ char *p, *ep;
+ struct db_cond *cp;
if (bkpt->tb_cond <= 0)
return;
@@ -123,11 +121,11 @@ db_cond_print(bkpt)
}
void
-db_cond_cmd()
+db_cond_cmd(void)
{
- register int c;
- register struct db_cond *cp;
- register char *p;
+ int c;
+ struct db_cond *cp;
+ char *p;
db_expr_t value;
db_thread_breakpoint_t bkpt;
diff --git a/ddb/db_cond.h b/ddb/db_cond.h
index dec4967d..6b9c3a5b 100644
--- a/ddb/db_cond.h
+++ b/ddb/db_cond.h
@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <machine/db_machdep.h>
-extern void db_cond_free (db_thread_breakpoint_t bkpt);
+extern void db_cond_free (const db_thread_breakpoint_t bkpt);
extern boolean_t db_cond_check (db_thread_breakpoint_t bkpt);
diff --git a/ddb/db_elf.c b/ddb/db_elf.c
new file mode 100644
index 00000000..10e71621
--- /dev/null
+++ b/ddb/db_elf.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2014 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * 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 Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 7/90
+ */
+
+#if MACH_KDB
+
+/*
+ * Symbol table routines for ELF format files.
+ */
+
+#include <string.h>
+#include <mach/std_types.h>
+#include <mach/exec/elf.h>
+#include <machine/db_machdep.h> /* data types */
+#include <machine/vm_param.h>
+#include <ddb/db_output.h>
+#include <ddb/db_sym.h>
+#include <ddb/db_elf.h>
+
+#ifndef DB_NO_ELF
+
+struct db_symtab_elf {
+ int type;
+ Elf32_Sym *start;
+ Elf32_Sym *end;
+ char *strings;
+ char *map_pointer; /* symbols are for this map only,
+ if not null */
+ char name[SYMTAB_NAME_LEN];
+ /* symtab name */
+};
+
+boolean_t
+elf_db_sym_init (unsigned shdr_num,
+ vm_size_t shdr_size,
+ vm_offset_t shdr_addr,
+ unsigned shdr_shndx,
+ char *name,
+ char *task_addr)
+{
+ Elf32_Shdr *shdr, *symtab, *strtab;
+ const char *shstrtab;
+ int i;
+
+ if (shdr_num == 0)
+ return FALSE;
+
+ if (shdr_size != sizeof *shdr)
+ return FALSE;
+
+ shdr = (Elf32_Shdr *) shdr_addr;
+
+ if (shdr[shdr_shndx].sh_type != SHT_STRTAB)
+ return FALSE;
+
+ shstrtab = (const char *) phystokv (shdr[shdr_shndx].sh_addr);
+
+ symtab = strtab = NULL;
+ for (i = 0; i < shdr_num; i++)
+ switch (shdr[i].sh_type) {
+ case SHT_SYMTAB:
+ if (symtab)
+ db_printf ("Ignoring additional ELF symbol table at %d\n", i);
+ else
+ symtab = &shdr[i];
+ break;
+
+ case SHT_STRTAB:
+ if (strcmp (&shstrtab[shdr[i].sh_name], ".strtab") == 0) {
+ if (strtab)
+ db_printf ("Ignoring additional ELF string table at %d\n", i);
+ else
+ strtab = &shdr[i];
+ }
+ break;
+ }
+
+ if (symtab == NULL || strtab == NULL)
+ return FALSE;
+
+ if (db_add_symbol_table (SYMTAB_ELF,
+ (char *) phystokv (symtab->sh_addr),
+ (char *) phystokv (symtab->sh_addr)+symtab->sh_size,
+ name,
+ (char *) phystokv (strtab->sh_addr),
+ task_addr)) {
+ db_printf ("Loaded ELF symbol table for %s (%d symbols)\n",
+ name, symtab->sh_size / sizeof (Elf32_Sym));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * lookup symbol by name
+ */
+db_sym_t
+elf_db_lookup (db_symtab_t *stab,
+ char *symstr)
+{
+ struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
+ Elf32_Sym *s;
+
+ for (s = self->start; s < self->end; s++)
+ if (strcmp (symstr, &self->strings[s->st_name]) == 0)
+ return (db_sym_t) s;
+
+ return NULL;
+}
+
+db_sym_t
+elf_db_search_symbol (db_symtab_t *stab,
+ db_addr_t off,
+ db_strategy_t strategy,
+ db_expr_t *diffp) /* in/out */
+{
+ struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
+ unsigned long diff = *diffp;
+ Elf32_Sym *s, *symp = NULL;
+
+ for (s = self->start; s < self->end; s++) {
+ if (s->st_name == 0)
+ continue;
+
+ if (strategy == DB_STGY_XTRN && (s->st_info & STB_GLOBAL) == 0)
+ continue;
+
+ if (off >= s->st_value) {
+ if (s->st_info == STT_FUNC)
+ continue;
+
+ if (off - s->st_value < diff) {
+ diff = off - s->st_value;
+ symp = s;
+ if (diff == 0 && (s->st_info & STB_GLOBAL))
+ break;
+ } else if (off - s->st_value == diff) {
+ if (symp == NULL)
+ symp = s;
+ else if ((symp->st_info & STB_GLOBAL) == 0
+ && (s->st_info & STB_GLOBAL) != 0)
+ symp = s; /* pick the external symbol */
+ }
+ }
+ }
+
+ if (symp == NULL)
+ *diffp = off;
+ else
+ *diffp = diff;
+
+ return (db_sym_t) symp;
+}
+
+/*
+ * Return the name and value for a symbol.
+ */
+void
+elf_db_symbol_values (db_symtab_t *stab,
+ db_sym_t sym,
+ char **namep,
+ db_expr_t *valuep)
+{
+ struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
+ Elf32_Sym *s = (Elf32_Sym *) sym;
+
+ if (namep)
+ *namep = &self->strings[s->st_name];
+ if (valuep)
+ *valuep = s->st_value;
+}
+
+/*
+ * Find filename and lineno within, given the current pc.
+ */
+boolean_t
+elf_db_line_at_pc (db_symtab_t *stab,
+ db_sym_t sym,
+ char **file,
+ int *line,
+ db_addr_t pc)
+{
+ /* XXX Parse DWARF information. */
+ return FALSE;
+}
+
+#endif /* DB_NO_ELF */
+
+#endif /* MACH_KDB */
diff --git a/ddb/db_elf.h b/ddb/db_elf.h
new file mode 100644
index 00000000..12b82868
--- /dev/null
+++ b/ddb/db_elf.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _DDB_DB_ELF_H_
+#define _DDB_DB_ELF_H_
+
+#include <ddb/db_sym.h>
+#include <machine/db_machdep.h>
+
+extern boolean_t
+elf_db_line_at_pc(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **file,
+ int *line,
+ db_addr_t pc);
+
+extern db_sym_t
+elf_db_lookup(
+ db_symtab_t *stab,
+ char * symstr);
+
+extern db_sym_t
+elf_db_search_symbol(
+ db_symtab_t * symtab,
+ db_addr_t off,
+ db_strategy_t strategy,
+ db_expr_t *diffp);
+
+extern void
+elf_db_symbol_values(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **namep,
+ db_expr_t *valuep);
+
+#endif /* _DDB_DB_ELF_H_ */
diff --git a/ddb/db_examine.c b/ddb/db_examine.c
index 96c5eee1..836b0e89 100644
--- a/ddb/db_examine.c
+++ b/ddb/db_examine.c
@@ -53,9 +53,6 @@ int db_examine_count = 1;
db_addr_t db_examine_prev_addr = 0;
thread_t db_examine_thread = THREAD_NULL;
-extern db_addr_t db_disasm(db_addr_t pc, boolean_t altform, task_t task);
- /* instruction disassembler */
-
/*
* Examine (print) data.
*/
@@ -65,10 +62,9 @@ db_examine_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
thread_t thread;
- boolean_t db_option();
if (modif[0] != '\0')
db_strcpy(db_examine_format, modif);
@@ -82,7 +78,7 @@ db_examine_cmd(addr, have_addr, count, modif)
return;
}
else
- if (db_option(modif,'u'))
+ if (db_option(modif, 'u'))
thread = current_thread();
else
thread = THREAD_NULL;
@@ -98,7 +94,7 @@ db_examine_forward(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
db_examine(db_next, db_examine_format, db_examine_count,
db_thread_to_task(db_examine_thread));
@@ -110,7 +106,7 @@ db_examine_backward(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
db_examine(db_examine_prev_addr - (db_next - db_examine_prev_addr),
@@ -120,9 +116,8 @@ db_examine_backward(addr, have_addr, count, modif)
void
db_examine(addr, fmt, count, task)
- register
db_addr_t addr;
- char * fmt; /* format string */
+ const char * fmt; /* format string */
int count; /* repeat count */
task_t task;
{
@@ -130,7 +125,7 @@ db_examine(addr, fmt, count, task)
db_expr_t value;
int size; /* in bytes */
int width;
- char * fp;
+ const char * fp;
db_examine_prev_addr = addr;
while (--count >= 0) {
@@ -163,7 +158,7 @@ db_examine(addr, fmt, count, task)
db_printf(":\t");
break;
case 'm':
- db_next = db_xcdump(addr, size, count+1, task);
+ db_next = db_xcdump(addr, size, count + 1, task);
return;
default:
if (db_print_position() == 0) {
@@ -171,7 +166,7 @@ db_examine(addr, fmt, count, task)
char * name;
db_addr_t off;
- db_find_task_sym_and_offset(addr,&name,&off,task);
+ db_find_task_sym_and_offset(addr, &name, &off, task);
if (off == 0)
db_printf("%s:\t", name);
else
@@ -260,7 +255,7 @@ char db_print_format = 'x';
/*ARGSUSED*/
void
-db_print_cmd()
+db_print_cmd(void)
{
db_expr_t value;
int t;
@@ -326,9 +321,9 @@ db_print_cmd()
}
void
-db_print_loc_and_inst(loc, task)
- db_addr_t loc;
- task_t task;
+db_print_loc_and_inst(
+ db_addr_t loc,
+ task_t task)
{
db_task_printsym(loc, DB_STGY_PROC, task);
db_printf(":\t");
@@ -337,20 +332,19 @@ db_print_loc_and_inst(loc, task)
void
db_strcpy(dst, src)
- register char *dst;
- register char *src;
+ char *dst;
+ const char *src;
{
while ((*dst++ = *src++))
;
}
-void db_search(); /*forward*/
/*
* Search for a value in memory.
* Syntax: search [/bhl] addr value [mask] [,count] [thread]
*/
void
-db_search_cmd()
+db_search_cmd(void)
{
int t;
db_addr_t addr;
@@ -360,7 +354,7 @@ db_search_cmd()
db_addr_t count;
thread_t thread;
boolean_t thread_flag = FALSE;
- register char *p;
+ char *p;
t = db_read_token();
if (t == tSLASH) {
@@ -395,7 +389,7 @@ db_search_cmd()
size = sizeof(int);
}
- if (!db_expression(&addr)) {
+ if (!db_expression((db_expr_t *)&addr)) {
db_printf("Address missing\n");
db_flush_lex();
return;
@@ -412,7 +406,7 @@ db_search_cmd()
t = db_read_token();
if (t == tCOMMA) {
- if (!db_expression(&count)) {
+ if (!db_expression((db_expr_t *)&count)) {
db_printf("Count missing\n");
db_flush_lex();
return;
@@ -431,18 +425,17 @@ db_search_cmd()
}
void
-db_search(addr, size, value, mask, count, task)
- register
- db_addr_t addr;
- int size;
- db_expr_t value;
- db_expr_t mask;
- unsigned int count;
- task_t task;
+db_search(
+ db_addr_t addr,
+ int size,
+ db_expr_t value,
+ db_expr_t mask,
+ unsigned int count,
+ task_t task)
{
while (count-- != 0) {
db_prev = addr;
- if ((db_get_task_value(addr,size,FALSE,task) & mask) == value)
+ if ((db_get_task_value(addr, size, FALSE, task) & mask) == value)
break;
addr += size;
}
@@ -452,13 +445,13 @@ db_search(addr, size, value, mask, count, task)
#define DB_XCDUMP_NC 16
int
-db_xcdump(addr, size, count, task)
- db_addr_t addr;
- int size;
- int count;
- task_t task;
+db_xcdump(
+ db_addr_t addr,
+ int size,
+ int count,
+ task_t task)
{
- register int i, n;
+ int i, n;
db_expr_t value;
int bcount;
db_addr_t off;
diff --git a/ddb/db_examine.h b/ddb/db_examine.h
index 96ad7194..df578a02 100644
--- a/ddb/db_examine.h
+++ b/ddb/db_examine.h
@@ -29,18 +29,54 @@ extern void db_examine_cmd (
db_expr_t addr,
int have_addr,
db_expr_t count,
- char *modif);
+ const char *modif);
-extern void db_strcpy (char *dst, char *src);
+extern void db_strcpy (char *dst, const char *src);
extern void db_examine (
db_addr_t addr,
- char *fmt,
+ const char *fmt,
int count,
task_t task);
+void db_examine_forward(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
+void db_examine_backward(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
extern void db_print_loc_and_inst (
db_addr_t loc,
task_t task);
+int db_xcdump(
+ db_addr_t addr,
+ int size,
+ int count,
+ task_t task);
+
+void db_print_cmd(void);
+
+void db_search_cmd(void);
+
+void db_search(
+ db_addr_t addr,
+ int size,
+ db_expr_t value,
+ db_expr_t mask,
+ unsigned int count,
+ task_t task);
+
+/* instruction disassembler */
+extern db_addr_t db_disasm(
+ db_addr_t pc,
+ boolean_t altform,
+ task_t task);
+
#endif /* _DDB_DB_EXAMINE_H_ */
diff --git a/ddb/db_expr.c b/ddb/db_expr.c
index 611baa09..c9e6752a 100644
--- a/ddb/db_expr.c
+++ b/ddb/db_expr.c
@@ -41,10 +41,8 @@
#include <ddb/db_variables.h>
#include <kern/task.h>
-
boolean_t
-db_term(valuep)
- db_expr_t *valuep;
+db_term(db_expr_t *valuep)
{
int t;
@@ -95,12 +93,12 @@ db_term(valuep)
int
db_size_option(modif, u_option, t_option)
- char *modif;
+ const char *modif;
boolean_t *u_option;
boolean_t *t_option;
{
- register char *p;
- int size = sizeof(int);
+ const char *p;
+ int size = sizeof(int);
*u_option = FALSE;
*t_option = FALSE;
@@ -127,8 +125,7 @@ db_size_option(modif, u_option, t_option)
}
boolean_t
-db_unary(valuep)
- db_expr_t *valuep;
+db_unary(db_expr_t *valuep)
{
int t;
int size;
@@ -177,10 +174,9 @@ db_unary(valuep)
}
boolean_t
-db_mult_expr(valuep)
- db_expr_t *valuep;
+db_mult_expr(db_expr_t *valuep)
{
- db_expr_t lhs, rhs;
+ db_expr_t lhs = 0, rhs;
int t;
char c;
@@ -223,8 +219,7 @@ db_mult_expr(valuep)
}
boolean_t
-db_add_expr(valuep)
- db_expr_t *valuep;
+db_add_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
@@ -255,8 +250,7 @@ db_add_expr(valuep)
}
boolean_t
-db_shift_expr(valuep)
- db_expr_t *valuep;
+db_shift_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
@@ -290,8 +284,7 @@ db_shift_expr(valuep)
}
boolean_t
-db_logical_relation_expr(valuep)
- db_expr_t *valuep;
+db_logical_relation_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
@@ -340,8 +333,7 @@ db_logical_relation_expr(valuep)
}
boolean_t
-db_logical_and_expr(valuep)
- db_expr_t *valuep;
+db_logical_and_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
@@ -363,8 +355,7 @@ db_logical_and_expr(valuep)
}
boolean_t
-db_logical_or_expr(valuep)
- db_expr_t *valuep;
+db_logical_or_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
@@ -386,8 +377,7 @@ db_logical_or_expr(valuep)
}
int
-db_expression(valuep)
- db_expr_t *valuep;
+db_expression(db_expr_t *valuep)
{
return (db_logical_or_expr(valuep));
}
diff --git a/ddb/db_expr.h b/ddb/db_expr.h
index 989b66be..9c304e69 100644
--- a/ddb/db_expr.h
+++ b/ddb/db_expr.h
@@ -17,7 +17,7 @@
*/
int db_size_option(
- char *modif,
+ const char *modif,
boolean_t *u_option,
boolean_t *t_option);
diff --git a/ddb/db_ext_symtab.c b/ddb/db_ext_symtab.c
index 24342971..cafb0c4c 100644
--- a/ddb/db_ext_symtab.c
+++ b/ddb/db_ext_symtab.c
@@ -33,6 +33,7 @@
#include <mach/vm_param.h>
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
+#include <vm/vm_user.h>
#include <kern/host.h>
#include <kern/task.h>
#include <ddb/db_sym.h>
@@ -45,12 +46,12 @@
* the caller and the kernel debugger agree on its format.
*/
kern_return_t
-host_load_symbol_table(host, task, name, symtab, symtab_count)
- host_t host;
- task_t task;
- char * name;
- pointer_t symtab;
- unsigned int symtab_count;
+host_load_symbol_table(
+ host_t host,
+ task_t task,
+ char * name,
+ pointer_t symtab,
+ unsigned int symtab_count)
{
kern_return_t result;
vm_offset_t symtab_start;
diff --git a/ddb/db_input.c b/ddb/db_input.c
index ce6a3103..6b6db764 100644
--- a/ddb/db_input.c
+++ b/ddb/db_input.c
@@ -32,6 +32,7 @@
#include <mach/boolean.h>
#include <machine/db_machdep.h>
+#include <device/cons.h>
#include <ddb/db_command.h>
#include <ddb/db_input.h>
#include <ddb/db_output.h>
@@ -68,8 +69,8 @@ char * db_history_prev = (char *) 0; /* start of previous line */
void
db_putstring(s, count)
- char *s;
- int count;
+ const char *s;
+ int count;
{
while (--count >= 0)
cnputc(*s++);
@@ -90,11 +91,11 @@ db_putnchars(c, count)
#define DEL_FWD 0
#define DEL_BWD 1
void
-db_delete(n, bwd)
- int n;
- int bwd;
+db_delete(
+ int n,
+ int bwd)
{
- register char *p;
+ char *p;
if (bwd) {
db_lc -= n;
@@ -110,7 +111,7 @@ db_delete(n, bwd)
}
void
-db_delete_line()
+db_delete_line(void)
{
db_delete(db_le - db_lc, DEL_FWD);
db_delete(db_lc - db_lbuf_start, DEL_BWD);
@@ -132,12 +133,11 @@ db_delete_line()
db_history_curr = db_history + \
db_history_size - 1; \
} while (0)
-#endif
+#endif /* DB_HISTORY_SIZE */
/* returns TRUE at end-of-line */
boolean_t
-db_inputchar(c)
- int c;
+db_inputchar(int c)
{
switch (c) {
case CTRL('b'):
@@ -213,7 +213,7 @@ db_inputchar(c)
INC_DB_CURR();
db_le = db_lc = db_lbuf_start;
} else {
- register char *p;
+ char *p;
INC_DB_CURR();
for (p = db_history_curr, db_le = db_lbuf_start;
*p; ) {
@@ -236,7 +236,7 @@ db_inputchar(c)
INC_DB_CURR();
db_delete_line();
if (db_history_curr != db_history_last) {
- register char *p;
+ char *p;
for (p = db_history_curr,
db_le = db_lbuf_start; *p;) {
*db_le++ = *p++;
@@ -250,7 +250,7 @@ db_inputchar(c)
db_putstring(db_lbuf_start, db_le - db_lbuf_start);
}
break;
-#endif
+#endif /* DB_HISTORY_SIZE */
case CTRL('r'):
db_putstring("^R\n", 3);
if (db_le > db_lbuf_start) {
@@ -267,7 +267,7 @@ db_inputchar(c)
* save it.
*/
if (db_history_curr == db_history_prev) {
- register char *pp, *pc;
+ char *pp, *pc;
/*
* Is it the same?
@@ -291,7 +291,7 @@ db_inputchar(c)
}
}
if (db_le != db_lbuf_start) {
- register char *p;
+ char *p;
db_history_prev = db_history_last;
for (p = db_lbuf_start; p != db_le; p++) {
*db_history_last++ = *p;
@@ -303,7 +303,7 @@ db_inputchar(c)
*db_history_last++ = '\0';
}
db_history_curr = db_history_last;
-#endif
+#endif /* DB_HISTORY_SIZE */
*db_le++ = c;
return (TRUE);
default:
@@ -311,7 +311,7 @@ db_inputchar(c)
cnputc('\007');
}
else if (c >= ' ' && c <= '~') {
- register char *p;
+ char *p;
for (p = db_le; p > db_lc; p--)
*p = *(p-1);
@@ -327,9 +327,9 @@ db_inputchar(c)
}
int
-db_readline(lstart, lsize)
- char * lstart;
- int lsize;
+db_readline(
+ char * lstart,
+ int lsize)
{
db_force_whitespace(); /* synch output position */
@@ -348,9 +348,9 @@ db_readline(lstart, lsize)
}
void
-db_check_interrupt()
+db_check_interrupt(void)
{
- register int c;
+ int c;
c = cnmaygetc();
switch (c) {
diff --git a/ddb/db_input.h b/ddb/db_input.h
index 316e3268..77f07bb6 100644
--- a/ddb/db_input.h
+++ b/ddb/db_input.h
@@ -25,4 +25,6 @@
extern int db_readline (char *lstart, int lsize);
+extern void db_check_interrupt(void);
+
#endif /* _DDB_DB_INPUT_H_ */
diff --git a/ddb/db_lex.c b/ddb/db_lex.c
index ebffe062..8ab69106 100644
--- a/ddb/db_lex.c
+++ b/ddb/db_lex.c
@@ -50,7 +50,7 @@ db_expr_t db_look_token = 0;
int
db_read_line(repeat_last)
- char *repeat_last;
+ const char *repeat_last;
{
int i;
@@ -82,9 +82,9 @@ db_flush_line(void)
}
void
-db_switch_input(buffer, size)
- char *buffer;
- int size;
+db_switch_input(
+ char *buffer,
+ int size)
{
db_lp = buffer;
db_last_lp = db_lp;
@@ -94,8 +94,7 @@ db_switch_input(buffer, size)
}
void
-db_save_lex_context(lp)
- register struct db_lex_context *lp;
+db_save_lex_context(struct db_lex_context *lp)
{
lp->l_ptr = db_lp;
lp->l_eptr = db_endlp;
@@ -105,7 +104,7 @@ db_save_lex_context(lp)
void
db_restore_lex_context(lp)
- register struct db_lex_context *lp;
+ const struct db_lex_context *lp;
{
db_lp = lp->l_ptr;
db_last_lp = db_lp;
@@ -131,15 +130,13 @@ db_read_char(void)
}
void
-db_unread_char(c)
- int c;
+db_unread_char(int c)
{
db_look_char = c;
}
void
-db_unread_token(t)
- int t;
+db_unread_token(int t)
{
db_look_token = t;
}
@@ -179,10 +176,10 @@ db_flush_lex(void)
void
db_skip_to_eol(void)
{
- register int skip;
- register int t;
- register int n;
- register char *p;
+ int skip;
+ int t;
+ int n;
+ char *p;
t = db_read_token();
p = db_last_lp;
@@ -205,8 +202,8 @@ db_skip_to_eol(void)
int
db_lex(void)
{
- register char *cp;
- register int c;
+ char *cp;
+ int c;
c = db_read_char();
while (c <= ' ' || c > '~') {
diff --git a/ddb/db_lex.h b/ddb/db_lex.h
index dc9da0a9..f7677df8 100644
--- a/ddb/db_lex.h
+++ b/ddb/db_lex.h
@@ -31,6 +31,9 @@
* Lexical analyzer.
*/
+#ifndef _DDB_DB_LEX_H_
+#define _DDB_DB_LEX_H_
+
#define TOK_STRING_SIZE 64
#define DB_LEX_LINE_SIZE 256
@@ -42,7 +45,7 @@ struct db_lex_context {
};
extern int db_lex(void);
-extern int db_read_line(char *rep_str);
+extern int db_read_line(const char *rep_str);
extern void db_flush_line(void);
extern int db_read_char(void);
extern void db_unread_char(int c);
@@ -51,7 +54,7 @@ extern void db_unread_token(int t);
extern void db_flush_lex(void);
extern void db_switch_input(char *, int);
extern void db_save_lex_context(struct db_lex_context *);
-extern void db_restore_lex_context(struct db_lex_context *);
+extern void db_restore_lex_context(const struct db_lex_context *);
extern void db_skip_to_eol(void);
extern db_expr_t db_tok_number;
@@ -92,3 +95,5 @@ extern db_expr_t db_radix;
#define tLOG_OR 31
#define tSTRING 32
#define tQUESTION 33
+
+#endif /* _DDB_DB_LEX_H_ */
diff --git a/ddb/db_macro.c b/ddb/db_macro.c
index 43bb5837..307b7c59 100644
--- a/ddb/db_macro.c
+++ b/ddb/db_macro.c
@@ -59,9 +59,9 @@ db_expr_t db_macro_args[DB_MACRO_LEVEL][DB_NARGS];
static struct db_user_macro *
db_lookup_macro(name)
- char *name;
+ const char *name;
{
- register struct db_user_macro *mp;
+ struct db_user_macro *mp;
for (mp = db_user_macro; mp < &db_user_macro[DB_NUSER_MACRO]; mp++) {
if (mp->m_name[0] == 0)
@@ -73,11 +73,11 @@ db_lookup_macro(name)
}
void
-db_def_macro_cmd()
+db_def_macro_cmd(void)
{
- register char *p;
- register int c;
- register struct db_user_macro *mp, *ep;
+ char *p;
+ int c;
+ struct db_user_macro *mp, *ep;
if (db_read_token() != tIDENT) {
db_printf("Bad macro name \"%s\"\n", db_tok_string);
@@ -104,9 +104,9 @@ db_def_macro_cmd()
}
void
-db_del_macro_cmd()
+db_del_macro_cmd(void)
{
- register struct db_user_macro *mp;
+ struct db_user_macro *mp;
if (db_read_token() != tIDENT
|| (mp = db_lookup_macro(db_tok_string)) == 0) {
@@ -120,9 +120,9 @@ db_del_macro_cmd()
}
void
-db_show_macro()
+db_show_macro(void)
{
- register struct db_user_macro *mp;
+ struct db_user_macro *mp;
int t;
char *name = 0;
@@ -141,10 +141,10 @@ db_show_macro()
int
db_exec_macro(name)
- char *name;
+ const char *name;
{
- register struct db_user_macro *mp;
- register int n;
+ struct db_user_macro *mp;
+ int n;
if ((mp = db_lookup_macro(name)) == 0)
return(-1);
@@ -165,13 +165,13 @@ db_exec_macro(name)
return(0);
}
-long
+void
/* ARGSUSED */
-db_arg_variable(vp, valuep, flag, ap)
- struct db_variable *vp;
- db_expr_t *valuep;
- int flag;
- db_var_aux_param_t ap;
+db_arg_variable(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap)
{
if (ap->level != 1 || ap->suffix[0] < 1 || ap->suffix[0] > DB_NARGS) {
db_error("Bad $arg variable\n");
@@ -181,7 +181,7 @@ db_arg_variable(vp, valuep, flag, ap)
*valuep = db_macro_args[db_macro_level][ap->suffix[0]-1];
else
db_macro_args[db_macro_level][ap->suffix[0]-1] = *valuep;
- return(0);
+ return;
}
#endif /* MACH_KDB */
diff --git a/ddb/db_macro.h b/ddb/db_macro.h
index da5626f9..2c0a599b 100644
--- a/ddb/db_macro.h
+++ b/ddb/db_macro.h
@@ -30,9 +30,9 @@ extern void db_del_macro_cmd (void);
extern void db_show_macro (void);
-extern int db_exec_macro (char *name);
+extern int db_exec_macro (const char *name);
-extern long db_arg_variable (
+extern void db_arg_variable (
struct db_variable *vp,
db_expr_t *valuep,
int flag,
diff --git a/ddb/db_mp.c b/ddb/db_mp.c
index cc14aea2..8d1a5605 100644
--- a/ddb/db_mp.c
+++ b/ddb/db_mp.c
@@ -38,6 +38,7 @@
#include <ddb/db_command.h>
#include <ddb/db_run.h>
+#include <ddb/db_mp.h>
/*
* Routines to interlock access to the kernel debugger on
@@ -52,12 +53,7 @@ int db_active[NCPUS] = { 0 }; /* count recursive entries
int db_slave[NCPUS] = { 0 }; /* nonzero if cpu interrupted
by another cpu in debugger */
-int db_enter_debug = 0;
-
-void remote_db(); /* forward */
-void lock_db();
-void unlock_db();
-
+boolean_t db_enter_debug = FALSE;
/*
* Called when entering kernel debugger.
@@ -67,7 +63,7 @@ void unlock_db();
*/
boolean_t
-db_enter()
+db_enter(void)
{
int mycpu = cpu_number();
@@ -112,7 +108,7 @@ db_enter()
* Leave debugger.
*/
void
-db_leave()
+db_leave(void)
{
int mycpu = cpu_number();
@@ -147,9 +143,9 @@ db_leave()
*/
void
-remote_db() {
+remote_db(void) {
int my_cpu = cpu_number();
- register int i;
+ int i;
for (i = 0; i < NCPUS; i++) {
if (i != my_cpu &&
@@ -214,8 +210,7 @@ remote_db() {
* switch to another cpu
*/
void
-db_on(cpu)
- int cpu;
+db_on(int cpu)
{
/*
* Save ddb global variables
@@ -254,7 +249,7 @@ db_on(cpu)
* in kernel debugger and wants to stop other CPUs
*/
void
-remote_db_enter()
+remote_db_enter(void)
{
db_slave[cpu_number()]++;
kdb_kintr();
@@ -271,7 +266,7 @@ remote_db_enter()
* is active on another cpu.
*/
void
-lock_db()
+lock_db(void)
{
int my_cpu = cpu_number();
@@ -280,7 +275,7 @@ lock_db()
if (my_cpu == master_cpu) {
db_console();
}
-#endif
+#endif /* CONSOLE_ON_MASTER */
if (db_cpu != -1 && db_cpu != my_cpu)
continue;
@@ -292,9 +287,9 @@ lock_db()
else {
simple_lock(&db_lock);
}
-#else
+#else /* CONSOLE_ON_MASTER */
simple_lock(&db_lock);
-#endif
+#endif /* CONSOLE_ON_MASTER */
if (db_cpu == -1 || db_cpu == my_cpu)
break;
simple_unlock(&db_lock);
@@ -302,14 +297,14 @@ lock_db()
}
void
-unlock_db()
+unlock_db(void)
{
simple_unlock(&db_lock);
}
-#ifdef sketch
+#if CONSOLE_ON_MASTER
void
-db_console()
+db_console(void)
{
if (i_bit(CBUS_PUT_CHAR, my_word)) {
volatile u_char c = cbus_ochar;
@@ -330,7 +325,7 @@ db_console()
db_cpu = my_cpu;
}
}
-#endif /* sketch */
+#endif /* CONSOLE_ON_MASTER */
#endif /* NCPUS > 1 */
diff --git a/ddb/db_mp.h b/ddb/db_mp.h
new file mode 100644
index 00000000..722f28c7
--- /dev/null
+++ b/ddb/db_mp.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _DDB_DB_MP_H_
+#define _DDB_DB_MP_H_
+
+void remote_db(void);
+void lock_db(void);
+void unlock_db(void);
+
+#if CONSOLE_ON_MASTER
+void db_console(void);
+#endif /* CONSOLE_ON_MASTER */
+
+#endif /* _DDB_DB_MP_H_ */
diff --git a/ddb/db_output.c b/ddb/db_output.c
index 3ea2caac..be5319d2 100644
--- a/ddb/db_output.c
+++ b/ddb/db_output.c
@@ -38,9 +38,11 @@
#include <stdarg.h>
#include <mach/boolean.h>
#include <machine/db_machdep.h>
+#include <device/cons.h>
#include <ddb/db_command.h>
#include <ddb/db_lex.h>
#include <ddb/db_output.h>
+#include <ddb/db_input.h>
/*
* Character output - tracks position in line.
@@ -73,15 +75,13 @@ 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();
-
/*
* Force pending whitespace.
*/
void
db_force_whitespace(void)
{
- register int last_print, next_tab;
+ int last_print, next_tab;
last_print = db_last_non_space;
while (last_print < db_output_position) {
@@ -99,9 +99,9 @@ db_force_whitespace(void)
}
static void
-db_more()
+db_more(void)
{
- register char *p;
+ char *p;
boolean_t quit_output = FALSE;
for (p = "--db_more--"; *p; p++)
@@ -132,8 +132,7 @@ db_more()
* Output character. Buffer whitespace.
*/
void
-db_putchar(c)
- int c; /* character to output */
+db_putchar(int c) /* character to output */
{
if (db_max_line >= DB_MIN_MAX_LINE && db_output_line >= db_max_line-1)
db_more();
@@ -188,7 +187,7 @@ db_id_putc(char c, vm_offset_t dummy)
/*
* Return output position
*/
-int
+int __attribute__ ((pure))
db_print_position(void)
{
return (db_output_position);
@@ -209,21 +208,6 @@ db_printf(const char *fmt, ...)
{
va_list listp;
-#ifdef db_printf_enter
- db_printf_enter(); /* optional multiP serialization */
-#endif
- va_start(listp, fmt);
- _doprnt(fmt, listp, db_id_putc, db_radix, 0);
- va_end(listp);
-}
-
-/* alternate name */
-
-/*VARARGS1*/
-void
-kdbprintf(const char *fmt, ...)
-{
- va_list listp;
va_start(listp, fmt);
_doprnt(fmt, listp, db_id_putc, db_radix, 0);
va_end(listp);
diff --git a/ddb/db_output.h b/ddb/db_output.h
index 1159c6ba..497ae430 100644
--- a/ddb/db_output.h
+++ b/ddb/db_output.h
@@ -32,9 +32,15 @@
* Printing routines for kernel debugger.
*/
+#ifndef _DDB_DB_OUTPUT_H_
+#define _DDB_DB_OUTPUT_H_
+
extern void db_force_whitespace(void);
-extern int db_print_position(void);
+extern int db_print_position(void) __attribute__ ((pure));
extern void db_end_line(void);
extern void db_printf(const char *fmt, ...);
+/* alternate name */
+#define kdbprintf db_printf
extern void db_putchar(int c);
-extern void kdbprintf(const char *fmt, ...);
+
+#endif /* _DDB_DB_OUTPUT_H_ */
diff --git a/ddb/db_print.c b/ddb/db_print.c
index 5d0f150b..fb4efaad 100644
--- a/ddb/db_print.c
+++ b/ddb/db_print.c
@@ -51,22 +51,23 @@
#include <ddb/db_variables.h>
#include <ddb/db_sym.h>
#include <ddb/db_task_thread.h>
+#include <ddb/db_print.h>
-extern unsigned int db_maxoff;
+extern unsigned long db_maxoff;
/* ARGSUSED */
void
-db_show_regs(addr, have_addr, count, modif)
- db_expr_t addr;
- boolean_t have_addr;
- db_expr_t count;
- char *modif;
+db_show_regs(
+ db_expr_t addr,
+ boolean_t have_addr,
+ db_expr_t count,
+ char *modif)
{
- register struct db_variable *regp;
+ struct db_variable *regp;
db_expr_t value;
db_addr_t offset;
char * name;
- register int i;
+ int i;
struct db_var_aux_param aux_param;
task_t task = TASK_NULL;
@@ -126,10 +127,10 @@ db_show_regs(addr, have_addr, count, modif)
char *
db_thread_stat(thread, status)
- register thread_t thread;
- char *status;
+ const thread_t thread;
+ char *status;
{
- register char *p = status;
+ char *p = status;
*p++ = (thread->state & TH_RUN) ? 'R' : '.';
*p++ = (thread->state & TH_WAIT) ? 'W' : '.';
@@ -143,10 +144,10 @@ db_thread_stat(thread, status)
}
void
-db_print_thread(thread, thread_id, flag)
- thread_t thread;
- int thread_id;
- int flag;
+db_print_thread(
+ thread_t thread,
+ int thread_id,
+ int flag)
{
if (flag & OPTION_USER) {
char status[8];
@@ -193,12 +194,8 @@ db_print_thread(thread, thread_id, flag)
2*sizeof(vm_offset_t), thread);
else
db_printf("(%0*X) ", 2*sizeof(vm_offset_t), thread);
- db_printf("%c%c%c%c%c",
- (thread->state & TH_RUN) ? 'R' : ' ',
- (thread->state & TH_WAIT) ? 'W' : ' ',
- (thread->state & TH_SUSP) ? 'S' : ' ',
- (thread->state & TH_UNINT)? 'N' : ' ',
- db_thread_fp_used(thread) ? 'F' : ' ');
+ char status[8];
+ db_printf("%s", db_thread_stat(thread, status));
if (thread->state & TH_SWAPPED) {
if (thread->swap_func) {
db_printf("(");
@@ -219,10 +216,10 @@ db_print_thread(thread, thread_id, flag)
}
void
-db_print_task(task, task_id, flag)
- task_t task;
- int task_id;
- int flag;
+db_print_task(
+ task_t task,
+ int task_id,
+ int flag)
{
thread_t thread;
int thread_id;
@@ -257,7 +254,12 @@ db_print_task(task, task_id, flag)
} else {
if (flag & OPTION_TASK_TITLE)
db_printf(" TASK THREADS\n");
- db_printf("%3d (%0*X): ", task_id, 2*sizeof(vm_offset_t), task);
+ if (task->name[0])
+ db_printf("%3d %s (%0*X): ", task_id, task->name,
+ 2*sizeof(vm_offset_t), task);
+ else
+ db_printf("%3d (%0*X): ", task_id,
+ 2*sizeof(vm_offset_t), task);
if (task->thread_count == 0) {
db_printf("no threads\n");
} else {
@@ -274,13 +276,37 @@ db_print_task(task, task_id, flag)
}
}
+void
+db_show_all_tasks(db_expr_t addr,
+ boolean_t have_addr,
+ db_expr_t count,
+ const char *modif)
+{
+ task_t task;
+ int task_id = 0;
+ processor_set_t pset;
+
+ db_printf(" ID %-*s NAME [THREADS]\n", 2*sizeof(vm_offset_t), "TASK");
+
+ queue_iterate(&all_psets, pset, processor_set_t, all_psets)
+ queue_iterate(&pset->tasks, task, task_t, pset_tasks) {
+ db_printf("%3d %0*X %s [%d]\n",
+ task_id,
+ 2*sizeof(vm_offset_t),
+ task,
+ task->name,
+ task->thread_count);
+ task_id++;
+ }
+}
+
/*ARGSUSED*/
void
db_show_all_threads(addr, have_addr, count, modif)
db_expr_t addr;
boolean_t have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
task_t task;
int task_id;
@@ -331,7 +357,7 @@ db_show_one_thread(addr, have_addr, count, modif)
db_expr_t addr;
boolean_t have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
int flag;
int thread_id;
@@ -377,7 +403,7 @@ db_show_one_task(addr, have_addr, count, modif)
db_expr_t addr;
boolean_t have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
int flag;
int task_id;
@@ -409,41 +435,33 @@ db_show_one_task(addr, have_addr, count, modif)
int
db_port_iterate(thread, func)
- thread_t thread;
+ const thread_t thread;
void (*func)();
{
ipc_entry_t entry;
- int index;
int n = 0;
- int size;
- ipc_space_t space;
-
- space = thread->task->itk_space;
- entry = space->is_table;
- size = space->is_table_size;
- for (index = 0; index < size; index++, entry++) {
+ struct rdxtree_iter iter;
+ rdxtree_for_each(&thread->task->itk_space->is_map, &iter, entry) {
if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS)
- (*func)(index, (ipc_port_t) entry->ie_object,
+ (*func)(entry->ie_name, (ipc_port_t) entry->ie_object,
entry->ie_bits, n++);
}
return(n);
}
ipc_port_t
-db_lookup_port(thread, id)
- thread_t thread;
- int id;
+db_lookup_port(
+ thread_t thread,
+ int id)
{
- register ipc_space_t space;
- register ipc_entry_t entry;
+ ipc_entry_t entry;
if (thread == THREAD_NULL)
return(0);
- space = thread->task->itk_space;
- if (id < 0 || id >= space->is_table_size)
+ if (id < 0)
return(0);
- entry = &space->is_table[id];
- if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS)
+ entry = ipc_entry_lookup(thread->task->itk_space, (mach_port_t) id);
+ if (entry && entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS)
return((ipc_port_t)entry->ie_object);
return(0);
}
@@ -451,7 +469,7 @@ db_lookup_port(thread, id)
static void
db_print_port_id(id, port, bits, n)
int id;
- ipc_port_t port;
+ const ipc_port_t port;
unsigned bits;
int n;
{
@@ -465,7 +483,7 @@ db_print_port_id(id, port, bits, n)
static void
db_print_port_id_long(
int id,
- ipc_port_t port,
+ const ipc_port_t port,
unsigned bits,
int n)
{
@@ -483,7 +501,7 @@ db_show_port_id(addr, have_addr, count, modif)
db_expr_t addr;
boolean_t have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
thread_t thread;
diff --git a/ddb/db_print.h b/ddb/db_print.h
index 634c5be4..87db97be 100644
--- a/ddb/db_print.h
+++ b/ddb/db_print.h
@@ -20,91 +20,38 @@ void db_show_regs(
db_expr_t count,
char *modif);
-void db_show_all_acts(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
-void db_show_one_act(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
void db_show_one_task(
db_expr_t addr,
boolean_t have_addr,
db_expr_t count,
- char * modif);
-
-void db_show_shuttle(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
+ const char * modif);
void db_show_port_id(
db_expr_t addr,
boolean_t have_addr,
db_expr_t count,
- char * modif);
+ const char * modif);
-void db_show_one_task_vm(
+void db_show_one_thread(
db_expr_t addr,
- boolean_t have_addr,
+ int have_addr,
db_expr_t count,
- char *modif);
+ const char * modif);
-void db_show_all_task_vm(
+void db_show_all_tasks(
db_expr_t addr,
- boolean_t have_addr,
+ int have_addr,
db_expr_t count,
- char *modif);
+ const char * modif);
-void db_show_one_space(
+void db_show_all_threads(
db_expr_t addr,
- boolean_t have_addr,
+ int have_addr,
db_expr_t count,
- char * modif);
-
-void db_show_all_spaces(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
-void db_sys(void);
-
-int db_port_kmsg_count(
- ipc_port_t port);
+ const char * modif);
db_addr_t db_task_from_space(
ipc_space_t space,
int *task_id);
-void db_show_one_simple_lock(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
-void db_show_one_mutex(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
-void db_show_subsystem(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
-void db_show_runq(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char * modif);
-
#endif /* !_DDB_DB_PRINT_H_ */
diff --git a/ddb/db_run.c b/ddb/db_run.c
index 53a02ce1..9b467fc4 100644
--- a/ddb/db_run.c
+++ b/ddb/db_run.c
@@ -59,24 +59,13 @@ int db_last_inst_count;
int db_load_count;
int db_store_count;
-#ifndef db_set_single_step
-void db_set_task_single_step(/* db_regs_t *, task_t */);/* forward */
-#else
-#define db_set_task_single_step(regs,task) db_set_single_step(regs)
-#endif
-#ifndef db_clear_single_step
-void db_clear_task_single_step(/* db_regs_t *, task_t */);
-#else
-#define db_clear_task_single_step(regs,task) db_clear_single_step(regs)
-#endif
-
boolean_t
-db_stop_at_pc(is_breakpoint, task)
- boolean_t *is_breakpoint;
- task_t task;
+db_stop_at_pc(
+ boolean_t *is_breakpoint,
+ task_t task)
{
- register db_addr_t pc;
- register db_thread_breakpoint_t bkpt;
+ db_addr_t pc;
+ db_thread_breakpoint_t bkpt;
db_clear_task_single_step(DDB_REGS, task);
db_clear_breakpoints();
@@ -92,7 +81,7 @@ db_stop_at_pc(is_breakpoint, task)
FIXUP_PC_AFTER_BREAK
pc = PC_REGS(DDB_REGS);
}
-#endif
+#endif /* FIXUP_PC_AFTER_BREAK */
/*
* Now check for a breakpoint at this address.
@@ -131,7 +120,7 @@ db_stop_at_pc(is_breakpoint, task)
(!inst_return(ins) || --db_call_depth != 0)) {
if (db_sstep_print) {
if (inst_call(ins) || inst_return(ins)) {
- register int i;
+ int i;
db_printf("[after %6d /%4d] ",
db_inst_count,
@@ -167,32 +156,32 @@ db_stop_at_pc(is_breakpoint, task)
}
void
-db_restart_at_pc(watchpt, task)
- boolean_t watchpt;
- task_t task;
+db_restart_at_pc(
+ boolean_t watchpt,
+ task_t task)
{
- register db_addr_t pc = PC_REGS(DDB_REGS), brpc;
+ db_addr_t pc = PC_REGS(DDB_REGS);
if ((db_run_mode == STEP_COUNT) ||
(db_run_mode == STEP_RETURN) ||
(db_run_mode == STEP_CALLT)) {
- db_expr_t ins;
/*
* We are about to execute this instruction,
* so count it now.
*/
- ins = db_get_task_value(pc, sizeof(int), FALSE, task);
+ db_get_task_value(pc, sizeof(int), FALSE, task);
db_inst_count++;
db_load_count += inst_load(ins);
db_store_count += inst_store(ins);
#ifdef SOFTWARE_SSTEP
+ db_addr_t brpc;
/* Account for instructions in delay slots */
- brpc = next_instr_address(pc,1,task);
+ brpc = next_instr_address(pc, 1, task);
if ((brpc != pc) && (inst_branch(ins) || inst_call(ins))) {
/* Note: this ~assumes an instruction <= sizeof(int) */
- ins = db_get_task_value(brpc, sizeof(int), FALSE, task);
+ db_get_task_value(brpc, sizeof(int), FALSE, task);
db_inst_count++;
db_load_count += inst_load(ins);
db_store_count += inst_store(ins);
@@ -217,9 +206,9 @@ db_restart_at_pc(watchpt, task)
}
void
-db_single_step(regs, task)
- db_regs_t *regs;
- task_t task;
+db_single_step(
+ db_regs_t *regs,
+ task_t task)
{
if (db_run_mode == STEP_CONTINUE) {
db_run_mode = STEP_INVISIBLE;
@@ -260,10 +249,10 @@ db_single_step(regs, task)
db_breakpoint_t db_not_taken_bkpt = 0;
db_breakpoint_t db_taken_bkpt = 0;
-db_breakpoint_t
+db_breakpoint_t __attribute__ ((pure))
db_find_temp_breakpoint(task, addr)
- task_t task;
- db_addr_t addr;
+ const task_t task;
+ db_addr_t addr;
{
if (db_taken_bkpt && (db_taken_bkpt->address == addr) &&
db_taken_bkpt->task == task)
@@ -275,13 +264,13 @@ db_find_temp_breakpoint(task, addr)
}
void
-db_set_task_single_step(regs, task)
- register db_regs_t *regs;
- task_t task;
+db_set_task_single_step(
+ db_regs_t *regs,
+ task_t task)
{
db_addr_t pc = PC_REGS(regs), brpc;
- register unsigned int inst;
- register boolean_t unconditional;
+ unsigned int inst;
+ boolean_t unconditional;
/*
* User was stopped at pc, e.g. the instruction
@@ -321,8 +310,8 @@ db_set_task_single_step(regs, task)
void
db_clear_task_single_step(regs, task)
- db_regs_t *regs;
- task_t task;
+ const db_regs_t *regs;
+ task_t task;
{
if (db_taken_bkpt != 0) {
db_delete_temp_breakpoint(task, db_taken_bkpt);
@@ -346,7 +335,7 @@ db_single_step_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
boolean_t print = FALSE;
@@ -374,7 +363,7 @@ db_trace_until_call_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
boolean_t print = FALSE;
@@ -397,7 +386,7 @@ db_trace_until_matching_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
boolean_t print = FALSE;
@@ -422,7 +411,7 @@ db_continue_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
if (modif[0] == 'c')
db_run_mode = STEP_COUNT;
@@ -437,7 +426,7 @@ db_continue_cmd(addr, have_addr, count, modif)
}
boolean_t
-db_in_single_step()
+db_in_single_step(void)
{
return(db_run_mode != STEP_NONE && db_run_mode != STEP_CONTINUE);
}
diff --git a/ddb/db_run.h b/ddb/db_run.h
index 31c0e376..c042d4ca 100644
--- a/ddb/db_run.h
+++ b/ddb/db_run.h
@@ -24,6 +24,9 @@
* the rights to redistribute these changes.
*/
+#ifndef _DDB_DB_RUN_H_
+#define _DDB_DB_RUN_H_
+
#include <kern/task.h>
#include <machine/db_machdep.h>
@@ -43,8 +46,49 @@ extern void db_single_step(db_regs_t *regs, task_t task);
extern void db_single_step_cmd(
db_expr_t addr,
- int have_addr,
+ int have_addr,
+ db_expr_t count,
+ const char *modif);
+
+void db_trace_until_call_cmd(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
+void db_trace_until_matching_cmd(
+ db_expr_t addr,
+ int have_addr,
db_expr_t count,
- char *modif);
+ const char * modif);
+
+void db_continue_cmd(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
+#ifndef db_set_single_step
+void db_set_task_single_step(db_regs_t *, task_t);
+#else
+#define db_set_task_single_step(regs, task) db_set_single_step(regs)
+#endif
+#ifndef db_clear_single_step
+void db_clear_task_single_step(const db_regs_t *, task_t);
+#else
+#define db_clear_task_single_step(regs, task) db_clear_single_step(regs)
+#endif
extern boolean_t db_in_single_step(void);
+
+extern void
+db_restart_at_pc(
+ boolean_t watchpt,
+ task_t task);
+
+extern boolean_t
+db_stop_at_pc(
+ boolean_t *is_breakpoint,
+ task_t task);
+
+#endif /* _DDB_DB_RUN_H_ */
diff --git a/ddb/db_sym.c b/ddb/db_sym.c
index 5c5f7006..2abd5746 100644
--- a/ddb/db_sym.c
+++ b/ddb/db_sym.c
@@ -37,6 +37,8 @@
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
#include <ddb/db_task_thread.h>
+#include <ddb/db_aout.h>
+#include <ddb/db_elf.h>
#include <vm/vm_map.h> /* vm_map_t */
@@ -50,21 +52,19 @@ int db_nsymtab = 0;
db_symtab_t *db_last_symtab;
-db_sym_t db_lookup(); /* forward */
-
/*
* Add symbol table, with given name, to list of symbol tables.
*/
boolean_t
-db_add_symbol_table(type, start, end, name, ref, map_pointer)
- int type;
- char *start;
- char *end;
- char *name;
- char *ref;
- char *map_pointer;
+db_add_symbol_table(
+ int type,
+ char *start,
+ char *end,
+ char *name,
+ char *ref,
+ char *map_pointer)
{
- register db_symtab_t *st;
+ db_symtab_t *st;
extern vm_map_t kernel_map;
if (db_nsymtab >= MAXNOSYMTABS)
@@ -76,7 +76,8 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer)
st->end = end;
st->private = ref;
st->map_pointer = (map_pointer == (char *)kernel_map)? 0: map_pointer;
- strcpy(st->name, name);
+ strncpy(st->name, name, sizeof st->name - 1);
+ st->name[sizeof st->name - 1] = '\0';
db_nsymtab++;
@@ -89,13 +90,13 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer)
* Note: return value points to static data whose content is
* overwritten by each call... but in practice this seems okay.
*/
-static char *
+static char * __attribute__ ((pure))
db_qualify(symname, symtabname)
- char *symname;
- register char *symtabname;
+ const char *symname;
+ const char *symtabname;
{
static char tmp[256];
- register char *s;
+ char *s;
s = tmp;
while ((*s++ = *symtabname++)) {
@@ -109,7 +110,7 @@ db_qualify(symname, symtabname)
boolean_t
-db_eqname( char* src, char* dst, char c )
+db_eqname( const char* src, const char* dst, char c )
{
if (!strcmp(src, dst))
return (TRUE);
@@ -119,9 +120,9 @@ db_eqname( char* src, char* dst, char c )
}
boolean_t
-db_value_of_name(name, valuep)
- char *name;
- db_expr_t *valuep;
+db_value_of_name(
+ char *name,
+ db_expr_t *valuep)
{
db_sym_t sym;
@@ -141,14 +142,13 @@ db_value_of_name(name, valuep)
* otherwise, all symbol tables will be searched.
*/
db_sym_t
-db_lookup(symstr)
- char *symstr;
+db_lookup(char *symstr)
{
db_sym_t sp;
- register int i;
+ int i;
int symtab_start = 0;
int symtab_end = db_nsymtab;
- register char *cp;
+ char *cp;
/*
* Look for, remove, and remember any symbol table specifier.
@@ -193,13 +193,13 @@ db_lookup(symstr)
* with parsed file name, symbol name and line number.
*/
db_sym_t
-db_sym_parse_and_lookup(func, symtab, symstr)
- db_sym_t (*func)();
- db_symtab_t *symtab;
- char *symstr;
+db_sym_parse_and_lookup(
+ db_sym_t (*func)(),
+ db_symtab_t *symtab,
+ char *symstr)
{
- register char *p;
- register int n;
+ char *p;
+ int n;
int n_name;
int line_number;
char *file_name = 0;
@@ -265,19 +265,17 @@ out:
boolean_t db_qualify_ambiguous_names = FALSE;
boolean_t
-db_name_is_ambiguous(sym_name)
- char *sym_name;
+db_name_is_ambiguous(char *sym_name)
{
- register int i;
- register
+ int i;
boolean_t found_once = FALSE;
if (!db_qualify_ambiguous_names)
return FALSE;
for (i = 0; i < db_nsymtab; i++) {
- db_sym_t sp;
- if (sp = X_db_lookup(&db_symtabs[i], sym_name)) {
+ db_sym_t sp = X_db_lookup(&db_symtabs[i], sym_name);
+ if (sp) {
if (found_once)
{
db_free_symbol(sp);
@@ -290,26 +288,23 @@ db_name_is_ambiguous(sym_name)
return FALSE;
}
-
-db_sym_t db_search_in_task_symbol();
-
/*
* Find the closest symbol to val, and return its name
* and the difference between val and the symbol found.
*
* Logic change. If the task argument is non NULL and a
- * matching symbol is found in a symbol table which explictly
+ * matching symbol is found in a symbol table which explicitly
* specifies its map to be task->map, that symbol will have
* precedence over any symbol from a symbol table will a null
* map. This allows overlapping kernel/user maps to work correctly.
*
*/
db_sym_t
-db_search_task_symbol(val, strategy, offp, task)
- register db_addr_t val;
- db_strategy_t strategy;
- db_addr_t *offp; /* better be unsigned */
- task_t task;
+db_search_task_symbol(
+ db_addr_t val,
+ db_strategy_t strategy,
+ db_addr_t *offp, /* better be unsigned */
+ task_t task)
{
db_sym_t ret;
@@ -334,15 +329,15 @@ db_search_task_symbol(val, strategy, offp, task)
}
db_sym_t
-db_search_in_task_symbol(val, strategy, offp, task)
- register db_addr_t val;
- db_strategy_t strategy;
- db_addr_t *offp;
- task_t task;
+db_search_in_task_symbol(
+ db_addr_t val,
+ db_strategy_t strategy,
+ db_addr_t *offp,
+ task_t task)
{
- register vm_size_t diff;
+ vm_size_t diff;
vm_size_t newdiff;
- register int i;
+ int i;
db_symtab_t *sp;
db_sym_t ret = DB_SYM_NULL, sym;
vm_map_t map_for_val;
@@ -402,11 +397,11 @@ db_search_in_task_symbol(val, strategy, offp, task)
* Return name and value of a symbol
*/
void
-db_symbol_values(stab, sym, namep, valuep)
- db_symtab_t *stab;
- db_sym_t sym;
- char **namep;
- db_expr_t *valuep;
+db_symbol_values(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **namep,
+ db_expr_t *valuep)
{
db_expr_t value;
char *name;
@@ -449,7 +444,7 @@ unsigned long db_maxoff = 0x4000;
void
db_task_printsym(off, strategy, task)
- db_expr_t off;
+ db_addr_t off;
db_strategy_t strategy;
task_t task;
{
@@ -494,7 +489,7 @@ db_line_at_pc( sym, filename, linenum, pc)
db_sym_t sym;
char **filename;
int *linenum;
- db_expr_t pc;
+ db_addr_t pc;
{
return (db_last_symtab) ?
X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc) :
@@ -512,15 +507,11 @@ void db_free_symbol(db_sym_t s)
* Switch into symbol-table specific routines
*/
-extern boolean_t aout_db_sym_init(), aout_db_line_at_pc();
-extern db_sym_t aout_db_lookup(), aout_db_search_symbol();
-extern void aout_db_symbol_values();
-
-extern boolean_t coff_db_sym_init(), coff_db_line_at_pc();
-extern db_sym_t coff_db_lookup(), coff_db_search_symbol();
-extern void coff_db_symbol_values();
+void dummy_db_free_symbol(db_sym_t symbol) { }
+boolean_t dummy_db_sym_init(char *a, char *b, char *c, char *d) {
+ return FALSE;
+}
-void dummy_db_free_symbol(sym_t) { }
struct db_sym_switch x_db[] = {
@@ -532,15 +523,17 @@ struct db_sym_switch x_db[] = {
aout_db_line_at_pc, aout_db_symbol_values, dummy_db_free_symbol },
#endif /* DB_NO_AOUT */
-#ifdef DB_NO_COFF
{ 0,},
-#else /* DB_NO_COFF */
- { coff_db_sym_init, coff_db_lookup, coff_db_search_symbol,
- coff_db_line_at_pc, coff_db_symbol_values, dummy_db_free_symbol },
-#endif /* DB_NO_COFF */
/* Machdep, not inited here */
- { 0,}
+ { 0,},
+
+#ifdef DB_NO_ELF
+ { 0,},
+#else /* DB_NO_ELF */
+ { dummy_db_sym_init, elf_db_lookup, elf_db_search_symbol,
+ elf_db_line_at_pc, elf_db_symbol_values, dummy_db_free_symbol },
+#endif /* DB_NO_ELF */
};
diff --git a/ddb/db_sym.h b/ddb/db_sym.h
index e40264ab..d8f33874 100644
--- a/ddb/db_sym.h
+++ b/ddb/db_sym.h
@@ -46,6 +46,7 @@ typedef struct {
#define SYMTAB_AOUT 0
#define SYMTAB_COFF 1
#define SYMTAB_MACHDEP 2
+#define SYMTAB_ELF 3
char *start; /* symtab location */
char *end;
char *private; /* optional machdep pointer */
@@ -161,10 +162,10 @@ extern void db_symbol_values( db_symtab_t *stab,
db_search_task_symbol(val,strgy,offp,0)
/* strcmp, modulo leading char */
-extern boolean_t db_eqname( char* src, char* dst, char c );
+extern boolean_t db_eqname( const char* src, const char* dst, char c );
/* print closest symbol to a value */
-extern void db_task_printsym( db_expr_t off,
+extern void db_task_printsym( db_addr_t off,
db_strategy_t strategy,
task_t task);
@@ -205,7 +206,7 @@ extern struct db_sym_switch {
db_sym_t sym,
char **file,
int *line,
- db_expr_t pc
+ db_addr_t pc
);
void (*symbol_values)(
@@ -235,6 +236,35 @@ extern boolean_t db_line_at_pc(
db_sym_t sym,
char **filename,
int *linenum,
- db_expr_t pc);
-
-#endif
+ db_addr_t pc);
+
+extern boolean_t aout_db_sym_init(
+ char *symtab,
+ char *esymtab,
+ char *name,
+ char *task_addr);
+
+extern boolean_t elf_db_sym_init (
+ unsigned shdr_num,
+ vm_size_t shdr_size,
+ vm_offset_t shdr_addr,
+ unsigned shdr_shndx,
+ char *name,
+ char *task_addr);
+
+db_sym_t db_lookup(char *);
+
+db_sym_t
+db_search_in_task_symbol(
+ db_addr_t val,
+ db_strategy_t strategy,
+ db_addr_t *offp,
+ task_t task);
+
+extern db_sym_t
+db_sym_parse_and_lookup(
+ db_sym_t (*func)(),
+ db_symtab_t *symtab,
+ char *symstr);
+
+#endif /* _DDB_DB_SYM_H_ */
diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c
index 1146223b..7927e674 100644
--- a/ddb/db_task_thread.c
+++ b/ddb/db_task_thread.c
@@ -52,12 +52,12 @@ thread_t db_default_thread; /* default target thread */
*/
int
db_lookup_task(target_task)
- task_t target_task;
+ const task_t target_task;
{
- register task_t task;
- register int task_id;
- register processor_set_t pset;
- register int npset = 0;
+ task_t task;
+ int task_id;
+ processor_set_t pset;
+ int npset = 0;
task_id = 0;
if (queue_first(&all_psets) == 0)
@@ -82,11 +82,11 @@ db_lookup_task(target_task)
*/
int
db_lookup_task_thread(task, target_thread)
- task_t task;
- thread_t target_thread;
+ const task_t task;
+ const thread_t target_thread;
{
- register thread_t thread;
- register int thread_id;
+ thread_t thread;
+ int thread_id;
thread_id = 0;
if (queue_first(&task->thread_list) == 0)
@@ -106,13 +106,13 @@ db_lookup_task_thread(task, target_thread)
*/
int
db_lookup_thread(target_thread)
- thread_t target_thread;
+ const thread_t target_thread;
{
- register int thread_id;
- register task_t task;
- register processor_set_t pset;
- register int ntask = 0;
- register int npset = 0;
+ int thread_id;
+ task_t task;
+ processor_set_t pset;
+ int ntask = 0;
+ int npset = 0;
if (queue_first(&all_psets) == 0)
return(-1);
@@ -139,7 +139,7 @@ db_lookup_thread(target_thread)
*/
boolean_t
db_check_thread_address_valid(thread)
- thread_t thread;
+ const thread_t thread;
{
if (db_lookup_thread(thread) < 0) {
db_printf("Bad thread address 0x%x\n", thread);
@@ -150,15 +150,14 @@ db_check_thread_address_valid(thread)
}
/*
- * convert task_id(queue postion) to task address
+ * convert task_id(queue position) to task address
*/
task_t
-db_lookup_task_id(task_id)
- register int task_id;
+db_lookup_task_id(int task_id)
{
- register task_t task;
- register processor_set_t pset;
- register int npset = 0;
+ task_t task;
+ processor_set_t pset;
+ int npset = 0;
if (task_id > DB_MAX_TASKID)
return(TASK_NULL);
@@ -181,11 +180,11 @@ db_lookup_task_id(task_id)
* convert (task_id, thread_id) pair to thread address
*/
static thread_t
-db_lookup_thread_id(task, thread_id)
- task_t task;
- register int thread_id;
+db_lookup_thread_id(
+ task_t task,
+ int thread_id)
{
- register thread_t thread;
+ thread_t thread;
if (thread_id > DB_MAX_THREADID)
@@ -204,9 +203,9 @@ db_lookup_thread_id(task, thread_id)
* thread address
*/
boolean_t
-db_get_next_thread(threadp, position)
- thread_t *threadp;
- int position;
+db_get_next_thread(
+ thread_t *threadp,
+ int position)
{
db_expr_t value;
thread_t thread;
@@ -245,17 +244,18 @@ db_init_default_thread(void)
* in the command line
*/
/* ARGSUSED */
-long
-db_set_default_thread(vp, valuep, flag)
- struct db_variable *vp;
- db_expr_t *valuep;
- int flag;
+void
+db_set_default_thread(vp, valuep, flag, ap)
+ struct db_variable *vp;
+ db_expr_t *valuep;
+ int flag;
+ db_var_aux_param_t ap;
{
thread_t thread;
if (flag != DB_VAR_SET) {
*valuep = (db_expr_t) db_default_thread;
- return(0);
+ return;
}
thread = (thread_t) *valuep;
if (thread != THREAD_NULL && !db_check_thread_address_valid(thread))
@@ -264,18 +264,18 @@ db_set_default_thread(vp, valuep, flag)
db_default_thread = thread;
if (thread)
db_default_task = thread->task;
- return(0);
+ return;
}
/*
* convert $taskXXX[.YYY] type DDB variable to task or thread address
*/
-long
-db_get_task_thread(vp, valuep, flag, ap)
- struct db_variable *vp;
- db_expr_t *valuep;
- int flag;
- db_var_aux_param_t ap;
+void
+db_get_task_thread(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap)
{
task_t task;
thread_t thread;
@@ -291,7 +291,7 @@ db_get_task_thread(vp, valuep, flag, ap)
}
if (ap->level <= 1) {
*valuep = (db_expr_t) task;
- return(0);
+ return;
}
if ((thread = db_lookup_thread_id(task, ap->suffix[1])) == THREAD_NULL){
db_printf("no such thread($task%d.%d)\n",
@@ -300,7 +300,7 @@ db_get_task_thread(vp, valuep, flag, ap)
/* NOTREACHED */
}
*valuep = (db_expr_t) thread;
- return(0);
+ return;
}
#endif /* MACH_KDB */
diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h
index ebf99d8d..cbb36802 100644
--- a/ddb/db_task_thread.h
+++ b/ddb/db_task_thread.h
@@ -27,6 +27,8 @@
#ifndef _DDB_DB_TASK_THREAD_H_
#define _DDB_DB_TASK_THREAD_H_
+#include <ddb/db_variables.h>
+
#include <kern/task.h>
#include <kern/thread.h>
@@ -41,11 +43,25 @@
extern task_t db_default_task; /* default target task */
extern thread_t db_default_thread; /* default target thread */
-extern int db_lookup_task(task_t);
-extern int db_lookup_thread(thread_t);
-extern int db_lookup_task_thread(task_t, thread_t);
-extern boolean_t db_check_thread_address_valid(thread_t);
+extern int db_lookup_task(const task_t);
+extern int db_lookup_thread(const thread_t);
+extern int db_lookup_task_thread(const task_t, const thread_t);
+extern boolean_t db_check_thread_address_valid(const thread_t);
extern boolean_t db_get_next_thread(thread_t *, int);
extern void db_init_default_thread(void);
+extern void
+db_set_default_thread(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap);
+
+extern void
+db_get_task_thread(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap);
+
#endif /* _DDB_DB_TASK_THREAD_H_ */
diff --git a/ddb/db_trap.c b/ddb/db_trap.c
index 395a9b51..7e107319 100644
--- a/ddb/db_trap.c
+++ b/ddb/db_trap.c
@@ -35,6 +35,7 @@
*/
#include <mach/boolean.h>
#include <machine/db_machdep.h>
+#include <machine/setjmp.h>
#include <ddb/db_command.h>
#include <ddb/db_access.h>
#include <ddb/db_break.h>
@@ -42,28 +43,26 @@
#include <ddb/db_output.h>
#include <ddb/db_task_thread.h>
#include <ddb/db_trap.h>
+#include <ddb/db_run.h>
+#include <machine/db_interface.h>
extern jmp_buf_t *db_recover;
-extern void db_restart_at_pc();
-extern boolean_t db_stop_at_pc();
-
extern int db_inst_count;
extern int db_load_count;
extern int db_store_count;
void
-db_task_trap(type, code, user_space)
- int type, code;
- boolean_t user_space;
+db_task_trap(
+ int type,
+ int code,
+ boolean_t user_space)
{
jmp_buf_t db_jmpbuf;
jmp_buf_t *prev;
boolean_t bkpt;
boolean_t watchpt;
- void db_init_default_thread();
- void db_check_breakpoint_valid();
task_t task_space;
task_space = db_target_space(current_thread(), user_space);
@@ -90,6 +89,9 @@ db_task_trap(type, code, user_space)
db_print_loc_and_inst(db_dot, task_space);
else
db_printf("Trouble printing location %#X.\n", db_dot);
+
+ if (!bkpt && !watchpt && _setjmp(db_recover = &db_jmpbuf) == 0)
+ db_stack_trace_cmd(0, 0, -1, "");
db_recover = prev;
db_command_loop();
@@ -99,8 +101,9 @@ db_task_trap(type, code, user_space)
}
void
-db_trap(type, code)
- int type, code;
+db_trap(
+ int type,
+ int code)
{
db_task_trap(type, code, !DB_VALID_KERN_ADDR(PC_REGS(DDB_REGS)));
}
diff --git a/ddb/db_variables.c b/ddb/db_variables.c
index 55b87422..4442ccbc 100644
--- a/ddb/db_variables.c
+++ b/ddb/db_variables.c
@@ -39,6 +39,7 @@
#include <ddb/db_output.h>
#include <ddb/db_variables.h>
#include <ddb/db_task_thread.h>
+#include <ddb/db_macro.h>
extern unsigned long db_maxoff;
@@ -46,9 +47,6 @@ extern db_expr_t db_radix;
extern db_expr_t db_max_width;
extern db_expr_t db_tab_stop_width;
extern db_expr_t db_max_line;
-extern int db_set_default_thread();
-extern int db_get_task_thread();
-extern int db_arg_variable();
#define DB_NWORK 32 /* number of work variable */
@@ -70,12 +68,12 @@ struct db_variable db_vars[] = {
};
struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
-char *
+const char *
db_get_suffix(suffix, suffix_value)
- register char *suffix;
+ const char *suffix;
short *suffix_value;
{
- register int value;
+ int value;
for (value = 0; *suffix && *suffix != '.' && *suffix != ':'; suffix++) {
if (*suffix < '0' || *suffix > '9')
@@ -92,10 +90,11 @@ static boolean_t
db_cmp_variable_name(vp, name, ap)
struct db_variable *vp;
char *name;
- register db_var_aux_param_t ap;
+ const db_var_aux_param_t ap;
{
- register char *var_np, *np;
- register int level;
+ char *var_np;
+ const char *np;
+ int level;
for (np = name, var_np = vp->name; *var_np; ) {
if (*np++ != *var_np++)
@@ -116,9 +115,9 @@ db_cmp_variable_name(vp, name, ap)
}
int
-db_find_variable(varp, ap)
- struct db_variable **varp;
- db_var_aux_param_t ap;
+db_find_variable(
+ struct db_variable **varp,
+ db_var_aux_param_t ap)
{
int t;
struct db_variable *vp;
@@ -143,12 +142,8 @@ db_find_variable(varp, ap)
return (0);
}
-
-void db_read_write_variable(); /* forward */
-
int
-db_get_variable(valuep)
- db_expr_t *valuep;
+db_get_variable(db_expr_t *valuep)
{
struct db_variable *vp;
struct db_var_aux_param aux_param;
@@ -164,8 +159,7 @@ db_get_variable(valuep)
}
int
-db_set_variable(value)
- db_expr_t value;
+db_set_variable(db_expr_t value)
{
struct db_variable *vp;
struct db_var_aux_param aux_param;
@@ -181,13 +175,13 @@ db_set_variable(value)
}
void
-db_read_write_variable(vp, valuep, rw_flag, ap)
- struct db_variable *vp;
- db_expr_t *valuep;
- int rw_flag;
- db_var_aux_param_t ap;
+db_read_write_variable(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int rw_flag,
+ db_var_aux_param_t ap)
{
- int (*func)() = vp->fcn;
+ void (*func)() = vp->fcn;
struct db_var_aux_param aux_param;
if (ap == 0) {
@@ -206,7 +200,7 @@ db_read_write_variable(vp, valuep, rw_flag, ap)
}
void
-db_set_cmd()
+db_set_cmd(void)
{
db_expr_t value;
int t;
diff --git a/ddb/db_variables.h b/ddb/db_variables.h
index 5249d18c..9880d50f 100644
--- a/ddb/db_variables.h
+++ b/ddb/db_variables.h
@@ -32,6 +32,7 @@
#define _DB_VARIABLES_H_
#include <kern/thread.h>
+#include <machine/db_machdep.h>
/*
* Debugger variables.
@@ -42,7 +43,7 @@ struct db_variable {
char *name; /* Name of variable */
db_expr_t *valuep; /* pointer to value of variable */
/* function to call when reading/writing */
- long (*fcn)(struct db_variable *, db_expr_t *, int, db_var_aux_param_t);
+ void (*fcn)(struct db_variable *, db_expr_t *, int, db_var_aux_param_t);
short min_level; /* number of minimum suffix levels */
short max_level; /* number of maximum suffix levels */
short low; /* low value of level 1 suffix */
@@ -50,7 +51,7 @@ struct db_variable {
#define DB_VAR_GET 0
#define DB_VAR_SET 1
};
-#define FCN_NULL ((long (*)())0)
+#define FCN_NULL ((void (*)())0)
#define DB_VAR_LEVEL 3 /* maximum number of suffix level */
@@ -80,4 +81,8 @@ extern struct db_variable *db_eregs;
extern int db_get_variable(db_expr_t *valuep);
+void db_set_cmd(void);
+
+void db_read_write_variable(struct db_variable *, db_expr_t *, int, struct db_var_aux_param *);
+
#endif /* _DB_VARIABLES_H_ */
diff --git a/ddb/db_watch.c b/ddb/db_watch.c
index 072f474a..f0d0443f 100644
--- a/ddb/db_watch.c
+++ b/ddb/db_watch.c
@@ -37,6 +37,7 @@
#include <vm/vm_map.h>
#include <machine/db_machdep.h>
+#include <machine/db_interface.h>
#include <ddb/db_command.h>
#include <ddb/db_lex.h>
#include <ddb/db_watch.h>
@@ -64,9 +65,9 @@ db_watchpoint_t db_watchpoint_list = 0;
extern vm_map_t kernel_map;
db_watchpoint_t
-db_watchpoint_alloc()
+db_watchpoint_alloc(void)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
if ((watch = db_free_watchpoints) != 0) {
db_free_watchpoints = watch->link;
@@ -84,7 +85,7 @@ db_watchpoint_alloc()
void
db_watchpoint_free(watch)
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
{
watch->link = db_free_watchpoints;
db_free_watchpoints = watch;
@@ -92,11 +93,11 @@ db_watchpoint_free(watch)
void
db_set_watchpoint(task, addr, size)
- task_t task;
+ const task_t task;
db_addr_t addr;
vm_size_t size;
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
/*
* Should we do anything fancy with overlapping regions?
@@ -129,11 +130,11 @@ db_set_watchpoint(task, addr, size)
void
db_delete_watchpoint(task, addr)
- task_t task;
+ const task_t task;
db_addr_t addr;
{
- register db_watchpoint_t watch;
- register db_watchpoint_t *prev;
+ db_watchpoint_t watch;
+ db_watchpoint_t *prev;
for (prev = &db_watchpoint_list; (watch = *prev) != 0;
prev = &watch->link) {
@@ -152,8 +153,8 @@ db_delete_watchpoint(task, addr)
void
db_list_watchpoints(void)
{
- register db_watchpoint_t watch;
- int task_id;
+ db_watchpoint_t watch;
+ int task_id;
if (db_watchpoint_list == 0) {
db_printf("No watchpoints set\n");
@@ -178,7 +179,7 @@ db_list_watchpoints(void)
static int
db_get_task(modif, taskp, addr)
- char *modif;
+ const char *modif;
task_t *taskp;
db_addr_t addr;
{
@@ -220,7 +221,7 @@ db_deletewatch_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
task_t task;
@@ -236,12 +237,11 @@ db_watchpoint_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
vm_size_t size;
db_expr_t value;
task_t task;
- boolean_t db_option();
if (db_get_task(modif, &task, addr) < 0)
return;
@@ -254,7 +254,7 @@ db_watchpoint_cmd(addr, have_addr, count, modif)
/* list watchpoints */
void
-db_listwatch_cmd()
+db_listwatch_cmd(void)
{
db_list_watchpoints();
}
@@ -262,11 +262,16 @@ db_listwatch_cmd()
void
db_set_watchpoints(void)
{
- register db_watchpoint_t watch;
- vm_map_t map;
+ db_watchpoint_t watch;
+ vm_map_t map;
+ unsigned hw_idx = 0;
if (!db_watchpoints_inserted) {
for (watch = db_watchpoint_list; watch != 0; watch = watch->link) {
+ if (db_set_hw_watchpoint(watch, hw_idx)) {
+ hw_idx++;
+ continue;
+ }
map = (watch->task)? watch->task->map: kernel_map;
pmap_protect(map->pmap,
trunc_page(watch->loaddr),
@@ -280,18 +285,23 @@ db_set_watchpoints(void)
void
db_clear_watchpoints(void)
{
+ unsigned hw_idx = 0;
+
+ while (db_clear_hw_watchpoint(hw_idx))
+ hw_idx++;
+
db_watchpoints_inserted = FALSE;
}
boolean_t
-db_find_watchpoint(map, addr, regs)
- vm_map_t map;
- db_addr_t addr;
- db_regs_t *regs;
+db_find_watchpoint(
+ vm_map_t map,
+ db_addr_t addr,
+ db_regs_t *regs)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
db_watchpoint_t found = 0;
- register task_t task_space;
+ task_t task_space;
task_space = (map == kernel_map)? TASK_NULL: db_current_task();
for (watch = db_watchpoint_list; watch != 0; watch = watch->link) {
diff --git a/ddb/db_watch.h b/ddb/db_watch.h
index a7acb39e..7ef1a207 100644
--- a/ddb/db_watch.h
+++ b/ddb/db_watch.h
@@ -49,14 +49,28 @@ typedef struct db_watchpoint {
} *db_watchpoint_t;
extern boolean_t db_find_watchpoint(vm_map_t map, db_addr_t addr,
- db_regs_t *regs);
+ db_regs_t *regs);
extern void db_set_watchpoints(void);
extern void db_clear_watchpoints(void);
-extern void db_set_watchpoint(task_t task, db_addr_t addr, vm_size_t size);
-extern void db_delete_watchpoint(task_t task, db_addr_t addr);
+extern void db_set_watchpoint(const task_t task, db_addr_t addr, vm_size_t size);
+extern void db_delete_watchpoint(const task_t task, db_addr_t addr);
extern void db_list_watchpoints(void);
+void db_listwatch_cmd(void);
+
+void db_deletewatch_cmd(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
+void db_watchpoint_cmd(
+ db_expr_t addr,
+ int have_addr,
+ db_expr_t count,
+ const char * modif);
+
#endif /* _DDB_DB_WATCH_ */
#endif /* MACH_KDB */
diff --git a/ddb/db_write_cmd.c b/ddb/db_write_cmd.c
index eacf53b4..46a2ee32 100644
--- a/ddb/db_write_cmd.c
+++ b/ddb/db_write_cmd.c
@@ -55,12 +55,12 @@ db_write_cmd(address, have_addr, count, modif)
db_expr_t address;
boolean_t have_addr;
db_expr_t count;
- char * modif;
+ const char * modif;
{
- register db_addr_t addr;
- register db_expr_t old_value;
+ db_addr_t addr;
+ db_expr_t old_value;
db_expr_t new_value;
- register int size;
+ int size;
boolean_t wrote_one = FALSE;
boolean_t t_opt, u_opt;
thread_t thread;
diff --git a/ddb/db_write_cmd.h b/ddb/db_write_cmd.h
new file mode 100644
index 00000000..3a1d0575
--- /dev/null
+++ b/ddb/db_write_cmd.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _DDB_DB_WRITE_CMD_H_
+#define _DDB_DB_WRITE_CMD_H_
+
+#include <mach/boolean.h>
+#include <machine/db_machdep.h>
+
+/* Prototypes for functions exported by this module.
+ */
+
+void db_write_cmd(
+ db_expr_t address,
+ boolean_t have_addr,
+ db_expr_t count,
+ const char * modif);
+
+#endif /* !_DDB_DB_WRITE_CMD_H_ */
diff --git a/ddb/stab.h b/ddb/stab.h
index 3ebc1af8..55e9d452 100644
--- a/ddb/stab.h
+++ b/ddb/stab.h
@@ -33,6 +33,8 @@
* @(#)stab.h 5.2 (Berkeley) 4/4/91
*/
+#ifndef _DDB_STAB_H_
+#define _DDB_STAB_H_
/*
* The following are symbols used by various debuggers and by the Pascal
@@ -67,3 +69,5 @@
#define N_ECOMM 0xe4 /* end common */
#define N_ECOML 0xe8 /* end common (local name) */
#define N_LENG 0xfe /* length of preceding entry */
+
+#endif /* _DDB_STAB_H_ */