diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-04-19 10:12:37 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-04-19 10:12:37 +0000 |
commit | 9753f8926234c5209a981963d9da79915d452dad (patch) | |
tree | 342d33f811305bfca251b6f6e619271f10e6f972 /sys | |
parent | 97c55638692ca49b78b34b6b09a24864767d8dd0 (diff) |
Keep db_write_cmd() in the only place where it is used, just like we did
with db_show_regs().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/files | 3 | ||||
-rw-r--r-- | sys/ddb/db_command.c | 68 | ||||
-rw-r--r-- | sys/ddb/db_extern.h | 5 | ||||
-rw-r--r-- | sys/ddb/db_write_cmd.c | 105 |
4 files changed, 69 insertions, 112 deletions
diff --git a/sys/conf/files b/sys/conf/files index 3fe140b33fb..048b557b6b7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.616 2016/03/25 18:53:41 zhuk Exp $ +# $OpenBSD: files,v 1.617 2016/04/19 10:12:36 mpi Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -611,7 +611,6 @@ file ddb/db_sym.c ddb file ddb/db_trap.c ddb file ddb/db_variables.c ddb file ddb/db_watch.c ddb -file ddb/db_write_cmd.c ddb file ddb/db_usrreq.c ddb file dev/audio.c audio needs-flag file dev/cons.c diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index e698ce6ab3c..52cc29010c7 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.69 2016/03/09 09:04:15 mpi Exp $ */ +/* $OpenBSD: db_command.c,v 1.70 2016/04/19 10:12:36 mpi Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -43,6 +43,7 @@ #include <uvm/uvm_extern.h> #include <machine/db_machdep.h> /* type definitions */ +#include <ddb/db_access.h> #include <ddb/db_lex.h> #include <ddb/db_output.h> #include <ddb/db_command.h> @@ -77,6 +78,8 @@ db_addr_t db_next; /* next address to be examined or written */ void db_show_regs(db_expr_t, boolean_t, db_expr_t, char *); +void db_write_cmd(db_expr_t, boolean_t, db_expr_t, char *); + /* * Utility routine - discard tokens through end-of-line. @@ -816,3 +819,66 @@ db_show_regs(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } db_print_loc_and_inst(PC_REGS(&ddb_regs)); } + +/* + * Write to file. + */ +/*ARGSUSED*/ +void +db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count, + char *modif) +{ + db_addr_t addr; + db_expr_t old_value; + db_expr_t new_value; + int size; + boolean_t wrote_one = FALSE; + char tmpfmt[28]; + + addr = (db_addr_t) address; + + switch (modif[0]) { + case 'b': + size = 1; + break; + case 'h': + size = 2; + break; + case 'l': + case '\0': + size = 4; + break; +#ifdef __LP64__ + case 'q': + size = 8; + break; +#endif + default: + size = -1; + db_error("Unknown size\n"); + /*NOTREACHED*/ + } + + while (db_expression(&new_value)) { + old_value = db_get_value(addr, size, FALSE); + db_printsym(addr, DB_STGY_ANY, db_printf); + db_printf("\t\t%s\t", db_format(tmpfmt, sizeof tmpfmt, + old_value, DB_FORMAT_N, 0, 8)); + db_printf("=\t%s\n", db_format(tmpfmt, sizeof tmpfmt, + new_value, DB_FORMAT_N, 0, 8)); + db_put_value(addr, size, new_value); + addr += size; + + wrote_one = TRUE; + } + + if (!wrote_one) { + db_error("Nothing written.\n"); + /*NOTREACHED*/ + } + + db_next = addr; + db_prev = addr - size; + + db_skip_to_eol(); +} diff --git a/sys/ddb/db_extern.h b/sys/ddb/db_extern.h index 46fffc958d7..e5ce46a5357 100644 --- a/sys/ddb/db_extern.h +++ b/sys/ddb/db_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_extern.h,v 1.14 2016/03/09 09:04:15 mpi Exp $ */ +/* $OpenBSD: db_extern.h,v 1.15 2016/04/19 10:12:36 mpi Exp $ */ /* $NetBSD: db_extern.h,v 1.1 1996/02/05 01:57:00 christos Exp $ */ /* @@ -66,7 +66,4 @@ int db_readline(char *, int); /* db_trap.c */ void db_trap(int, int); -/* db_write_cmd.c */ -void db_write_cmd(db_expr_t, boolean_t, db_expr_t, char *); - #endif /* _DDB_DB_EXTERN_H_ */ diff --git a/sys/ddb/db_write_cmd.c b/sys/ddb/db_write_cmd.c deleted file mode 100644 index 383a985b588..00000000000 --- a/sys/ddb/db_write_cmd.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenBSD: db_write_cmd.c,v 1.14 2015/03/14 03:38:46 jsg Exp $ */ -/* $NetBSD: db_write_cmd.c,v 1.6 1996/02/05 01:57:25 christos Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1993,1992,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 - */ - -#include <sys/param.h> -#include <sys/systm.h> - -#include <machine/db_machdep.h> - -#include <ddb/db_access.h> -#include <ddb/db_command.h> -#include <ddb/db_sym.h> -#include <ddb/db_extern.h> -#include <ddb/db_output.h> - -/* - * Write to file. - */ -/*ARGSUSED*/ -void -db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count, - char *modif) -{ - db_addr_t addr; - db_expr_t old_value; - db_expr_t new_value; - int size; - boolean_t wrote_one = FALSE; - char tmpfmt[28]; - - addr = (db_addr_t) address; - - switch (modif[0]) { - case 'b': - size = 1; - break; - case 'h': - size = 2; - break; - case 'l': - case '\0': - size = 4; - break; -#ifdef __LP64__ - case 'q': - size = 8; - break; -#endif - default: - size = -1; - db_error("Unknown size\n"); - /*NOTREACHED*/ - } - - while (db_expression(&new_value)) { - old_value = db_get_value(addr, size, FALSE); - db_printsym(addr, DB_STGY_ANY, db_printf); - db_printf("\t\t%s\t", db_format(tmpfmt, sizeof tmpfmt, - old_value, DB_FORMAT_N, 0, 8)); - db_printf("=\t%s\n", db_format(tmpfmt, sizeof tmpfmt, - new_value, DB_FORMAT_N, 0, 8)); - db_put_value(addr, size, new_value); - addr += size; - - wrote_one = TRUE; - } - - if (!wrote_one) { - db_error("Nothing written.\n"); - /*NOTREACHED*/ - } - - db_next = addr; - db_prev = addr - size; - - db_skip_to_eol(); -} |