Deleted Added
full compact
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

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

18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
25 *
26 * $Id: db_examine.c,v 1.2 1993/10/16 16:47:13 rgrimes Exp $
27 */
28
29/*
30 * Author: David B. Golub, Carnegie Mellon University
31 * Date: 7/90
32 */
33#include "param.h"
34#include "systm.h"
35#include "proc.h"
36
37#include "ddb/ddb.h"
38
39#include <ddb/db_lex.h>
40#include <ddb/db_output.h>
41#include <ddb/db_command.h>
42#include <ddb/db_sym.h>
43
44char db_examine_format[TOK_STRING_SIZE] = "x";
45
46extern db_addr_t db_disasm(/* db_addr_t, boolean_t */);
47 /* instruction disassembler */
48
49static void db_examine(db_addr_t, char *, int);
50static void db_search(db_addr_t, int, db_expr_t, db_expr_t, u_int);
51
52/*
53 * Examine (print) data.
54 */
55/*ARGSUSED*/
56void
57db_examine_cmd(addr, have_addr, count, modif)
58 db_expr_t addr;
59 int have_addr;

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

64 db_strcpy(db_examine_format, modif);
65
66 if (count == -1)
67 count = 1;
68
69 db_examine((db_addr_t) addr, db_examine_format, count);
70}
71
72static void
73db_examine(addr, fmt, count)
74 register
75 db_addr_t addr;
76 char * fmt; /* format string */
77 int count; /* repeat count */
78{
79 int c;
80 db_expr_t value;

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

238 db_printf("%c", value);
239 else
240 db_printf("\\%03o", value);
241 break;
242 }
243 db_printf("\n");
244}
245
246void
247db_print_loc_and_inst(loc)
248 db_addr_t loc;
249{
250 db_printsym(loc, DB_STGY_PROC);
251 db_printf(":\t");
252 (void) db_disasm(loc, TRUE);
253}
254
255/*
256 * Search for a value in memory.
257 * Syntax: search [/bhl] addr value [mask] [,count]
258 */
259void
260db_search_cmd(db_expr_t dummy1, int dummy2, db_expr_t dummy3, char *dummy4)
261{
262 int t;
263 db_addr_t addr;
264 int size;
265 db_expr_t value;
266 db_expr_t mask;
267 unsigned int count;
268

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

284 size = 4;
285 else
286 goto bad_modifier;
287 } else {
288 db_unread_token(t);
289 size = 4;
290 }
291
292 if (!db_expression((db_expr_t *)&addr)) {
293 db_printf("Address missing\n");
294 db_flush_lex();
295 return;
296 }
297
298 if (!db_expression(&value)) {
299 db_printf("Value missing\n");
300 db_flush_lex();

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

315 db_unread_token(t);
316 count = -1; /* effectively forever */
317 }
318 db_skip_to_eol();
319
320 db_search(addr, size, value, mask, count);
321}
322
323static void
324db_search(addr, size, value, mask, count)
325 register
326 db_addr_t addr;
327 int size;
328 db_expr_t value;
329 db_expr_t mask;
330 unsigned int count;
331{
332 while (count-- != 0) {
333 db_prev = addr;
334 if ((db_get_value(addr, size, FALSE) & mask) == value)
335 break;
336 addr += size;
337 }
338 db_next = addr;
339}