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