Annotation of Net2/ddb/db_write_cmd.c, revision 1.1.1.1

1.1       root        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:  * software, derivative works or modified versions, and any portions
                     10:  * thereof, and that both notices appear in supporting documentation.
                     11:  * 
                     12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     15:  * 
                     16:  * Carnegie Mellon requests users of this software to return to
                     17:  * 
                     18:  *  Software Distribution Coordinator  or  [email protected]
                     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: /*
                     27:  * HISTORY
                     28:  * $Log: db_write_cmd.c,v $
                     29:  * Revision 1.1  1992/03/25  21:45:42  pace
                     30:  * Initial revision
                     31:  *
                     32:  * Revision 2.4  91/02/05  17:07:35  mrt
                     33:  *     Changed to new Mach copyright
                     34:  *     [91/01/31  16:20:19  mrt]
                     35:  * 
                     36:  * Revision 2.3  90/10/25  14:44:26  rwd
                     37:  *     Changed db_write_cmd to print unsigned.
                     38:  *     [90/10/19            rpd]
                     39:  * 
                     40:  * Revision 2.2  90/08/27  21:53:54  dbg
                     41:  *     Set db_prev and db_next instead of explicitly advancing dot.
                     42:  *     [90/08/22            dbg]
                     43:  *     Reflected changes in db_printsym()'s calling seq.
                     44:  *     [90/08/20            af]
                     45:  *     Warn user if nothing was written.
                     46:  *     [90/08/07            dbg]
                     47:  *     Created.
                     48:  *     [90/07/25            dbg]
                     49:  * 
                     50:  */
                     51: /*
                     52:  *     Author: David B. Golub,  Carnegie Mellon University
                     53:  *     Date:   7/90
                     54:  */
                     55: 
                     56: #include "param.h"
                     57: #include "proc.h"
                     58: #include <machine/db_machdep.h>
                     59: 
                     60: #include <ddb/db_lex.h>
                     61: #include <ddb/db_access.h>
                     62: #include <ddb/db_command.h>
                     63: #include <ddb/db_sym.h>
                     64: 
                     65: /*
                     66:  * Write to file.
                     67:  */
                     68: /*ARGSUSED*/
                     69: void
                     70: db_write_cmd(address, have_addr, count, modif)
                     71:        db_expr_t       address;
                     72:        boolean_t       have_addr;
                     73:        db_expr_t       count;
                     74:        char *          modif;
                     75: {
                     76:        register
                     77:        db_addr_t       addr;
                     78:        register
                     79:        db_expr_t       old_value;
                     80:        db_expr_t       new_value;
                     81:        register int    size;
                     82:        boolean_t       wrote_one = FALSE;
                     83: 
                     84:        addr = (db_addr_t) address;
                     85: 
                     86:        switch (modif[0]) {
                     87:            case 'b':
                     88:                size = 1;
                     89:                break;
                     90:            case 'h':
                     91:                size = 2;
                     92:                break;
                     93:            case 'l':
                     94:            case '\0':
                     95:                size = 4;
                     96:                break;
                     97:            default:
                     98:                db_error("Unknown size\n");
                     99:                return;
                    100:        }
                    101: 
                    102:        while (db_expression(&new_value)) {
                    103:            old_value = db_get_value(addr, size, FALSE);
                    104:            db_printsym(addr, DB_STGY_ANY);
                    105:            db_printf("\t\t%#8n\t=\t%#8n\n", old_value, new_value);
                    106:            db_put_value(addr, size, new_value);
                    107:            addr += size;
                    108: 
                    109:            wrote_one = TRUE;
                    110:        }
                    111: 
                    112:        if (!wrote_one)
                    113:            db_error("Nothing written.\n");
                    114: 
                    115:        db_next = addr;
                    116:        db_prev = addr - size;
                    117: 
                    118:        db_skip_to_eol();
                    119: }
                    120: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.