* Copyright (c) 1991,1990 Carnegie Mellon University
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
* Carnegie Mellon requests users of this software to return to
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
* Author: David B. Golub, Carnegie Mellon University
#include <machine/db_machdep.h> /* type definitions */
#include <ddb/db_output.h>
#include <ddb/db_command.h>
char db_examine_format
[TOK_STRING_SIZE
] = "x";
extern db_addr_t
db_disasm(/* db_addr_t, boolean_t */);
/* instruction disassembler */
db_examine_cmd(addr
, have_addr
, count
, modif
)
db_strcpy(db_examine_format
, modif
);
db_examine((db_addr_t
) addr
, db_examine_format
, count
);
db_examine(addr
, fmt
, count
)
char * fmt
; /* format string */
int count
; /* repeat count */
while ((c
= *fp
++) != 0) {
/* always forces a new line */
if (db_print_position() != 0)
db_printsym(addr
, DB_STGY_ANY
);
if (db_print_position() == 0) {
/* If we hit a new symbol, print it */
db_find_sym_and_offset(addr
, &name
, &off
);
db_printf("%s:\t", name
);
case 'r': /* signed, current radix */
value
= db_get_value(addr
, size
, TRUE
);
db_printf("%-*r", width
, value
);
case 'x': /* unsigned hex */
value
= db_get_value(addr
, size
, FALSE
);
db_printf("%-*x", width
, value
);
case 'z': /* signed hex */
value
= db_get_value(addr
, size
, TRUE
);
db_printf("%-*z", width
, value
);
case 'd': /* signed decimal */
value
= db_get_value(addr
, size
, TRUE
);
db_printf("%-*d", width
, value
);
case 'u': /* unsigned decimal */
value
= db_get_value(addr
, size
, FALSE
);
db_printf("%-*u", width
, value
);
case 'o': /* unsigned octal */
value
= db_get_value(addr
, size
, FALSE
);
db_printf("%-*o", width
, value
);
case 'c': /* character */
value
= db_get_value(addr
, 1, FALSE
);
if (value
>= ' ' && value
<= '~')
db_printf("\\%03o", value
);
case 's': /* null-terminated string */
value
= db_get_value(addr
, 1, FALSE
);
if (value
>= ' ' && value
<= '~')
db_printf("\\%03o", value
);
case 'i': /* instruction */
addr
= db_disasm(addr
, FALSE
);
case 'I': /* instruction, alternate form */
addr
= db_disasm(addr
, TRUE
);
if (db_print_position() != 0)
char db_print_format
= 'x';
db_print_cmd(addr
, have_addr
, count
, modif
)
db_print_format
= modif
[0];
switch (db_print_format
) {
db_printsym((db_addr_t
)addr
, DB_STGY_ANY
);
if (value
>= ' ' && value
<= '~')
db_printf("\\%03o", value
);
db_print_loc_and_inst(loc
)
db_printsym(loc
, DB_STGY_PROC
);
(void) db_disasm(loc
, TRUE
);
* Search for a value in memory.
* Syntax: search [/bhl] addr value [mask] [,count]
db_printf("Bad modifier\n");
if (!strcmp(db_tok_string
, "b"))
else if (!strcmp(db_tok_string
, "h"))
else if (!strcmp(db_tok_string
, "l"))
if (!db_expression(&addr
)) {
db_printf("Address missing\n");
if (!db_expression(&value
)) {
db_printf("Value missing\n");
if (!db_expression(&mask
))
if (!db_expression(&count
)) {
db_printf("Count missing\n");
count
= -1; /* effectively forever */
db_search(addr
, size
, value
, mask
, count
);
db_search(addr
, size
, value
, mask
, count
)
if ((db_get_value(addr
, size
, FALSE
) & mask
) == value
)