The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_write_cmd.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,1992,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 "AS IS"
   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  Software.Distribution@CS.CMU.EDU
   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 Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        db_write_cmd.c,v $
   29  * Revision 2.11  93/11/17  16:27:12  dbg
   30  *      ANSI-fied.
   31  *      [93/10/13            dbg]
   32  * 
   33  * Revision 2.10  93/01/14  17:26:21  danner
   34  *      64bit cleanup.
   35  *      [92/11/30            af]
   36  * 
   37  * Revision 2.9  92/08/03  17:32:36  jfriedl
   38  *      removed silly prototypes
   39  *      [92/08/02            jfriedl]
   40  * 
   41  * Revision 2.8  92/05/21  17:08:21  jfriedl
   42  *      Removed unused variable 'p' from db_write_cmd().
   43  *      [92/05/16            jfriedl]
   44  * 
   45  * Revision 2.7  92/05/04  11:24:18  danner
   46  *      Reorganized. w/u now works, instead of just w/tu. 
   47  *      [92/04/18            danner]
   48  * 
   49  * Revision 2.6  91/10/09  16:05:06  af
   50  *      Added user space write support including inactive task.
   51  *      [91/08/29            tak]
   52  * 
   53  * Revision 2.5  91/05/14  15:38:04  mrt
   54  *      Correcting copyright
   55  * 
   56  * Revision 2.4  91/02/05  17:07:35  mrt
   57  *      Changed to new Mach copyright
   58  *      [91/01/31  16:20:19  mrt]
   59  * 
   60  * Revision 2.3  90/10/25  14:44:26  rwd
   61  *      Changed db_write_cmd to print unsigned.
   62  *      [90/10/19            rpd]
   63  * 
   64  * Revision 2.2  90/08/27  21:53:54  dbg
   65  *      Set db_prev and db_next instead of explicitly advancing dot.
   66  *      [90/08/22            dbg]
   67  *      Reflected changes in db_printsym()'s calling seq.
   68  *      [90/08/20            af]
   69  *      Warn user if nothing was written.
   70  *      [90/08/07            dbg]
   71  *      Created.
   72  *      [90/07/25            dbg]
   73  * 
   74  */
   75 /*
   76  *      Author: David B. Golub,  Carnegie Mellon University
   77  *      Date:   7/90
   78  */
   79 
   80 #include <mach/boolean.h>
   81 #include <kern/task.h>
   82 #include <kern/thread.h>
   83 
   84 #include <machine/db_machdep.h>
   85 
   86 #include <ddb/db_lex.h>
   87 #include <ddb/db_access.h>
   88 #include <ddb/db_command.h>
   89 #include <ddb/db_examine.h>
   90 #include <ddb/db_output.h>
   91 #include <ddb/db_sym.h>
   92 #include <ddb/db_task_thread.h>
   93 
   94 
   95 
   96 /*
   97  * Write to file.
   98  */
   99 /*ARGSUSED*/
  100 void
  101 db_write_cmd(
  102         db_expr_t       address,
  103         boolean_t       have_addr,
  104         db_expr_t       count,
  105         char *          modif)
  106 {
  107         register db_addr_t      addr;
  108         register db_expr_t      old_value;
  109         db_expr_t       new_value;
  110         register int    size;
  111         boolean_t       wrote_one = FALSE;
  112         boolean_t       t_opt, u_opt;
  113         thread_t        thread;
  114         task_t          task;
  115 
  116         addr = (db_addr_t) address;
  117 
  118         size = db_size_option(modif, &u_opt, &t_opt);
  119         if (t_opt) 
  120           {
  121             if (!db_get_next_thread(&thread, 0))
  122               return;
  123             task = thread->task;
  124           }
  125         else
  126           task = db_current_task();
  127         
  128         /* if user space is not explicitly specified, 
  129            look in the kernel */
  130         if (!u_opt)
  131           task = TASK_NULL;
  132 
  133         if (!DB_VALID_ADDRESS(addr, u_opt)) {
  134           db_printf("Bad address %#*X\n", 2*sizeof(vm_offset_t), addr);
  135           return;
  136         }
  137 
  138         while (db_expression(&new_value)) {
  139             old_value = db_get_task_value(addr, size, FALSE, task);
  140             db_task_printsym(addr, DB_STGY_ANY, task);
  141             db_printf("\t\t%#*N\t=\t%#*N\n",
  142                 2*sizeof(db_expr_t), old_value,
  143                 2*sizeof(db_expr_t), new_value);
  144             db_put_task_value(addr, size, new_value, task);
  145             addr += size;
  146 
  147             wrote_one = TRUE;
  148         }
  149 
  150         if (!wrote_one)
  151             db_error("Nothing written.\n");
  152 
  153         db_next = addr;
  154         db_prev = addr - size;
  155 }

Cache object: 4aa544e49affb3684bb6a3d17d3075b2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.