Annotation of Gnu-Mach/ddb/db_write_cmd.c, revision 1.1.1.4

1.1.1.2   root        1: /*
1.1       root        2:  * Mach Operating System
                      3:  * Copyright (c) 1992,1991,1990 Carnegie Mellon University
                      4:  * All Rights Reserved.
1.1.1.2   root        5:  *
1.1       root        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.
1.1.1.2   root       11:  *
1.1       root       12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1.1.1.2   root       15:  *
1.1       root       16:  * Carnegie Mellon requests users of this software to return to
1.1.1.2   root       17:  *
1.1       root       18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
1.1.1.2   root       22:  *
1.1       root       23:  * any improvements or extensions that they make and grant Carnegie Mellon
                     24:  * the rights to redistribute these changes.
                     25:  */
                     26: /*
                     27:  *     Author: David B. Golub,  Carnegie Mellon University
                     28:  *     Date:   7/90
                     29:  */
                     30: 
                     31: #if MACH_KDB
                     32: 
                     33: #include <mach/boolean.h>
                     34: #include <kern/task.h>
                     35: #include <kern/thread.h>
                     36: 
                     37: #include <machine/db_machdep.h>
                     38: 
                     39: #include <ddb/db_lex.h>
                     40: #include <ddb/db_access.h>
                     41: #include <ddb/db_command.h>
1.1.1.3   root       42: #include <ddb/db_expr.h>
                     43: #include <ddb/db_output.h>
1.1       root       44: #include <ddb/db_sym.h>
                     45: #include <ddb/db_task_thread.h>
                     46: 
                     47: 
                     48: 
                     49: /*
                     50:  * Write to file.
                     51:  */
                     52: /*ARGSUSED*/
                     53: void
                     54: db_write_cmd(address, have_addr, count, modif)
                     55:        db_expr_t       address;
                     56:        boolean_t       have_addr;
                     57:        db_expr_t       count;
1.1.1.4 ! root       58:        const char *    modif;
1.1       root       59: {
1.1.1.4 ! root       60:        db_addr_t       addr;
        !            61:        db_expr_t       old_value;
1.1       root       62:        db_expr_t       new_value;
1.1.1.4 ! root       63:        int             size;
1.1       root       64:        boolean_t       wrote_one = FALSE;
                     65:        boolean_t       t_opt, u_opt;
                     66:        thread_t        thread;
                     67:        task_t          task;
                     68: 
                     69:        addr = (db_addr_t) address;
                     70: 
                     71:        size = db_size_option(modif, &u_opt, &t_opt);
1.1.1.2   root       72:        if (t_opt)
1.1       root       73:          {
                     74:            if (!db_get_next_thread(&thread, 0))
                     75:              return;
                     76:            task = thread->task;
                     77:          }
                     78:        else
                     79:          task = db_current_task();
1.1.1.2   root       80: 
                     81:        /* if user space is not explicitly specified,
1.1       root       82:           look in the kernel */
                     83:        if (!u_opt)
                     84:          task = TASK_NULL;
                     85: 
                     86:        if (!DB_VALID_ADDRESS(addr, u_opt)) {
                     87:          db_printf("Bad address %#*X\n", 2*sizeof(vm_offset_t), addr);
                     88:          return;
                     89:        }
                     90: 
                     91:        while (db_expression(&new_value)) {
                     92:            old_value = db_get_task_value(addr, size, FALSE, task);
                     93:            db_task_printsym(addr, DB_STGY_ANY, task);
                     94:            db_printf("\t\t%#*N\t=\t%#*N\n",
                     95:                2*sizeof(db_expr_t), old_value,
                     96:                2*sizeof(db_expr_t), new_value);
                     97:            db_put_task_value(addr, size, new_value, task);
                     98:            addr += size;
                     99: 
                    100:            wrote_one = TRUE;
                    101:        }
                    102: 
                    103:        if (!wrote_one)
                    104:            db_error("Nothing written.\n");
                    105: 
                    106:        db_next = addr;
                    107:        db_prev = addr - size;
                    108: }
                    109: 
1.1.1.2   root      110: #endif /* MACH_KDB */

unix.superglobalmegacorp.com

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