db_examine.c (623) | db_examine.c (798) |
---|---|
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 * | 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$ | 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" | 27 */ 28 29/* 30 * Author: David B. Golub, Carnegie Mellon University 31 * Date: 7/90 32 */ 33#include "param.h" |
34#include "systm.h" |
|
34#include "proc.h" | 35#include "proc.h" |
35#include <machine/db_machdep.h> /* type definitions */ | |
36 | 36 |
37#include "ddb/ddb.h" 38 |
|
37#include <ddb/db_lex.h> 38#include <ddb/db_output.h> 39#include <ddb/db_command.h> 40#include <ddb/db_sym.h> 41 42char db_examine_format[TOK_STRING_SIZE] = "x"; 43 44extern db_addr_t db_disasm(/* db_addr_t, boolean_t */); 45 /* instruction disassembler */ 46 | 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 |
|
47/* 48 * Examine (print) data. 49 */ 50/*ARGSUSED*/ 51void 52db_examine_cmd(addr, have_addr, count, modif) 53 db_expr_t addr; 54 int have_addr; --- 4 unchanged lines hidden (view full) --- 59 db_strcpy(db_examine_format, modif); 60 61 if (count == -1) 62 count = 1; 63 64 db_examine((db_addr_t) addr, db_examine_format, count); 65} 66 | 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 |
|
67db_examine(addr, fmt, count) 68 register 69 db_addr_t addr; 70 char * fmt; /* format string */ 71 int count; /* repeat count */ 72{ 73 int c; 74 db_expr_t value; --- 157 unchanged lines hidden (view full) --- 232 db_printf("%c", value); 233 else 234 db_printf("\\%03o", value); 235 break; 236 } 237 db_printf("\n"); 238} 239 | 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 |
|
240db_print_loc_and_inst(loc) 241 db_addr_t loc; 242{ 243 db_printsym(loc, DB_STGY_PROC); 244 db_printf(":\t"); 245 (void) db_disasm(loc, TRUE); 246} 247 | 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 |
248db_strcpy(dst, src) 249 register char *dst; 250 register char *src; 251{ 252 while (*dst++ = *src++) 253 ; 254} 255 | |
256/* 257 * Search for a value in memory. 258 * Syntax: search [/bhl] addr value [mask] [,count] 259 */ 260void | 255/* 256 * Search for a value in memory. 257 * Syntax: search [/bhl] addr value [mask] [,count] 258 */ 259void |
261db_search_cmd() | 260db_search_cmd(db_expr_t dummy1, int dummy2, db_expr_t dummy3, char *dummy4) |
262{ 263 int t; 264 db_addr_t addr; 265 int size; 266 db_expr_t value; 267 db_expr_t mask; 268 unsigned int count; 269 --- 15 unchanged lines hidden (view full) --- 285 size = 4; 286 else 287 goto bad_modifier; 288 } else { 289 db_unread_token(t); 290 size = 4; 291 } 292 | 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 |
293 if (!db_expression(&addr)) { | 292 if (!db_expression((db_expr_t *)&addr)) { |
294 db_printf("Address missing\n"); 295 db_flush_lex(); 296 return; 297 } 298 299 if (!db_expression(&value)) { 300 db_printf("Value missing\n"); 301 db_flush_lex(); --- 14 unchanged lines hidden (view full) --- 316 db_unread_token(t); 317 count = -1; /* effectively forever */ 318 } 319 db_skip_to_eol(); 320 321 db_search(addr, size, value, mask, count); 322} 323 | 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} | 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} |