/*-1* SPDX-License-Identifier: MIT-CMU2*3* Mach Operating System4* Copyright (c) 1991,1990 Carnegie Mellon University5* All Rights Reserved.6*7* Permission to use, copy, modify and distribute this software and its8* documentation is hereby granted, provided that both the copyright9* notice and this permission notice appear in all copies of the10* software, derivative works or modified versions, and any portions11* thereof, and that both notices appear in supporting documentation.12*13* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS14* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR15* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.16*17* Carnegie Mellon requests users of this software to return to18*19* Software Distribution Coordinator or [email protected]20* School of Computer Science21* Carnegie Mellon University22* Pittsburgh PA 15213-389023*24* any improvements or extensions that they make and grant Carnegie the25* rights to redistribute these changes.26*/27/*28* Author: David B. Golub, Carnegie Mellon University29* Date: 7/9030*/3132#include <sys/param.h>3334#include <ddb/ddb.h>35#include <ddb/db_access.h>36#include <ddb/db_command.h>37#include <ddb/db_sym.h>3839/*40* Write to file.41*/42/*ARGSUSED*/43void44db_write_cmd(db_expr_t address, bool have_addr, db_expr_t count,45char * modif)46{47db_addr_t addr;48db_expr_t old_value;49db_expr_t new_value;50int size;51bool wrote_one = false;5253addr = (db_addr_t) address;5455switch (modif[0]) {56case 'b':57size = 1;58break;59case 'h':60size = 2;61break;62case 'l':63case '\0':64size = 4;65break;66default:67db_error("Unknown size\n");68return;69}7071while (db_expression(&new_value)) {72old_value = db_get_value(addr, size, false);73db_printsym(addr, DB_STGY_ANY);74db_printf("\t\t%#8lr\t=\t%#8lr\n", (long)old_value,(long)new_value);75db_put_value(addr, size, new_value);76addr += size;7778wrote_one = true;79}8081if (!wrote_one)82db_error("Nothing written.\n");8384db_next = addr;85db_prev = addr - size;8687db_skip_to_eol();88}899091