1dd3cb568SWarner Losh /*-
2*796df753SPedro F. Giffuni * SPDX-License-Identifier: MIT-CMU
3*796df753SPedro F. Giffuni *
45b81b6b3SRodney W. Grimes * Mach Operating System
55b81b6b3SRodney W. Grimes * Copyright (c) 1991,1990 Carnegie Mellon University
65b81b6b3SRodney W. Grimes * All Rights Reserved.
75b81b6b3SRodney W. Grimes *
85b81b6b3SRodney W. Grimes * Permission to use, copy, modify and distribute this software and its
95b81b6b3SRodney W. Grimes * documentation is hereby granted, provided that both the copyright
105b81b6b3SRodney W. Grimes * notice and this permission notice appear in all copies of the
115b81b6b3SRodney W. Grimes * software, derivative works or modified versions, and any portions
125b81b6b3SRodney W. Grimes * thereof, and that both notices appear in supporting documentation.
135b81b6b3SRodney W. Grimes *
145b81b6b3SRodney W. Grimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
155b81b6b3SRodney W. Grimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
165b81b6b3SRodney W. Grimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
175b81b6b3SRodney W. Grimes *
185b81b6b3SRodney W. Grimes * Carnegie Mellon requests users of this software to return to
195b81b6b3SRodney W. Grimes *
205b81b6b3SRodney W. Grimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
215b81b6b3SRodney W. Grimes * School of Computer Science
225b81b6b3SRodney W. Grimes * Carnegie Mellon University
235b81b6b3SRodney W. Grimes * Pittsburgh PA 15213-3890
245b81b6b3SRodney W. Grimes *
255b81b6b3SRodney W. Grimes * any improvements or extensions that they make and grant Carnegie the
265b81b6b3SRodney W. Grimes * rights to redistribute these changes.
275b81b6b3SRodney W. Grimes */
285b81b6b3SRodney W. Grimes /*
295b81b6b3SRodney W. Grimes * Author: David B. Golub, Carnegie Mellon University
305b81b6b3SRodney W. Grimes * Date: 7/90
315b81b6b3SRodney W. Grimes */
325b81b6b3SRodney W. Grimes
33f540b106SGarrett Wollman #include <sys/param.h>
345b81b6b3SRodney W. Grimes
355ccbc3ccSBruce Evans #include <ddb/ddb.h>
365b81b6b3SRodney W. Grimes #include <ddb/db_access.h>
375b81b6b3SRodney W. Grimes #include <ddb/db_command.h>
385b81b6b3SRodney W. Grimes #include <ddb/db_sym.h>
395b81b6b3SRodney W. Grimes
405b81b6b3SRodney W. Grimes /*
415b81b6b3SRodney W. Grimes * Write to file.
425b81b6b3SRodney W. Grimes */
435b81b6b3SRodney W. Grimes /*ARGSUSED*/
445b81b6b3SRodney W. Grimes void
db_write_cmd(db_expr_t address,bool have_addr,db_expr_t count,char * modif)45cd508278SPedro F. Giffuni db_write_cmd(db_expr_t address, bool have_addr, db_expr_t count,
46a41dd031SPedro F. Giffuni char * modif)
475b81b6b3SRodney W. Grimes {
485b81b6b3SRodney W. Grimes db_addr_t addr;
495b81b6b3SRodney W. Grimes db_expr_t old_value;
505b81b6b3SRodney W. Grimes db_expr_t new_value;
510a95ab74SPedro F. Giffuni int size;
52cd508278SPedro F. Giffuni bool wrote_one = false;
535b81b6b3SRodney W. Grimes
545b81b6b3SRodney W. Grimes addr = (db_addr_t) address;
555b81b6b3SRodney W. Grimes
565b81b6b3SRodney W. Grimes switch (modif[0]) {
575b81b6b3SRodney W. Grimes case 'b':
585b81b6b3SRodney W. Grimes size = 1;
595b81b6b3SRodney W. Grimes break;
605b81b6b3SRodney W. Grimes case 'h':
615b81b6b3SRodney W. Grimes size = 2;
625b81b6b3SRodney W. Grimes break;
635b81b6b3SRodney W. Grimes case 'l':
645b81b6b3SRodney W. Grimes case '\0':
655b81b6b3SRodney W. Grimes size = 4;
665b81b6b3SRodney W. Grimes break;
675b81b6b3SRodney W. Grimes default:
685b81b6b3SRodney W. Grimes db_error("Unknown size\n");
695b81b6b3SRodney W. Grimes return;
705b81b6b3SRodney W. Grimes }
715b81b6b3SRodney W. Grimes
725b81b6b3SRodney W. Grimes while (db_expression(&new_value)) {
732b490bc7SPedro F. Giffuni old_value = db_get_value(addr, size, false);
745b81b6b3SRodney W. Grimes db_printsym(addr, DB_STGY_ANY);
751c6989faSPeter Wemm db_printf("\t\t%#8lr\t=\t%#8lr\n", (long)old_value,(long)new_value);
765b81b6b3SRodney W. Grimes db_put_value(addr, size, new_value);
775b81b6b3SRodney W. Grimes addr += size;
785b81b6b3SRodney W. Grimes
792b490bc7SPedro F. Giffuni wrote_one = true;
805b81b6b3SRodney W. Grimes }
815b81b6b3SRodney W. Grimes
825b81b6b3SRodney W. Grimes if (!wrote_one)
835b81b6b3SRodney W. Grimes db_error("Nothing written.\n");
845b81b6b3SRodney W. Grimes
855b81b6b3SRodney W. Grimes db_next = addr;
865b81b6b3SRodney W. Grimes db_prev = addr - size;
875b81b6b3SRodney W. Grimes
885b81b6b3SRodney W. Grimes db_skip_to_eol();
895b81b6b3SRodney W. Grimes }
90