]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
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. | |
e5568f75 | 11 | * |
37839358 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
1c79356b A |
25 | /* |
26 | * Mach Operating System | |
27 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
28 | * All Rights Reserved. | |
29 | * | |
30 | * Permission to use, copy, modify and distribute this software and its | |
31 | * documentation is hereby granted, provided that both the copyright | |
32 | * notice and this permission notice appear in all copies of the | |
33 | * software, derivative works or modified versions, and any portions | |
34 | * thereof, and that both notices appear in supporting documentation. | |
35 | * | |
36 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
37 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
38 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
39 | * | |
40 | * Carnegie Mellon requests users of this software to return to | |
41 | * | |
42 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
43 | * School of Computer Science | |
44 | * Carnegie Mellon University | |
45 | * Pittsburgh PA 15213-3890 | |
46 | * | |
47 | * any improvements or extensions that they make and grant Carnegie Mellon | |
48 | * the rights to redistribute these changes. | |
49 | */ | |
50 | /* | |
51 | */ | |
52 | /* | |
53 | * Author: David B. Golub, Carnegie Mellon University | |
54 | * Date: 7/90 | |
55 | */ | |
56 | ||
57 | #include <mach/boolean.h> | |
58 | #include <kern/task.h> | |
59 | #include <kern/thread.h> | |
60 | ||
61 | #include <machine/db_machdep.h> | |
62 | ||
63 | #include <ddb/db_lex.h> | |
64 | #include <ddb/db_access.h> | |
65 | #include <ddb/db_command.h> | |
66 | #include <ddb/db_sym.h> | |
67 | #include <ddb/db_task_thread.h> | |
68 | #include <ddb/db_expr.h> | |
69 | #include <ddb/db_write_cmd.h> | |
70 | #include <ddb/db_output.h> /* For db_printf() */ | |
71 | ||
72 | /* | |
73 | * Write to file. | |
74 | */ | |
75 | void | |
76 | db_write_cmd( | |
77 | db_expr_t address, | |
78 | boolean_t have_addr, | |
79 | db_expr_t count, | |
80 | char * modif) | |
81 | { | |
82 | register db_addr_t addr; | |
83 | register db_expr_t old_value; | |
84 | db_expr_t new_value; | |
85 | register int size; | |
86 | boolean_t wrote_one = FALSE; | |
87 | boolean_t t_opt, u_opt; | |
91447636 | 88 | thread_t thr_act; |
1c79356b A |
89 | task_t task; |
90 | ||
91 | addr = (db_addr_t) address; | |
92 | ||
93 | size = db_size_option(modif, &u_opt, &t_opt); | |
94 | ||
95 | if (t_opt) | |
96 | { | |
97 | if (!db_get_next_act(&thr_act, 0)) | |
98 | return; | |
99 | task = thr_act->task; | |
100 | } | |
101 | else | |
102 | task = db_current_space(); | |
103 | ||
104 | /* if user space is not explicitly specified, | |
105 | look in the kernel */ | |
106 | if (!u_opt) | |
107 | task = TASK_NULL; | |
108 | ||
109 | if (!DB_VALID_ADDRESS(addr, u_opt)) { | |
91447636 | 110 | db_printf("Bad address 0x%llx\n", (unsigned long long)addr); |
1c79356b A |
111 | return; |
112 | } | |
113 | ||
114 | while (db_expression(&new_value)) { | |
115 | old_value = db_get_task_value(addr, size, FALSE, task); | |
116 | db_task_printsym(addr, DB_STGY_ANY, task); | |
91447636 | 117 | db_printf("\t\t%#8lln\t=\t%#8lln\n", (unsigned long long)old_value, (unsigned long long)new_value); |
1c79356b A |
118 | db_put_task_value(addr, size, new_value, task); |
119 | addr += size; | |
120 | ||
121 | wrote_one = TRUE; | |
122 | } | |
123 | ||
124 | if (!wrote_one) | |
125 | db_error("Nothing written.\n"); | |
126 | ||
127 | db_next = addr; | |
128 | db_prev = addr - size; | |
129 | } |