1 /** $MirOS: src/sys/ddb/db_write_cmd.c,v 1.2 2005/03/06 21:27:34 tg Exp $ */
2 /* $OpenBSD: db_write_cmd.c,v 1.7 2002/05/16 13:01:41 art Exp $ */
3 /* $NetBSD: db_write_cmd.c,v 1.6 1996/02/05 01:57:25 christos Exp $ */
4
5 /*
6 * Mach Operating System
7 * Copyright (c) 1993,1992,1991,1990 Carnegie Mellon University
8 * All Rights Reserved.
9 *
10 * Permission to use, copy, modify and distribute this software and its
11 * documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
29 *
30 * Author: David B. Golub, Carnegie Mellon University
31 * Date: 7/90
32 */
33
34 #include <sys/param.h>
35 #include <sys/proc.h>
36
37 #include <uvm/uvm_extern.h>
38
39 #include <machine/db_machdep.h>
40
41 #include <ddb/db_lex.h>
42 #include <ddb/db_access.h>
43 #include <ddb/db_command.h>
44 #include <ddb/db_sym.h>
45 #include <ddb/db_extern.h>
46 #include <ddb/db_output.h>
47
48 /*
49 * Write to file.
50 */
51 /*ARGSUSED*/
52 void
db_write_cmd(address,have_addr,count,modif)53 db_write_cmd(address, have_addr, count, modif)
54 db_expr_t address;
55 boolean_t have_addr;
56 db_expr_t count;
57 char * modif;
58 {
59 register
60 db_addr_t addr;
61 register
62 db_expr_t old_value;
63 db_expr_t new_value;
64 register int size;
65 boolean_t wrote_one = FALSE;
66
67 addr = (db_addr_t) address;
68
69 switch (modif[0]) {
70 case 'b':
71 size = 1;
72 break;
73 case 'h':
74 size = 2;
75 break;
76 case 'l':
77 case '\0':
78 size = 4;
79 break;
80 default:
81 size = -1;
82 db_error("Unknown size\n");
83 /*NOTREACHED*/
84 }
85
86 while (db_expression(&new_value)) {
87 old_value = db_get_value(addr, size, FALSE);
88 db_printsym(addr, DB_STGY_ANY, db_printf);
89 db_printf("\t\t%#8n\t=\t%#8n\n", (int)old_value, (int)new_value);
90 db_put_value(addr, size, new_value);
91 addr += size;
92
93 wrote_one = TRUE;
94 }
95
96 if (!wrote_one) {
97 db_error("Nothing written.\n");
98 /*NOTREACHED*/
99 }
100
101 db_next = addr;
102 db_prev = addr - size;
103
104 db_skip_to_eol();
105 }
106