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.
| 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.
|
50/* 51 * Author: David B. Golub, Carnegie Mellon University 52 * Date: 7/90 53 */ 54 55#include "param.h" 56#include "proc.h" 57#include <machine/db_machdep.h> 58 59#include <ddb/db_lex.h> 60#include <ddb/db_variables.h> 61 62extern unsigned int db_maxoff; 63 64extern int db_radix; 65extern int db_max_width; 66extern int db_tab_stop_width; 67 68struct db_variable db_vars[] = { 69 { "radix", &db_radix, FCN_NULL }, 70 { "maxoff", (int *)&db_maxoff, FCN_NULL }, 71 { "maxwidth", &db_max_width, FCN_NULL }, 72 { "tabstops", &db_tab_stop_width, FCN_NULL }, 73}; 74struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]); 75 76int 77db_find_variable(varp) 78 struct db_variable **varp; 79{ 80 int t; 81 struct db_variable *vp; 82 83 t = db_read_token(); 84 if (t == tIDENT) { 85 for (vp = db_vars; vp < db_evars; vp++) { 86 if (!strcmp(db_tok_string, vp->name)) { 87 *varp = vp; 88 return (1); 89 } 90 } 91 for (vp = db_regs; vp < db_eregs; vp++) { 92 if (!strcmp(db_tok_string, vp->name)) { 93 *varp = vp; 94 return (1); 95 } 96 } 97 } 98 db_error("Unknown variable\n"); 99 return (0); 100} 101 102int 103db_get_variable(valuep) 104 db_expr_t *valuep; 105{ 106 struct db_variable *vp; 107 108 if (!db_find_variable(&vp)) 109 return (0); 110 111 db_read_variable(vp, valuep); 112 113 return (1); 114} 115 116int 117db_set_variable(value) 118 db_expr_t value; 119{ 120 struct db_variable *vp; 121 122 if (!db_find_variable(&vp)) 123 return (0); 124 125 db_write_variable(vp, &value); 126 127 return (1); 128} 129 130 131db_read_variable(vp, valuep) 132 struct db_variable *vp; 133 db_expr_t *valuep; 134{ 135 int (*func)() = vp->fcn; 136 137 if (func == FCN_NULL) 138 *valuep = *(vp->valuep); 139 else 140 (*func)(vp, valuep, DB_VAR_GET); 141} 142 143db_write_variable(vp, valuep) 144 struct db_variable *vp; 145 db_expr_t *valuep; 146{ 147 int (*func)() = vp->fcn; 148 149 if (func == FCN_NULL) 150 *(vp->valuep) = *valuep; 151 else 152 (*func)(vp, valuep, DB_VAR_SET); 153} 154 155void 156db_set_cmd() 157{ 158 db_expr_t value; 159 int (*func)(); 160 struct db_variable *vp; 161 int t; 162 163 t = db_read_token(); 164 if (t != tDOLLAR) { 165 db_error("Unknown variable\n"); 166 return; 167 } 168 if (!db_find_variable(&vp)) { 169 db_error("Unknown variable\n"); 170 return; 171 } 172 173 t = db_read_token(); 174 if (t != tEQ) 175 db_unread_token(t); 176 177 if (!db_expression(&value)) { 178 db_error("No value\n"); 179 return; 180 } 181 if (db_read_token() != tEOL) { 182 db_error("?\n"); 183 } 184 185 db_write_variable(vp, &value); 186}
| 29/* 30 * Author: David B. Golub, Carnegie Mellon University 31 * Date: 7/90 32 */ 33 34#include "param.h" 35#include "proc.h" 36#include <machine/db_machdep.h> 37 38#include <ddb/db_lex.h> 39#include <ddb/db_variables.h> 40 41extern unsigned int db_maxoff; 42 43extern int db_radix; 44extern int db_max_width; 45extern int db_tab_stop_width; 46 47struct db_variable db_vars[] = { 48 { "radix", &db_radix, FCN_NULL }, 49 { "maxoff", (int *)&db_maxoff, FCN_NULL }, 50 { "maxwidth", &db_max_width, FCN_NULL }, 51 { "tabstops", &db_tab_stop_width, FCN_NULL }, 52}; 53struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]); 54 55int 56db_find_variable(varp) 57 struct db_variable **varp; 58{ 59 int t; 60 struct db_variable *vp; 61 62 t = db_read_token(); 63 if (t == tIDENT) { 64 for (vp = db_vars; vp < db_evars; vp++) { 65 if (!strcmp(db_tok_string, vp->name)) { 66 *varp = vp; 67 return (1); 68 } 69 } 70 for (vp = db_regs; vp < db_eregs; vp++) { 71 if (!strcmp(db_tok_string, vp->name)) { 72 *varp = vp; 73 return (1); 74 } 75 } 76 } 77 db_error("Unknown variable\n"); 78 return (0); 79} 80 81int 82db_get_variable(valuep) 83 db_expr_t *valuep; 84{ 85 struct db_variable *vp; 86 87 if (!db_find_variable(&vp)) 88 return (0); 89 90 db_read_variable(vp, valuep); 91 92 return (1); 93} 94 95int 96db_set_variable(value) 97 db_expr_t value; 98{ 99 struct db_variable *vp; 100 101 if (!db_find_variable(&vp)) 102 return (0); 103 104 db_write_variable(vp, &value); 105 106 return (1); 107} 108 109 110db_read_variable(vp, valuep) 111 struct db_variable *vp; 112 db_expr_t *valuep; 113{ 114 int (*func)() = vp->fcn; 115 116 if (func == FCN_NULL) 117 *valuep = *(vp->valuep); 118 else 119 (*func)(vp, valuep, DB_VAR_GET); 120} 121 122db_write_variable(vp, valuep) 123 struct db_variable *vp; 124 db_expr_t *valuep; 125{ 126 int (*func)() = vp->fcn; 127 128 if (func == FCN_NULL) 129 *(vp->valuep) = *valuep; 130 else 131 (*func)(vp, valuep, DB_VAR_SET); 132} 133 134void 135db_set_cmd() 136{ 137 db_expr_t value; 138 int (*func)(); 139 struct db_variable *vp; 140 int t; 141 142 t = db_read_token(); 143 if (t != tDOLLAR) { 144 db_error("Unknown variable\n"); 145 return; 146 } 147 if (!db_find_variable(&vp)) { 148 db_error("Unknown variable\n"); 149 return; 150 } 151 152 t = db_read_token(); 153 if (t != tEQ) 154 db_unread_token(t); 155 156 if (!db_expression(&value)) { 157 db_error("No value\n"); 158 return; 159 } 160 if (db_read_token() != tEOL) { 161 db_error("?\n"); 162 } 163 164 db_write_variable(vp, &value); 165}
|