Deleted Added
full compact
db_watch.c (256281) db_watch.c (273265)
1/*-
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

--- 15 unchanged lines hidden (view full) ---

24 * rights to redistribute these changes.
25 */
26/*
27 * Author: Richard P. Draves, Carnegie Mellon University
28 * Date: 10/90
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

--- 15 unchanged lines hidden (view full) ---

24 * rights to redistribute these changes.
25 */
26/*
27 * Author: Richard P. Draves, Carnegie Mellon University
28 * Date: 10/90
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/10/sys/ddb/db_watch.c 164359 2006-11-17 16:41:56Z jhb $");
32__FBSDID("$FreeBSD: stable/10/sys/ddb/db_watch.c 273265 2014-10-18 19:22:59Z pfg $");
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/lock.h>
37#include <sys/proc.h>
38
39#include <vm/vm.h>
40#include <vm/pmap.h>

--- 21 unchanged lines hidden (view full) ---

62static boolean_t db_find_watchpoint(vm_map_t map, db_addr_t addr,
63 db_regs_t *regs);
64#endif
65static void db_list_watchpoints(void);
66static void db_set_watchpoint(vm_map_t map, db_addr_t addr,
67 vm_size_t size);
68
69static db_watchpoint_t
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/lock.h>
37#include <sys/proc.h>
38
39#include <vm/vm.h>
40#include <vm/pmap.h>

--- 21 unchanged lines hidden (view full) ---

62static boolean_t db_find_watchpoint(vm_map_t map, db_addr_t addr,
63 db_regs_t *regs);
64#endif
65static void db_list_watchpoints(void);
66static void db_set_watchpoint(vm_map_t map, db_addr_t addr,
67 vm_size_t size);
68
69static db_watchpoint_t
70db_watchpoint_alloc()
70db_watchpoint_alloc(void)
71{
72 register db_watchpoint_t watch;
73
74 if ((watch = db_free_watchpoints) != 0) {
75 db_free_watchpoints = watch->link;
76 return (watch);
77 }
78 if (db_next_free_watchpoint == &db_watch_table[NWATCHPOINTS]) {
79 db_printf("All watchpoints used.\n");
80 return (0);
81 }
82 watch = db_next_free_watchpoint;
83 db_next_free_watchpoint++;
84
85 return (watch);
86}
87
88static void
71{
72 register db_watchpoint_t watch;
73
74 if ((watch = db_free_watchpoints) != 0) {
75 db_free_watchpoints = watch->link;
76 return (watch);
77 }
78 if (db_next_free_watchpoint == &db_watch_table[NWATCHPOINTS]) {
79 db_printf("All watchpoints used.\n");
80 return (0);
81 }
82 watch = db_next_free_watchpoint;
83 db_next_free_watchpoint++;
84
85 return (watch);
86}
87
88static void
89db_watchpoint_free(watch)
90 register db_watchpoint_t watch;
89db_watchpoint_free(db_watchpoint_t watch)
91{
92 watch->link = db_free_watchpoints;
93 db_free_watchpoints = watch;
94}
95
96static void
90{
91 watch->link = db_free_watchpoints;
92 db_free_watchpoints = watch;
93}
94
95static void
97db_set_watchpoint(map, addr, size)
98 vm_map_t map;
99 db_addr_t addr;
100 vm_size_t size;
96db_set_watchpoint(vm_map_t map, db_addr_t addr, vm_size_t size)
101{
102 register db_watchpoint_t watch;
103
104 if (map == NULL) {
105 db_printf("No map.\n");
106 return;
107 }
108

--- 23 unchanged lines hidden (view full) ---

132
133 watch->link = db_watchpoint_list;
134 db_watchpoint_list = watch;
135
136 db_watchpoints_inserted = FALSE;
137}
138
139static void
97{
98 register db_watchpoint_t watch;
99
100 if (map == NULL) {
101 db_printf("No map.\n");
102 return;
103 }
104

--- 23 unchanged lines hidden (view full) ---

128
129 watch->link = db_watchpoint_list;
130 db_watchpoint_list = watch;
131
132 db_watchpoints_inserted = FALSE;
133}
134
135static void
140db_delete_watchpoint(map, addr)
141 vm_map_t map;
142 db_addr_t addr;
136db_delete_watchpoint(vm_map_t map, db_addr_t addr)
143{
144 register db_watchpoint_t watch;
145 register db_watchpoint_t *prev;
146
147 for (prev = &db_watchpoint_list;
148 (watch = *prev) != 0;
149 prev = &watch->link)
150 if (db_map_equal(watch->map, map) &&
151 (watch->loaddr <= addr) &&
152 (addr < watch->hiaddr)) {
153 *prev = watch->link;
154 db_watchpoint_free(watch);
155 return;
156 }
157
158 db_printf("Not set.\n");
159}
160
161static void
137{
138 register db_watchpoint_t watch;
139 register db_watchpoint_t *prev;
140
141 for (prev = &db_watchpoint_list;
142 (watch = *prev) != 0;
143 prev = &watch->link)
144 if (db_map_equal(watch->map, map) &&
145 (watch->loaddr <= addr) &&
146 (addr < watch->hiaddr)) {
147 *prev = watch->link;
148 db_watchpoint_free(watch);
149 return;
150 }
151
152 db_printf("Not set.\n");
153}
154
155static void
162db_list_watchpoints()
156db_list_watchpoints(void)
163{
164 register db_watchpoint_t watch;
165
166 if (db_watchpoint_list == 0) {
167 db_printf("No watchpoints set\n");
168 return;
169 }
170

--- 13 unchanged lines hidden (view full) ---

184 db_map_current(watch->map) ? "*" : " ",
185 (void *)watch->map, (long)watch->loaddr,
186 (long)watch->hiaddr - (long)watch->loaddr);
187}
188
189/* Delete watchpoint */
190/*ARGSUSED*/
191void
157{
158 register db_watchpoint_t watch;
159
160 if (db_watchpoint_list == 0) {
161 db_printf("No watchpoints set\n");
162 return;
163 }
164

--- 13 unchanged lines hidden (view full) ---

178 db_map_current(watch->map) ? "*" : " ",
179 (void *)watch->map, (long)watch->loaddr,
180 (long)watch->hiaddr - (long)watch->loaddr);
181}
182
183/* Delete watchpoint */
184/*ARGSUSED*/
185void
192db_deletewatch_cmd(addr, have_addr, count, modif)
193 db_expr_t addr;
194 boolean_t have_addr;
195 db_expr_t count;
196 char * modif;
186db_deletewatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
187 char *modif)
197{
198 db_delete_watchpoint(db_map_addr(addr), addr);
199}
200
201/* Set watchpoint */
202/*ARGSUSED*/
203void
188{
189 db_delete_watchpoint(db_map_addr(addr), addr);
190}
191
192/* Set watchpoint */
193/*ARGSUSED*/
194void
204db_watchpoint_cmd(addr, have_addr, count, modif)
205 db_expr_t addr;
206 boolean_t have_addr;
207 db_expr_t count;
208 char * modif;
195db_watchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
196 char *modif)
209{
210 vm_size_t size;
211 db_expr_t value;
212
213 if (db_expression(&value))
214 size = (vm_size_t) value;
215 else
216 size = 4;

--- 8 unchanged lines hidden (view full) ---

225 */
226DB_SHOW_COMMAND(watches, db_listwatch_cmd)
227{
228 db_list_watchpoints();
229 db_md_list_watchpoints();
230}
231
232void
197{
198 vm_size_t size;
199 db_expr_t value;
200
201 if (db_expression(&value))
202 size = (vm_size_t) value;
203 else
204 size = 4;

--- 8 unchanged lines hidden (view full) ---

213 */
214DB_SHOW_COMMAND(watches, db_listwatch_cmd)
215{
216 db_list_watchpoints();
217 db_md_list_watchpoints();
218}
219
220void
233db_set_watchpoints()
221db_set_watchpoints(void)
234{
235 register db_watchpoint_t watch;
236
237 if (!db_watchpoints_inserted) {
238 for (watch = db_watchpoint_list;
239 watch != 0;
240 watch = watch->link)
241 pmap_protect(watch->map->pmap,
242 trunc_page(watch->loaddr),
243 round_page(watch->hiaddr),
244 VM_PROT_READ);
245
246 db_watchpoints_inserted = TRUE;
247 }
248}
249
250void
222{
223 register db_watchpoint_t watch;
224
225 if (!db_watchpoints_inserted) {
226 for (watch = db_watchpoint_list;
227 watch != 0;
228 watch = watch->link)
229 pmap_protect(watch->map->pmap,
230 trunc_page(watch->loaddr),
231 round_page(watch->hiaddr),
232 VM_PROT_READ);
233
234 db_watchpoints_inserted = TRUE;
235 }
236}
237
238void
251db_clear_watchpoints()
239db_clear_watchpoints(void)
252{
253 db_watchpoints_inserted = FALSE;
254}
255
256#ifdef notused
257static boolean_t
240{
241 db_watchpoints_inserted = FALSE;
242}
243
244#ifdef notused
245static boolean_t
258db_find_watchpoint(map, addr, regs)
259 vm_map_t map;
260 db_addr_t addr;
261 db_regs_t *regs;
246db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs)
262{
263 register db_watchpoint_t watch;
264 db_watchpoint_t found = 0;
265
266 for (watch = db_watchpoint_list;
267 watch != 0;
268 watch = watch->link)
269 if (db_map_equal(watch->map, map)) {

--- 20 unchanged lines hidden (view full) ---

290}
291#endif
292
293
294
295/* Delete hardware watchpoint */
296/*ARGSUSED*/
297void
247{
248 register db_watchpoint_t watch;
249 db_watchpoint_t found = 0;
250
251 for (watch = db_watchpoint_list;
252 watch != 0;
253 watch = watch->link)
254 if (db_map_equal(watch->map, map)) {

--- 20 unchanged lines hidden (view full) ---

275}
276#endif
277
278
279
280/* Delete hardware watchpoint */
281/*ARGSUSED*/
282void
298db_deletehwatch_cmd(addr, have_addr, count, modif)
299 db_expr_t addr;
300 boolean_t have_addr;
301 db_expr_t count;
302 char * modif;
283db_deletehwatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
284 char *modif)
303{
304 int rc;
305
285{
286 int rc;
287
306 if (count < 0)
307 count = 4;
288 if (count < 0)
289 count = 4;
308
309 rc = db_md_clr_watchpoint(addr, count);
310 if (rc < 0)
311 db_printf("hardware watchpoint could not be deleted\n");
312}
313
314/* Set hardware watchpoint */
315/*ARGSUSED*/
316void
290
291 rc = db_md_clr_watchpoint(addr, count);
292 if (rc < 0)
293 db_printf("hardware watchpoint could not be deleted\n");
294}
295
296/* Set hardware watchpoint */
297/*ARGSUSED*/
298void
317db_hwatchpoint_cmd(addr, have_addr, count, modif)
318 db_expr_t addr;
319 boolean_t have_addr;
320 db_expr_t count;
321 char * modif;
299db_hwatchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
300 char *modif)
322{
323 int rc;
324
301{
302 int rc;
303
325 if (count < 0)
326 count = 4;
304 if (count < 0)
305 count = 4;
327
328 rc = db_md_set_watchpoint(addr, count);
329 if (rc < 0)
330 db_printf("hardware watchpoint could not be set\n");
331}
306
307 rc = db_md_set_watchpoint(addr, count);
308 if (rc < 0)
309 db_printf("hardware watchpoint could not be set\n");
310}