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_variables.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    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  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 the
   24  * rights to redistribute these changes.
   25  */
   26 /*
   27  *      Author: David B. Golub, Carnegie Mellon University
   28  *      Date:   7/90
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD: stable/11/sys/ddb/db_variables.c 298354 2016-04-20 16:19:44Z pfg $");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 
   37 #include <ddb/ddb.h>
   38 #include <ddb/db_lex.h>
   39 #include <ddb/db_variables.h>
   40 
   41 static int      db_find_variable(struct db_variable **varp);
   42 
   43 static struct db_variable db_vars[] = {
   44         { "radix",      &db_radix, FCN_NULL },
   45         { "maxoff",     &db_maxoff, FCN_NULL },
   46         { "maxwidth",   &db_max_width, FCN_NULL },
   47         { "tabstops",   &db_tab_stop_width, FCN_NULL },
   48         { "lines",      &db_lines_per_page, FCN_NULL },
   49         { "curcpu",     NULL, db_var_curcpu },
   50         { "db_cpu",     NULL, db_var_db_cpu },
   51 #ifdef VIMAGE
   52         { "curvnet",    NULL, db_var_curvnet },
   53         { "db_vnet",    NULL, db_var_db_vnet },
   54 #endif
   55 };
   56 static struct db_variable *db_evars = db_vars + nitems(db_vars);
   57 
   58 static int
   59 db_find_variable(struct db_variable **varp)
   60 {
   61         struct db_variable *vp;
   62         int t;
   63 
   64         t = db_read_token();
   65         if (t == tIDENT) {
   66                 for (vp = db_vars; vp < db_evars; vp++) {
   67                         if (!strcmp(db_tok_string, vp->name)) {
   68                                 *varp = vp;
   69                                 return (1);
   70                         }
   71                 }
   72                 for (vp = db_regs; vp < db_eregs; vp++) {
   73                         if (!strcmp(db_tok_string, vp->name)) {
   74                                 *varp = vp;
   75                                 return (1);
   76                         }
   77                 }
   78         }
   79         db_error("Unknown variable\n");
   80         return (0);
   81 }
   82 
   83 int
   84 db_get_variable(db_expr_t *valuep)
   85 {
   86         struct db_variable *vp;
   87 
   88         if (!db_find_variable(&vp))
   89                 return (0);
   90 
   91         return (db_read_variable(vp, valuep));
   92 }
   93 
   94 int
   95 db_set_variable(db_expr_t value)
   96 {
   97         struct db_variable *vp;
   98 
   99         if (!db_find_variable(&vp))
  100                 return (0);
  101 
  102         return (db_write_variable(vp, value));
  103 }
  104 
  105 int
  106 db_read_variable(struct db_variable *vp, db_expr_t *valuep)
  107 {
  108         db_varfcn_t *func = vp->fcn;
  109 
  110         if (func == FCN_NULL) {
  111                 *valuep = *(vp->valuep);
  112                 return (1);
  113         }
  114         return ((*func)(vp, valuep, DB_VAR_GET));
  115 }
  116 
  117 int
  118 db_write_variable(struct db_variable *vp, db_expr_t value)
  119 {
  120         db_varfcn_t *func = vp->fcn;
  121 
  122         if (func == FCN_NULL) {
  123                 *(vp->valuep) = value;
  124                 return (1);
  125         }
  126         return ((*func)(vp, &value, DB_VAR_SET));
  127 }
  128 
  129 void
  130 db_set_cmd(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
  131 {
  132         struct db_variable *vp;
  133         db_expr_t value;
  134         int t;
  135 
  136         t = db_read_token();
  137         if (t != tDOLLAR) {
  138                 db_error("Unknown variable\n");
  139                 return;
  140         }
  141         if (!db_find_variable(&vp)) {
  142                 db_error("Unknown variable\n");
  143                 return;
  144         }
  145 
  146         t = db_read_token();
  147         if (t != tEQ)
  148                 db_unread_token(t);
  149 
  150         if (!db_expression(&value)) {
  151                 db_error("No value\n");
  152                 return;
  153         }
  154         if (db_read_token() != tEOL)
  155                 db_error("?\n");
  156 
  157         db_write_variable(vp, value);
  158 }

Cache object: 6c05ca07bf0b9cbbb63f90419b8d009e


[ 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.