123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #include <sys/param.h>
- #include <sys/systm.h>
- #include <machine/db_machdep.h>
- #include <ddb/db_access.h>
- #include <ddb/db_command.h>
- #include <ddb/db_sym.h>
- #include <ddb/db_extern.h>
- #include <ddb/db_output.h>
- void
- db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count,
- char *modif)
- {
- db_addr_t addr;
- db_expr_t old_value;
- db_expr_t new_value;
- int size;
- boolean_t wrote_one = FALSE;
- char tmpfmt[28];
- addr = (db_addr_t) address;
- switch (modif[0]) {
- case 'b':
- size = 1;
- break;
- case 'h':
- size = 2;
- break;
- case 'l':
- case '\0':
- size = 4;
- break;
- #ifdef __LP64__
- case 'q':
- size = 8;
- break;
- #endif
- default:
- size = -1;
- db_error("Unknown size\n");
-
- }
- while (db_expression(&new_value)) {
- old_value = db_get_value(addr, size, FALSE);
- db_printsym(addr, DB_STGY_ANY, db_printf);
- db_printf("\t\t%s\t", db_format(tmpfmt, sizeof tmpfmt,
- old_value, DB_FORMAT_N, 0, 8));
- db_printf("=\t%s\n", db_format(tmpfmt, sizeof tmpfmt,
- new_value, DB_FORMAT_N, 0, 8));
- db_put_value(addr, size, new_value);
- addr += size;
- wrote_one = TRUE;
- }
- if (!wrote_one) {
- db_error("Nothing written.\n");
-
- }
- db_next = addr;
- db_prev = addr - size;
- db_skip_to_eol();
- }
|