|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: */
25: /*
26: * HISTORY
27: *
28: * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
29: * Import of Mac OS X kernel (~semeria)
30: *
31: * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
32: * Import of OSF Mach kernel (~mburg)
33: *
34: * Revision 1.2.10.1 1994/09/23 01:23:15 ezf
35: * change marker to not FREE
36: * [1994/09/22 21:11:42 ezf]
37: *
38: * Revision 1.2.8.3 1994/03/17 22:35:48 dwm
39: * The infamous name change: thread_activation + thread_shuttle = thread.
40: * [1994/03/17 21:26:02 dwm]
41: *
42: * Revision 1.2.8.2 1994/01/12 17:51:11 dwm
43: * Coloc: initial restructuring to follow Utah model.
44: * [1994/01/12 17:13:42 dwm]
45: *
46: * Revision 1.2.8.1 1994/01/05 19:28:25 bolinger
47: * Target current address space, not current "task", for writes.
48: * [1994/01/04 17:44:51 bolinger]
49: *
50: * Revision 1.2.2.3 1993/07/27 18:28:36 elliston
51: * Add ANSI prototypes. CR #9523.
52: * [1993/07/27 18:13:37 elliston]
53: *
54: * Revision 1.2.2.2 1993/06/09 02:21:11 gm
55: * Added to OSF/1 R1.3 from NMK15.0.
56: * [1993/06/02 20:58:03 jeffc]
57: *
58: * Revision 1.2 1993/04/19 16:03:43 devrcs
59: * Changes from mk78:
60: * Removed unused variable 'p' from db_write_cmd().
61: * [92/05/16 jfriedl]
62: * Reorganized. w/u now works, instead of just w/tu.
63: * [92/04/18 danner]
64: * [93/02/02 bruel]
65: *
66: * Revision 1.1 1992/09/30 02:01:35 robert
67: * Initial revision
68: *
69: * $EndLog$
70: */
71: /* CMU_HIST */
72: /*
73: * Revision 2.6 91/10/09 16:05:06 af
74: * Revision 2.5.3.1 91/10/05 13:09:25 jeffreyh
75: * Added user space write support including inactive task.
76: * [91/08/29 tak]
77: *
78: * Revision 2.5.3.1 91/10/05 13:09:25 jeffreyh
79: * Added user space write support including inactive task.
80: * [91/08/29 tak]
81: *
82: * Revision 2.5 91/05/14 15:38:04 mrt
83: * Correcting copyright
84: *
85: * Revision 2.4 91/02/05 17:07:35 mrt
86: * Changed to new Mach copyright
87: * [91/01/31 16:20:19 mrt]
88: *
89: * Revision 2.3 90/10/25 14:44:26 rwd
90: * Changed db_write_cmd to print unsigned.
91: * [90/10/19 rpd]
92: *
93: * Revision 2.2 90/08/27 21:53:54 dbg
94: * Set db_prev and db_next instead of explicitly advancing dot.
95: * [90/08/22 dbg]
96: * Reflected changes in db_printsym()'s calling seq.
97: * [90/08/20 af]
98: * Warn user if nothing was written.
99: * [90/08/07 dbg]
100: * Created.
101: * [90/07/25 dbg]
102: *
103: */
104: /* CMU_ENDHIST */
105: /*
106: * Mach Operating System
107: * Copyright (c) 1991,1990 Carnegie Mellon University
108: * All Rights Reserved.
109: *
110: * Permission to use, copy, modify and distribute this software and its
111: * documentation is hereby granted, provided that both the copyright
112: * notice and this permission notice appear in all copies of the
113: * software, derivative works or modified versions, and any portions
114: * thereof, and that both notices appear in supporting documentation.
115: *
116: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
117: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
118: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
119: *
120: * Carnegie Mellon requests users of this software to return to
121: *
122: * Software Distribution Coordinator or [email protected]
123: * School of Computer Science
124: * Carnegie Mellon University
125: * Pittsburgh PA 15213-3890
126: *
127: * any improvements or extensions that they make and grant Carnegie Mellon
128: * the rights to redistribute these changes.
129: */
130: /*
131: */
132: /*
133: * Author: David B. Golub, Carnegie Mellon University
134: * Date: 7/90
135: */
136:
137: #include <mach/boolean.h>
138: #include <kern/task.h>
139: #include <kern/thread.h>
140:
141: #include <machine/db_machdep.h>
142:
143: #include <ddb/db_lex.h>
144: #include <ddb/db_access.h>
145: #include <ddb/db_command.h>
146: #include <ddb/db_sym.h>
147: #include <ddb/db_task_thread.h>
148: #include <ddb/db_expr.h>
149: #include <ddb/db_write_cmd.h>
150: #include <ddb/db_output.h> /* For db_printf() */
151:
152: /*
153: * Write to file.
154: */
155: void
156: db_write_cmd(
157: db_expr_t address,
158: boolean_t have_addr,
159: db_expr_t count,
160: char * modif)
161: {
162: register db_addr_t addr;
163: register db_expr_t old_value;
164: db_expr_t new_value;
165: register int size;
166: boolean_t wrote_one = FALSE;
167: boolean_t t_opt, u_opt;
168: thread_act_t thr_act;
169: task_t task;
170:
171: addr = (db_addr_t) address;
172:
173: size = db_size_option(modif, &u_opt, &t_opt);
174:
175: if (t_opt)
176: {
177: if (!db_get_next_act(&thr_act, 0))
178: return;
179: task = thr_act->task;
180: }
181: else
182: task = db_current_space();
183:
184: /* if user space is not explicitly specified,
185: look in the kernel */
186: if (!u_opt)
187: task = TASK_NULL;
188:
189: if (!DB_VALID_ADDRESS(addr, u_opt)) {
190: db_printf("Bad address 0x%x\n", addr);
191: return;
192: }
193:
194: while (db_expression(&new_value)) {
195: old_value = db_get_task_value(addr, size, FALSE, task);
196: db_task_printsym(addr, DB_STGY_ANY, task);
197: db_printf("\t\t%#8n\t=\t%#8n\n", old_value, new_value);
198: db_put_task_value(addr, size, new_value, task);
199: addr += size;
200:
201: wrote_one = TRUE;
202: }
203:
204: if (!wrote_one)
205: db_error("Nothing written.\n");
206:
207: db_next = addr;
208: db_prev = addr - size;
209: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.