|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: */
25: /*
26: * HISTORY
27: *
28: * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
29: * Import of Mac OS X kernel (~semeria)
30: *
31: * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
32: * Import of OSF Mach kernel (~mburg)
33: *
34: * Revision 1.2.18.5 1996/01/09 19:16:34 devrcs
35: * Search the alternate register names if configured
36: * Changed declarations of 'register foo' to 'register int foo'.
37: * [1995/12/01 21:42:42 jfraser]
38: *
39: * Merged '64-bit safe' changes from DEC alpha port.
40: * [1995/11/21 18:03:56 jfraser]
41: *
42: * Revision 1.2.18.4 1995/02/23 21:43:56 alanl
43: * Merged with DIPC2_SHARED.
44: * [1995/01/05 13:35:55 alanl]
45: *
46: * Revision 1.2.21.1 1994/11/04 09:53:26 dwm
47: * mk6 CR668 - 1.3b26 merge
48: * * Revision 1.2.4.6 1994/05/06 18:40:13 tmt
49: * Merged osc1.3dec/shared with osc1.3b19
50: * Merge Alpha changes into osc1.312b source code.
51: * 64bit cleanup.
52: * * End1.3merge
53: * [1994/11/04 08:50:12 dwm]
54: *
55: * Revision 1.2.18.2 1994/09/23 01:22:35 ezf
56: * change marker to not FREE
57: * [1994/09/22 21:11:24 ezf]
58: *
59: * Revision 1.2.18.1 1994/06/11 21:12:37 bolinger
60: * Merge up to NMK17.2.
61: * [1994/06/11 20:03:04 bolinger]
62: *
63: * Revision 1.2.23.1 1994/12/06 19:43:18 alanl
64: * Intel merge, Oct 94 code drop.
65: * Added db_find_reg_name (came from db_print.c).
66: * [94/11/28 mmp]
67: *
68: * Revision 1.2.16.1 1994/02/08 10:59:08 bernadat
69: * Added completion variable.
70: * [93/08/17 paire]
71: *
72: * Set up new fields (hidden_xxx) of db_vars[] array that are supposed
73: * to be helpful to display variables depending on an internal value
74: * like db_macro_level for macro arguments.
75: * Added db_auto_wrap as new variable.
76: * Added "set help" for listing all available variables.
77: * Added db_show_variable() and db_show_one_variable()
78: * to print variable values.
79: * [93/08/12 paire]
80: * [94/02/08 bernadat]
81: *
82: * Revision 1.2.4.4 1993/08/11 20:38:20 elliston
83: * Add ANSI Prototypes. CR #9523.
84: * [1993/08/11 03:34:13 elliston]
85: *
86: * Revision 1.2.4.3 1993/07/27 18:28:27 elliston
87: * Add ANSI prototypes. CR #9523.
88: * [1993/07/27 18:13:22 elliston]
89: *
90: * Revision 1.2.4.2 1993/06/09 02:21:02 gm
91: * Added to OSF/1 R1.3 from NMK15.0.
92: * [1993/06/02 20:57:43 jeffc]
93: *
94: * Revision 1.2 1993/04/19 16:03:25 devrcs
95: * Changes from mk78:
96: * Added void to db_read_write_variable().
97: * Removed unused variable 'func' from db_set_cmd().
98: * [92/05/16 jfriedl]
99: * [93/02/02 bruel]
100: *
101: * Print old value when changing register values.
102: * [[email protected]]
103: * [92/12/03 bernadat]
104: *
105: * Revision 1.1 1992/09/30 02:01:31 robert
106: * Initial revision
107: *
108: * $EndLog$
109: */
110: /* CMU_HIST */
111: /*
112: * Revision 2.5 91/10/09 16:03:59 af
113: * Revision 2.4.3.1 91/10/05 13:08:27 jeffreyh
114: * Added suffix handling and thread handling of variables.
115: * Added new variables: lines, task, thread, work and arg.
116: * Moved db_read_variable and db_write_variable to db_variables.h
117: * as macros, and added db_read_write_variable instead.
118: * Changed some error messages.
119: * [91/08/29 tak]
120: *
121: * Revision 2.4.3.1 91/10/05 13:08:27 jeffreyh
122: * Added suffix handling and thread handling of variables.
123: * Added new variables: lines, task, thread, work and arg.
124: * Moved db_read_variable and db_write_variable to db_variables.h
125: * as macros, and added db_read_write_variable instead.
126: * Changed some error messages.
127: * [91/08/29 tak]
128: *
129: * Revision 2.4 91/05/14 15:36:57 mrt
130: * Correcting copyright
131: *
132: * Revision 2.3 91/02/05 17:07:19 mrt
133: * Changed to new Mach copyright
134: * [91/01/31 16:19:46 mrt]
135: *
136: * Revision 2.2 90/08/27 21:53:24 dbg
137: * New db_read/write_variable functions. Should be used instead
138: * of dereferencing valuep directly, which might not be a true
139: * pointer if there is an fcn() access function.
140: * [90/08/20 af]
141: *
142: * Fix declarations.
143: * Check for trailing garbage after last expression on command line.
144: * [90/08/10 14:34:54 dbg]
145: *
146: * Created.
147: * [90/07/25 dbg]
148: *
149: */
150: /* CMU_ENDHIST */
151: /*
152: * Mach Operating System
153: * Copyright (c) 1991,1990 Carnegie Mellon University
154: * All Rights Reserved.
155: *
156: * Permission to use, copy, modify and distribute this software and its
157: * documentation is hereby granted, provided that both the copyright
158: * notice and this permission notice appear in all copies of the
159: * software, derivative works or modified versions, and any portions
160: * thereof, and that both notices appear in supporting documentation.
161: *
162: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
163: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
164: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
165: *
166: * Carnegie Mellon requests users of this software to return to
167: *
168: * Software Distribution Coordinator or [email protected]
169: * School of Computer Science
170: * Carnegie Mellon University
171: * Pittsburgh PA 15213-3890
172: *
173: * any improvements or extensions that they make and grant Carnegie Mellon
174: * the rights to redistribute these changes.
175: */
176: /*
177: */
178: /*
179: * Author: David B. Golub, Carnegie Mellon University
180: * Date: 7/90
181: */
182:
183: #include <machine/db_machdep.h>
184: #include <string.h> /* For strcpy() */
185:
186: #include <ddb/db_lex.h>
187: #include <ddb/db_variables.h>
188: #include <ddb/db_task_thread.h>
189: #include <ddb/db_sym.h>
190: #include <ddb/db_command.h>
191: #include <ddb/db_expr.h>
192: #include <ddb/db_macro.h>
193: #include <ddb/db_output.h> /* For db_printf() */
194:
195: extern db_expr_t db_radix;
196: extern db_expr_t db_max_width;
197: extern db_expr_t db_tab_stop_width;
198: extern db_expr_t db_max_line;
199: extern db_expr_t db_auto_wrap;
200: extern db_expr_t db_macro_level;
201: extern db_expr_t db_auto_completion;
202:
203: #define DB_NWORK 32 /* number of work variable */
204:
205: db_expr_t db_work[DB_NWORK]; /* work variable */
206:
207: struct db_variable db_vars[] = {
208: { "maxoff", (db_expr_t*)&db_maxoff, FCN_NULL },
209: { "autowrap", &db_auto_wrap, FCN_NULL },
210: { "completion", &db_auto_completion, FCN_NULL },
211: { "maxwidth", &db_max_width, FCN_NULL },
212: { "radix", &db_radix, FCN_NULL },
213: { "tabstops", &db_tab_stop_width, FCN_NULL },
214: { "lines", &db_max_line, FCN_NULL },
215: { "thr_act", 0, db_set_default_act },
216: { "task", 0, db_get_task_act,
217: 1, 2, -1, -1 },
218: { "work", &db_work[0], FCN_NULL,
219: 1, 1, 0, DB_NWORK-1 },
220: { "arg", 0, db_arg_variable,
221: 1, 1, 1, DB_MACRO_NARGS,
222: 1, 0, DB_MACRO_LEVEL-1, (int *)&db_macro_level },
223: };
224: struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
225:
226:
227:
228: /* Prototypes for functions local to this file.
229: */
230:
231: static char *db_get_suffix(
232: register char *suffix,
233: short *suffix_value);
234:
235: static boolean_t db_cmp_variable_name(
236: struct db_variable *vp,
237: char *name,
238: register db_var_aux_param_t ap);
239:
240: static int db_find_variable(
241: struct db_variable **varp,
242: db_var_aux_param_t ap);
243:
244: static int db_set_variable(db_expr_t value);
245:
246: void db_list_variable(void);
247:
248: static char *
249: db_get_suffix(
250: register char *suffix,
251: short *suffix_value)
252: {
253: register int value;
254:
255: for (value = 0; *suffix && *suffix != '.' && *suffix != ':'; suffix++) {
256: if (*suffix < '0' || *suffix > '9')
257: return(0);
258: value = value*10 + *suffix - '0';
259: }
260: *suffix_value = value;
261: if (*suffix == '.')
262: suffix++;
263: return(suffix);
264: }
265:
266: static boolean_t
267: db_cmp_variable_name(
268: struct db_variable *vp,
269: char *name,
270: register db_var_aux_param_t ap)
271: {
272: register char *var_np, *np;
273: register int level;
274:
275: for (np = name, var_np = vp->name; *var_np; ) {
276: if (*np++ != *var_np++)
277: return(FALSE);
278: }
279: for (level = 0; *np && *np != ':' && level < vp->max_level; level++){
280: if ((np = db_get_suffix(np, &ap->suffix[level])) == 0)
281: return(FALSE);
282: }
283: if ((*np && *np != ':') || level < vp->min_level
284: || (level > 0 && (ap->suffix[0] < vp->low
285: || (vp->high >= 0 && ap->suffix[0] > vp->high))))
286: return(FALSE);
287: strcpy(ap->modif, (*np)? np+1: "");
288: ap->thr_act = (db_option(ap->modif, 't')?db_default_act: THR_ACT_NULL);
289: ap->level = level;
290: ap->hidden_level = -1;
291: return(TRUE);
292: }
293:
294: static int
295: db_find_variable(
296: struct db_variable **varp,
297: db_var_aux_param_t ap)
298: {
299: int t;
300: struct db_variable *vp;
301:
302: t = db_read_token();
303: if (t == tIDENT) {
304: for (vp = db_vars; vp < db_evars; vp++) {
305: if (db_cmp_variable_name(vp, db_tok_string, ap)) {
306: *varp = vp;
307: return (1);
308: }
309: }
310: for (vp = db_regs; vp < db_eregs; vp++) {
311: if (db_cmp_variable_name(vp, db_tok_string, ap)) {
312: *varp = vp;
313: return (1);
314: }
315: }
316: #if defined(ALTERNATE_REGISTER_DEFS)
317: for (vp = db_altregs; vp < db_ealtregs; vp++) {
318: if (db_cmp_variable_name(vp, db_tok_string, ap)) {
319: *varp = vp;
320: return (1);
321: }
322: }
323: #endif /* defined(ALTERNATE_REGISTER_DEFS) */
324: }
325: db_printf("Unknown variable \"$%s\"\n", db_tok_string);
326: db_error(0);
327: return (0);
328: }
329:
330: int
331: db_get_variable(db_expr_t *valuep)
332: {
333: struct db_variable *vp;
334: struct db_var_aux_param aux_param;
335: char modif[TOK_STRING_SIZE];
336:
337: aux_param.modif = modif;
338: if (!db_find_variable(&vp, &aux_param))
339: return (0);
340:
341: db_read_write_variable(vp, valuep, DB_VAR_GET, &aux_param);
342:
343: return (1);
344: }
345:
346: static int
347: db_set_variable(db_expr_t value)
348: {
349: struct db_variable *vp;
350: struct db_var_aux_param aux_param;
351: char modif[TOK_STRING_SIZE];
352:
353: aux_param.modif = modif;
354: if (!db_find_variable(&vp, &aux_param))
355: return (0);
356:
357: db_read_write_variable(vp, &value, DB_VAR_SET, &aux_param);
358:
359: return (1);
360: }
361:
362: void
363: db_read_write_variable(
364: struct db_variable *vp,
365: db_expr_t *valuep,
366: int rw_flag,
367: db_var_aux_param_t ap)
368: {
369: int (*func)(struct db_variable*, db_expr_t*,int, db_var_aux_param_t)
370: = vp->fcn;
371: struct db_var_aux_param aux_param;
372: db_expr_t old_value;
373:
374: if (ap == 0) {
375: ap = &aux_param;
376: ap->modif = "";
377: ap->level = 0;
378: ap->thr_act = THR_ACT_NULL;
379: }
380: if (rw_flag == DB_VAR_SET && vp->precious)
381: db_read_write_variable(vp, &old_value, DB_VAR_GET, ap);
382: if (func == FCN_NULL) {
383: if (rw_flag == DB_VAR_SET)
384: vp->valuep[(ap->level)? (ap->suffix[0] - vp->low): 0] = *valuep;
385: else
386: *valuep = vp->valuep[(ap->level)? (ap->suffix[0] - vp->low): 0];
387: } else
388: (*func)(vp, valuep, rw_flag, ap);
389: if (rw_flag == DB_VAR_SET && vp->precious)
390: db_printf("\t$%s:%s<%#x>\t%#8n\t=\t%#8n\n", vp->name,
391: ap->modif, ap->thr_act, old_value, *valuep);
392: }
393:
394: void
395: db_list_variable(void)
396: {
397: register struct db_variable *new;
398: register struct db_variable *old;
399: register struct db_variable *cur;
400: unsigned int l;
401: unsigned int len;
402: short i;
403: unsigned int j;
404:
405: len = 1;
406: for (cur = db_vars; cur < db_evars; cur++) {
407: if (cur->min_level > 0 || cur->max_level > 0) {
408: j = 3 * (cur->max_level - cur->min_level + 1) - 1;
409: if (cur->max_level > cur->min_level)
410: j += 2;
411: } else
412: j = 0;
413: if ((l = strlen(cur->name) + j) >= len)
414: len = l + 1;
415: }
416:
417: old = (struct db_variable *)0;
418: for (;;) {
419: new = (struct db_variable *)0;
420: for (cur = db_vars; cur < db_evars; cur++)
421: if ((new == (struct db_variable *)0 ||
422: strcmp(cur->name, new->name) < 0) &&
423: (old == (struct db_variable *)0 ||
424: strcmp(cur->name, old->name) > 0))
425: new = cur;
426: if (new == (struct db_variable *)0)
427: return;
428: db_reserve_output_position(len);
429: db_printf(new->name);
430: j = strlen(new->name);
431: if (new->min_level > 0) {
432: db_putchar('?');
433: db_putchar('?');
434: j += 2;
435: for (i = new->min_level - 1; i > 0; i--) {
436: db_putchar('.');
437: db_putchar('?');
438: db_putchar('?');
439: j += 3;
440: }
441: if (new->max_level > new->min_level) {
442: db_putchar('[');
443: db_putchar('.');
444: db_putchar('?');
445: db_putchar('?');
446: j += 4;
447: }
448: i = new->min_level + 1;
449: } else {
450: if (new->max_level > new->min_level) {
451: db_putchar('[');
452: j++;
453: }
454: i = new->min_level;
455: }
456: while (i++ < new->max_level) {
457: db_putchar('.');
458: db_putchar('?');
459: db_putchar('?');
460: j += 3;
461: }
462: if (new->max_level > new->min_level) {
463: db_putchar(']');
464: j++;
465: }
466: while (j++ < len)
467: db_putchar(' ');
468: old = new;
469: }
470: }
471:
472: void
473: db_set_cmd(void)
474: {
475: db_expr_t value;
476: int t;
477: struct db_variable *vp;
478: struct db_var_aux_param aux_param;
479: char modif[TOK_STRING_SIZE];
480:
481: aux_param.modif = modif;
482: t = db_read_token();
483: if (t == tIDENT && strcmp("help", db_tok_string) == 0) {
484: db_list_variable();
485: return;
486: }
487: if (t != tDOLLAR) {
488: db_error("Variable name should be prefixed with $\n");
489: return;
490: }
491: if (!db_find_variable(&vp, &aux_param)) {
492: db_error("Unknown variable\n");
493: return;
494: }
495:
496: t = db_read_token();
497: if (t != tEQ)
498: db_unread_token(t);
499:
500: if (!db_expression(&value)) {
501: db_error("No value\n");
502: return;
503: }
504: if ((t = db_read_token()) == tSEMI_COLON)
505: db_unread_token(t);
506: else if (t != tEOL)
507: db_error("?\n");
508:
509: db_read_write_variable(vp, &value, DB_VAR_SET, &aux_param);
510: }
511:
512: void
513: db_show_one_variable(void)
514: {
515: struct db_variable *cur;
516: unsigned int len;
517: unsigned int sl;
518: unsigned int slen;
519: short h;
520: short i;
521: short j;
522: short k;
523: short low;
524: int hidden_level;
525: struct db_var_aux_param aux_param;
526: char *p;
527: char *q;
528: char *name;
529: db_addr_t offset;
530:
531: for (cur = db_vars; cur < db_evars; cur++)
532: if (db_cmp_variable_name(cur, db_tok_string, &aux_param))
533: break;
534: if (cur == db_evars) {
535: for (cur = db_vars; cur < db_evars; cur++) {
536: for (q = cur->name, p = db_tok_string; *q && *p == *q; p++,q++)
537: continue;
538: if (*q == '\0')
539: break;
540: }
541: if (cur == db_evars) {
542: db_error("Unknown variable\n");
543: return;
544: }
545:
546: for (i = 0; *p && *p != ':' && i < cur->max_level; i++, p = q)
547: if ((q = db_get_suffix(p, &aux_param.suffix[i])) == 0)
548: break;
549: aux_param.level = i;
550: if ((*p && *p != ':') ||
551: (i > 0 && (aux_param.suffix[0] < cur->low ||
552: (cur->high >= 0 &&
553: aux_param.suffix[0] > cur->high)))) {
554: db_error("Unknown variable format\n");
555: return;
556: }
557:
558: strcpy(aux_param.modif, *p ? p + 1 : "");
559: aux_param.thr_act = (db_option(aux_param.modif, 't') ?
560: db_default_act : THR_ACT_NULL);
561: }
562:
563: if (cur->hidden_level)
564: if (*cur->hidden_levelp >= cur->hidden_low &&
565: *cur->hidden_levelp <= cur->hidden_high) {
566: hidden_level = 1;
567: aux_param.hidden_level = h = *cur->hidden_levelp;
568: } else {
569: hidden_level = 0;
570: aux_param.hidden_level = h = cur->hidden_low;
571: slen = 1;
572: for (k = aux_param.level > 0 ? aux_param.suffix[0] : cur->high;
573: k > 9; k /= 10)
574: slen++;
575: }
576: else
577: aux_param.hidden_level = -1;
578:
579: if ((cur->min_level == 0 && !cur->hidden_level) || cur->high < 0)
580: j = 0;
581: else {
582: if (cur->min_level > 0) {
583: j = 1;
584: for (k = aux_param.level > 0 ?
585: aux_param.suffix[0] : cur->high; k > 9; k /= 10)
586: j++;
587: } else
588: j = 0;
589: if (cur->hidden_level && hidden_level == 0) {
590: j += 3;
591: for (k = aux_param.hidden_level >= 0 ?
592: aux_param.hidden_level : cur->hidden_high; k > 9; k /= 10)
593: j++;
594: }
595: }
596: len = strlen(cur->name) + j;
597: i = low = aux_param.level > 0 ? aux_param.suffix[0] : cur->low;
598:
599: for (;;) {
600: db_printf(cur->name);
601: j = strlen(cur->name);
602: if (cur->high >= 0) {
603: if (cur->min_level > 0) {
604: db_printf("%d", i);
605: j++;
606: for (k = i; k > 9; k /= 10)
607: j++;
608: }
609: if (cur->hidden_level && hidden_level == 0) {
610: sl = 1;
611: for (k = i; k > 9; k /= 10)
612: sl++;
613: while (sl++ < slen) {
614: db_putchar(' ');
615: j++;
616: }
617: db_printf("[%d]", h);
618: j += 3;
619: for (k = h; k > 9; k /= 10)
620: j++;
621: }
622: }
623:
624: while (j++ < len)
625: db_putchar(' ');
626: db_putchar(':');
627: db_putchar(' ');
628:
629: if (cur->fcn) {
630: aux_param.suffix[0] = i;
631: (*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
632: } else {
633: db_printf("%#n", *(cur->valuep + i));
634: db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
635: &offset, TASK_NULL);
636: if (name != (char *)0 && offset <= db_maxoff &&
637: offset != *(cur->valuep + i)) {
638: db_printf("\t%s", name);
639: if (offset != 0)
640: db_printf("+%#r", offset);
641: }
642: }
643: db_putchar('\n');
644: if (cur->high < 0)
645: break;
646: if (aux_param.level > 0 || i++ == cur->high) {
647: if (!cur->hidden_level ||
648: hidden_level == 0 ||
649: h++ == cur->hidden_high)
650: break;
651: aux_param.hidden_level = h;
652: i = low;
653: }
654: }
655: }
656:
657: void
658: db_show_variable(void)
659: {
660: struct db_variable *cur;
661: unsigned int l;
662: unsigned int len;
663: unsigned int sl;
664: unsigned int slen;
665: short h;
666: short i;
667: short j;
668: short k;
669: int t;
670: int t1;
671: struct db_var_aux_param aux_param;
672: char *name;
673: db_addr_t offset;
674:
675: switch(t = db_read_token()) {
676: case tEOL:
677: case tEOF:
678: case tSEMI_COLON:
679: break;
680:
681: case tDOLLAR:
682: t1 = db_read_token();
683: if (t1 == tIDENT) {
684: db_show_one_variable();
685: return;
686: }
687: db_error("Not a variable name after $\n");
688: db_unread_token(t);
689: return;
690:
691: default:
692: db_error("Variable name should be prefixed with $\n");
693: db_unread_token(t);
694: return;
695: }
696: db_unread_token(t);
697:
698: slen = len = 1;
699: for (cur = db_vars; cur < db_evars; cur++) {
700: if ((cur->min_level == 0 && !cur->hidden_level) || cur->high < 0)
701: j = 0;
702: else {
703: if (cur->min_level > 0) {
704: j = 1;
705: for (k = cur->high; k > 9; k /= 10)
706: j++;
707: } else
708: j = 0;
709: if (cur->hidden_level &&
710: (*cur->hidden_levelp < cur->hidden_low ||
711: *cur->hidden_levelp > cur->hidden_high)) {
712: j += 3;
713: for (k = cur->hidden_high; k > 9; k /= 10)
714: j++;
715: }
716: }
717: if ((l = strlen(cur->name) + j) >= len)
718: len = l + 1;
719: }
720:
721: aux_param.modif = "";
722: aux_param.level = 1;
723: aux_param.thr_act = THR_ACT_NULL;
724:
725: for (cur = db_vars; cur < db_evars; cur++) {
726: i = cur->low;
727: if (cur->hidden_level) {
728: if (*cur->hidden_levelp >= cur->hidden_low &&
729: *cur->hidden_levelp <= cur->hidden_high) {
730: h = cur->hidden_low - 1;
731: aux_param.hidden_level = *cur->hidden_levelp;
732: } else {
733: h = cur->hidden_low;
734: aux_param.hidden_level = cur->hidden_low;
735: }
736: slen = 1;
737: for (k = cur->high; k > 9; k /= 10)
738: slen++;
739: } else
740: aux_param.hidden_level = -1;
741:
742: if (cur != db_vars && cur->high >= 0 &&
743: (cur->min_level > 0 || cur->hidden_level))
744: db_putchar('\n');
745:
746: for (;;) {
747: db_printf(cur->name);
748: j = strlen(cur->name);
749: if (cur->high >= 0) {
750: if (cur->min_level > 0) {
751: db_printf("%d", i);
752: j++;
753: for (k = i; k > 9; k /= 10)
754: j++;
755: }
756: if (cur->hidden_level && h >= cur->hidden_low) {
757: sl = 1;
758: for (k = i; k > 9; k /= 10)
759: sl++;
760: while (sl++ < slen) {
761: db_putchar(' ');
762: j++;
763: }
764: db_printf("[%d]", h);
765: j += 3;
766: for (k = h; k > 9; k /= 10)
767: j++;
768: }
769: }
770: while (j++ < len)
771: db_putchar(' ');
772: db_putchar(':');
773: db_putchar(' ');
774:
775: if (cur->fcn) {
776: aux_param.suffix[0] = i;
777: (*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
778: } else {
779: db_printf("%#n", *(cur->valuep + i));
780: db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
781: &offset, TASK_NULL);
782: if (name != (char *)0 && offset <= db_maxoff &&
783: offset != *(cur->valuep + i)) {
784: db_printf("\t%s", name);
785: if (offset != 0)
786: db_printf("+%#r", offset);
787: }
788: }
789: db_putchar('\n');
790: if (cur->high < 0)
791: break;
792: if (i++ == cur->high) {
793: if (!cur->hidden_level || h++ == cur->hidden_high)
794: break;
795: aux_param.hidden_level = h;
796: i = cur->low;
797: }
798: }
799: }
800: }
801:
802: /*
803: * given a name of a machine register, return a variable pointer to it.
804: */
805: db_variable_t
806: db_find_reg_name(
807: char *s)
808: {
809: register db_variable_t regp;
810:
811: if ( s == (char *)0 )
812: return DB_VAR_NULL;
813:
814: for (regp = db_regs; regp < db_eregs; regp++) {
815: if ( strcmp( s, regp->name) == 0 )
816: return regp;
817: }
818: return DB_VAR_NULL;
819: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.