brunner@bullhead.uucp (10/21/89)
Subject: Fix for dbx (part 3) Index: /usr/src/ucb/dbx IBM/4.3 Description: Several problems (too numerous to mention) exist with the December release of dbx. This is part 1 of a 5 part patch installation kit. The contents of the kit are: part 1 shar file containing help.c part 2 patchs to the following files: dbx/ibmrt/{coredump.c,decode.c,frame.c,procinfo.c} part 3 patchs to the following files: dbx/{object.c,eval.c,commands.y,c.c,tree.c} part 4 patchs to the following files: dbx/{runtime.c,symbols.c,execute.c,events.c,mappings.c} part 5 patches to the following files: dbx/{stabstring.c,printsym.c,operators.c,process.c, keywords.c,pascal.c,fortran.c,main.c,Makefile, examine.c,scanner.c,source.c,library.c} Fix: Change directories to /usr/src/ucb/dbx and apply this patch file, e.g., patch < this_file Proceede to the next part of the kit. Inconsistencies between the several compilers (hc, pp, f77) and the loader exist, stabs in particular. These will be corrected in a following patch to dbx, or in corrective releases of the compilers, or both. *** /usr/src/ucb/dbx/object.c Fri Dec 9 11:57:21 1988 --- object.c Thu Oct 12 14:37:18 1989 *************** *** 1,9 **** ! /* $Header:object.c 12.0$ */ ! /* $ACIS:object.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/RCS/object.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:object.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: object.c,v 12.1 89/10/12 17:37:17 brunner Locked $ */ ! /* $Source: /fish/dbx/RCS/object.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: object.c,v 12.1 89/10/12 17:37:17 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 100,109 **** } blkstack[curlevel] = curblock; ++curlevel; - curblock = b; if (traceblocks) { ! printf("entering block %s\n", symname(b)); } } /* --- 99,109 ---- } blkstack[curlevel] = curblock; ++curlevel; if (traceblocks) { ! printf("current = %s entering block %s\n", ! symname(curblock), symname(b)); } + curblock = b; } /* *************** *** 139,145 **** } --curlevel; if (traceblocks) { ! printf("exiting block %s\n", symname(curblock)); } curblock = blkstack[curlevel]; } --- 139,146 ---- } --curlevel; if (traceblocks) { ! printf("exiting block %s to block %s\n", ! symname(curblock),symname(blkstack[curlevel])); } curblock = blkstack[curlevel]; } *************** *** 249,260 **** private foundglobals () { ! if (curblock->class != PROG) { exitblock(); ! if (curblock->class != PROG) { ! exitblock(); ! } ! } enterline(0, (linep-1)->addr + 1); } --- 250,258 ---- private foundglobals () { ! while ( curblock->class != PROG ) exitblock(); ! enterline(0, (linep-1)->addr + 1); } *************** *** 262,272 **** * Read in symbols from object file. */ /* Has to be larger than maximum string table entry */ #define STRBUFSIZ (BUFSIZ * 4) private char strbuf[STRBUFSIZ]; ! private readsyms (f, fstr) Fileid f, fstr; { register File fp; --- 260,284 ---- * Read in symbols from object file. */ + pr_np(name,np) + char *name; + struct nlist *np; + { + printf("entry: "); + if (name != nil) { + printf("name %s,", name); + } + else printf("<unnamed>"); + + printf("ntype %2x, desc %x, value %x'\n", + np->n_type, np->n_desc, np->n_value); + } + /* Has to be larger than maximum string table entry */ #define STRBUFSIZ (BUFSIZ * 4) private char strbuf[STRBUFSIZ]; ! /*private*/ readsyms (f, fstr) Fileid f, fstr; { register File fp; *************** *** 281,290 **** --- 293,304 ---- foundstab = false; np = &nl; symcounter = nlhdr.nsyms; + if((symtabfp = fp = fdopen(f, "r")) == 0) panic("fdopen1"); if((fpstr = fdopen(fstr, "r")) == 0) panic("fdopen2"); + while (symcounter--) { fread(np, sizeof(*np), 1, fp); i = np->n_un.n_strx; *************** *** 306,311 **** --- 320,328 ---- name = nil; } + if ( tracesyms ) + pr_np(name,np); + /* * Assumptions: * not an N_STAB ==> name != nil *************** *** 328,334 **** if (curcomm) { curcomm->symvalue.common.chain = commchain; } ! n = identname(name, true); curcomm = lookup(n); if (curcomm == nil) { curcomm = insert(n); --- 345,351 ---- if (curcomm) { curcomm->symvalue.common.chain = commchain; } ! n = identname(name, false); curcomm = lookup(n); if (curcomm == nil) { curcomm = insert(n); *************** *** 374,380 **** * Source files. */ case N_SO: ! n = identname(name, true); enterSourceModule(n, (Address) np->n_value); break; --- 391,397 ---- * Source files. */ case N_SO: ! n = identname(name, false); enterSourceModule(n, (Address) np->n_value); break; *************** *** 382,388 **** * Textually included files. */ case N_SOL: ! enterfile(name, (Address) np->n_value); break; /* --- 399,406 ---- * Textually included files. */ case N_SOL: ! n = identname(name,false); ! enterfile(ident(n), (Address) np->n_value); break; /* *************** *** 420,430 **** default: printf("warning: stab entry unrecognized: "); ! if (name != nil) { ! printf("name %s,", name); ! } ! printf("ntype %2x, desc %x, value %x'\n", ! np->n_type, np->n_desc, np->n_value); break; } } else if (afterlg) { --- 438,444 ---- default: printf("warning: stab entry unrecognized: "); ! pr_np(name,np); break; } } else if (afterlg) { *************** *** 443,452 **** --- 457,473 ---- } else if (name[0] == '_') { check_local(&name[1], np); } + else if((np->n_type&N_BSS)==N_BSS) + { + } + else + printf("readsym: ignored symbol: %s\n",name); } + if (!foundstab) { warning("no source compiled with -g"); } + fclose(fp); fclose(fpstr); } *************** *** 478,495 **** private initsyms () { - curblock = nil; curlevel = 0; nesting = 0; ! program = insert(identname("", true)); program->class = PROG; program->language = primlang; ! program->symvalue.funcv.beginaddr = CODESTART; program->symvalue.funcv.inline = false; newfunc(program, codeloc(program)); ! findbeginning(program); ! enterblock(program); curmodule = program; } /* --- 499,515 ---- private initsyms () { curlevel = 0; nesting = 0; ! program = insert(identname("", false)); program->class = PROG; program->language = primlang; ! codeloc(program) = CODESTART; program->symvalue.funcv.inline = false; newfunc(program, codeloc(program)); ! curblock = program; curmodule = program; + enterblock(program); } /* *************** *** 520,526 **** *var_isextref = false; find(s, n) where ( ! s->level == program->level and ( s->class == EXTREF or s->class == VAR or s->class == PROC or s->class == FUNC ) --- 540,546 ---- *var_isextref = false; find(s, n) where ( ! /*s->level == program->level and */( s->class == EXTREF or s->class == VAR or s->class == PROC or s->class == FUNC ) *************** *** 550,556 **** r->class = FUNC; r->symvalue.funcv.src = false; r->symvalue.funcv.inline = false; ! fdata(r->name, r->symvalue.offset); } return r; } --- 570,576 ---- r->class = FUNC; r->symvalue.funcv.src = false; r->symvalue.funcv.inline = false; ! dataloc(r) = r->symvalue.offset; } return r; } *************** *** 612,625 **** char *name; Address addr; { if (s->class == VAR) { s->symvalue.offset = addr; } else { ! s->symvalue.funcv.beginaddr = addr; ! if (name[0] == '_') { newfunc(s, codeloc(s)); findbeginning(s); } } } --- 632,651 ---- char *name; Address addr; { + if (s->class == VAR) { s->symvalue.offset = addr; } else { ! if (name[0] == '_' && name[1] == '.') { ! codeloc(s) = addr; newfunc(s, codeloc(s)); findbeginning(s); } + /***** + else { /* assume dataloc + dataloc(s) = addr; + } + *****/ } } *************** *** 666,678 **** isfunc = false; if (name[0] == '_') { if (name[1] == '.') { ! n = identname(&name[2], true); isfunc = true; } else { ! n = identname(&name[1], true); } } else { ! n = identname(name, true); if (lookup(n) != nil) { sprintf(buf, "$%s", name); n = identname(buf, false); --- 692,704 ---- isfunc = false; if (name[0] == '_') { if (name[1] == '.') { ! n = identname(&name[2], false); isfunc = true; } else { ! n = identname(&name[1], false); } } else { ! n = identname(name, false); if (lookup(n) != nil) { sprintf(buf, "$%s", name); n = identname(buf, false); *************** *** 703,709 **** if (tracesyms) { printdecl(t); } ! } else if (t->class == FUNC) { if (isfunc) { updateTextSym(t, name, np->n_value); } --- 729,735 ---- if (tracesyms) { printdecl(t); } ! } else if (t->class == FUNC || t->class == PROC) { if (isfunc) { updateTextSym(t, name, np->n_value); } *************** *** 776,782 **** return; case PROC: case FUNC: ! fdata(n, np->n_value); return; default: warning("global %s ignored", ident(n)); --- 802,808 ---- return; case PROC: case FUNC: ! dataloc(t) = np->n_value; return; default: warning("global %s ignored", ident(n)); *************** *** 794,818 **** } /* - * Handle a data symbol with the same name as a known function. - * These contain the address of function data areas. - */ - - private fdata (n, addr) - Name n; - Address addr; - { - char *str, *newstr; - Symbol v; - - str = ident(n); - newstr = mymalloc(strlen(str) + 2); - sprintf(newstr, ".%s", str); - v = defvar(identname(newstr, true), program, program->level); - v->symvalue.offset = addr; - } - - /* * Check to see if a local _name is known in the current scope. * If not then enter it. */ --- 820,825 ---- *************** *** 821,846 **** String name; register struct nlist *np; { ! register Name n; ! register Symbol s, t; if (name[0] == '.') { ! n = identname(&name[1], true); } else { ! n = identname(name, true); } s = lookup(n); ! if ((np->n_type&N_TYPE) == N_TEXT) { for (t = s; t != nil; t = t->next_sym) { ! if (t->name == n && t->block == curmodule) { ! return; ! } } ! t = deffunc(n, curmodule, curmodule->level); ! t->symvalue.funcv.beginaddr = np->n_value; ! newfunc(t, codeloc(t)); ! findbeginning(t); ! } else { for (t = s; t != nil; t = t->next_sym) { if (t->name == n && t->block == curblock) { t->symvalue.offset = np->n_value; --- 828,874 ---- String name; register struct nlist *np; { ! Name n; ! Symbol s, t; ! boolean is_code_addr, defined = false; if (name[0] == '.') { ! n = identname(&name[1], false); ! is_code_addr = true; } else { ! n = identname(name, false); ! is_code_addr = false; } s = lookup(n); ! ! /* ! * On the rt we have symbols that start with "_." ! * these are the only symbols which contain the TEXT address of a ! * function, the associated stab & plain "_" symbols contain a data ! * address which also contains the text address of the function. ! */ ! ! if ((np->n_type&N_TYPE) == N_TEXT|| (np->n_type == N_DATA)){ for (t = s; t != nil; t = t->next_sym) { ! if (t->name == n && t->block == curmodule) { ! defined = true; ! break; ! } } ! if ( !defined ) ! t = deffunc(n, curmodule, curmodule->level); ! ! t->class = FUNC; ! if ( is_code_addr ){ ! codeloc(t) = np->n_value; ! newfunc(t, codeloc(t)); ! findbeginning(t); ! } ! else dataloc(t) = np->n_value; ! } ! else { ! /* update address if sym predefined in this block */ ! for (t = s; t != nil; t = t->next_sym) { if (t->name == n && t->block == curblock) { t->symvalue.offset = np->n_value; *************** *** 847,855 **** return; } } for (t = s; t != nil; t = t->next_sym) { if (t->name == n && t->block == curmodule && t->class == FUNC) { ! fdata(n, np->n_value); return; } } --- 875,886 ---- return; } } + + /* set dataloc for func predefined in this module */ + for (t = s; t != nil; t = t->next_sym) { if (t->name == n && t->block == curmodule && t->class == FUNC) { ! dataloc(t) = np->n_value; return; } } *************** *** 879,885 **** while (mname[i] != '/' and i >= 0) { --i; } ! n = identname(&mname[i+1], true); find(s, n) where s->block == program and s->class == MODULE endfind(s); if (s == nil) { s = insert(n); --- 910,916 ---- while (mname[i] != '/' and i >= 0) { --i; } ! n = identname(&mname[i+1], false); find(s, n) where s->block == program and s->class == MODULE endfind(s); if (s == nil) { s = insert(n); *************** *** 887,903 **** s->class = MODULE; s->level = program->level; s->symvalue.funcv.beginaddr = 0; ! findbeginning(s); ! if (tracesyms) { printdecl(s); - } } ! if (curblock->class != PROG) { exitblock(); - if (curblock->class != PROG) { - exitblock(); - } - } enterblock(s); curmodule = s; } --- 918,929 ---- s->class = MODULE; s->level = program->level; s->symvalue.funcv.beginaddr = 0; ! ! if (tracesyms) printdecl(s); } ! while (curblock->class != PROG) exitblock(); enterblock(s); curmodule = s; } *************** *** 967,984 **** *suffix = '\0'; } if (!(*language_op(curlang, L_HASMODULES))()) { ! if (curblock->class != PROG) { exitblock(); ! if (curblock->class != PROG) { ! exitblock(); ! } ! } ! nn = identname(mname, true); if (curmodule == nil or curmodule->name != nn) { s = insert(nn); s->class = MODULE; s->symvalue.funcv.beginaddr = 0; - findbeginning(s); } else { s = curmodule; } --- 993,1006 ---- *suffix = '\0'; } if (!(*language_op(curlang, L_HASMODULES))()) { ! while ( curblock->class != PROG ) exitblock(); ! ! nn = identname(mname, false); if (curmodule == nil or curmodule->name != nn) { s = insert(nn); s->class = MODULE; s->symvalue.funcv.beginaddr = 0; } else { s = curmodule; } *** /usr/src/ucb/dbx/eval.c Fri Dec 9 11:56:47 1988 --- eval.c Thu Oct 12 14:36:58 1989 *************** *** 1,9 **** ! /* $Header:eval.c 12.0$ */ ! /* $ACIS:eval.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/RCS/eval.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:eval.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: eval.c,v 12.1 89/10/12 17:36:56 brunner Locked $ */ ! /* $Source: /fish/dbx/RCS/eval.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: eval.c,v 12.1 89/10/12 17:36:56 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 31,36 **** --- 30,36 ---- #include <math.h> #include <ieee.h> + extern Node findvar(); #ifndef public #include "machine.h" *************** *** 144,155 **** if (s == retaddrsym) { push(long, return_addr()); } else if (isvariable(s)) { - if (s != program && !isactive(container(s))) { - error("\"%s\" is not active", symname(s)); - } addr = address(s, nil); if (isvarparam(s) && !isopenarray(s)) { ! if (s->storage == INREG || preg(s, nil) != -1) { pushregvalue(s, addr, nil, sizeof(Address)); } else { rpush(addr, sizeof(Address)); --- 144,152 ---- if (s == retaddrsym) { push(long, return_addr()); } else if (isvariable(s)) { addr = address(s, nil); if (isvarparam(s) && !isopenarray(s)) { ! if (s->storage == INREG) { pushregvalue(s, addr, nil, sizeof(Address)); } else { rpush(addr, sizeof(Address)); *************** *** 215,222 **** case O_INDIR: case O_RVAL: - addr = pop(long); s = p->nodetype; len = size(s); if (s->class != REF && (s->storage == INREG || (s->param && preg(s, nil) != -1)) --- 212,223 ---- case O_INDIR: case O_RVAL: s = p->nodetype; + + if ( s->language == primlang && s->storage != INREG ) + break; + + addr = ( sp > &stack[0] ) ? pop(long) : 0; len = size(s); if (s->class != REF && (s->storage == INREG || (s->param && preg(s, nil) != -1)) *************** *** 369,374 **** --- 370,379 ---- printnews(); break; + case O_LISTI: + listi(p); + break; + case O_LIST: list(p); break; *************** *** 422,437 **** break; case O_STEP: ! b = inst_tracing; ! inst_tracing = (Boolean) (!p->value.step.source); ! if (p->value.step.skipcalls) { ! next(); ! } else { ! stepc(); } - inst_tracing = b; - useInstLoc = (Boolean) (!p->value.step.source); - printnews(); break; case O_WHATIS: --- 427,447 ---- break; case O_STEP: ! { ! int i; ! b = inst_tracing; ! inst_tracing = (Boolean) (!p->value.step.source); ! ! for(i = p->value.step.count; i ; i--) ! { ! if (p->value.step.skipcalls) next(); ! else stepc(); ! } ! ! inst_tracing = b; ! useInstLoc = (Boolean) (!p->value.step.source); ! printnews(); } break; case O_WHATIS: *************** *** 508,513 **** --- 518,531 ---- } break; + case O_CLEAR: + clearbps(p); + break; + + case O_CLEARI: + clearbps_i(p); + break; + case O_EDIT: edit(p->value.scon); break; *************** *** 535,546 **** } break; ! case O_GRIPE: ! gripe(); break; case O_HELP: ! help(); break; case O_IGNORE: --- 553,564 ---- } break; ! case O_GOTO: ! changepc(p); break; case O_HELP: ! help(p); break; case O_IGNORE: *************** *** 560,565 **** --- 578,587 ---- } break; + case O_REGS: + registers(); + break; + case O_RUN: run(); break; *************** *** 620,625 **** --- 642,651 ---- } break; + case O_DELALL: + deleteall(); + break; + case O_ENDX: endprogram(); break; *************** *** 639,647 **** break; case O_PRINTIFCHANGED: ! printifchanged(p->value.arg[0]); break; case O_PRINTRTN: printrtn(p->value.sym); break; --- 665,677 ---- break; case O_PRINTIFCHANGED: ! printifchanged(p->value.arg[0],true); break; + case O_PRINTIIFCHANGED: + printifchanged(p->value.arg[0],false); + break; + case O_PRINTRTN: printrtn(p->value.sym); break; *************** *** 654,664 **** printlines(nil, curline, curline); } else if (p->value.arg[0]->op == O_QLINE) { if (p->value.arg[0]->value.arg[1]->value.lcon == 0) { - printf("tracei: "); printinst(pc, pc); } else { if (canReadSource()) { - printf("trace: "); printlines(nil, curline, curline); } } --- 684,692 ---- *************** *** 678,686 **** break; case O_STOPIFCHANGED: ! stopifchanged(p->value.arg[0]); break; case O_STOPX: isstopped = true; break; --- 706,718 ---- break; case O_STOPIFCHANGED: ! stopifchanged(p->value.arg[0],true); break; + case O_STOPIIFCHANGED: + stopifchanged(p->value.arg[0],false); + break; + case O_STOPX: isstopped = true; break; *************** *** 1095,1101 **** * Set up breakpoint for tracing data. */ ! private tracedata (op, exp, place, cond) Operator op; Node exp; Node place; --- 1127,1133 ---- * Set up breakpoint for tracing data. */ ! private tracedata(op, exp, place, cond) Operator op; Node exp; Node place; *************** *** 1112,1118 **** if (p == nil) { p = program; } ! action = build(O_PRINTIFCHANGED, exp); if (cond != nil) { action = build(O_IF, cond, buildcmdlist(action)); } --- 1144,1151 ---- if (p == nil) { p = program; } ! if(op == O_TRACE) action = build(O_PRINTIFCHANGED, exp); ! else action = build(O_PRINTIIFCHANGED, exp); if (cond != nil) { action = build(O_IF, cond, buildcmdlist(action)); } *************** *** 1128,1134 **** * Setting and unsetting of stops. */ ! public stop (p) Node p; { Node exp, place, cond, t; --- 1161,1167 ---- * Setting and unsetting of stops. */ ! public stop(p) Node p; { Node exp, place, cond, t; *************** *** 1183,1188 **** --- 1216,1223 ---- event = build(O_EQ, build(O_SYM, linesym), place); } else { event = build(O_EQ, build(O_SYM, pcsym), place); + if(place->op == O_LCON && (int) place->value.lcon >= 0x10000000) + warning("instruction breakpoint set at data address"); } e = addevent(event, buildcmdlist(action)); if (isstdin()) { *************** *** 1195,1201 **** * the variable list. */ ! private stopvar (op, exp, place, cond) Operator op; Node exp; Node place; --- 1230,1236 ---- * the variable list. */ ! private stopvar(op, exp, place, cond) Operator op; Node exp; Node place; *************** *** 1220,1226 **** } else { p = place->value.sym; } ! action = build(O_STOPIFCHANGED, exp); if (cond != nil) { action = build(O_IF, cond, buildcmdlist(action)); } --- 1255,1262 ---- } else { p = place->value.sym; } ! if(op == O_STOP) action = build(O_STOPIFCHANGED, exp); ! else action = build(O_STOPIIFCHANGED, exp); if (cond != nil) { action = build(O_IF, cond, buildcmdlist(action)); } *************** *** 1498,1528 **** # endif } /* ! * Give the user some help. */ ! public help () { ! puts("run - begin execution of the program"); ! puts("print <exp> - print the value of the expression"); ! puts("where - print currently active procedures"); ! puts("stop at <line> - suspend execution at the line"); ! puts("stop in <proc> - suspend execution when <proc> is called"); ! puts("cont - continue execution"); ! puts("step - single step one line"); ! puts("next - step to next line (skip over calls)"); ! puts("trace <line#> - trace execution of the line"); ! puts("trace <proc> - trace calls to the procedure"); ! puts("trace <var> - trace changes to the variable"); ! puts("trace <exp> at <line#> - print <exp> when <line> is reached"); ! puts("status - print trace/stop's in effect"); ! puts("delete <number> - remove trace or stop of given number"); ! puts("call <proc> - call a procedure in program"); ! puts("whatis <name> - print the declaration of the name"); ! puts("list <line>, <line> - list source lines"); ! puts("gripe - send mail to the person in charge of dbx"); ! puts("quit - exit dbx"); } /* --- 1534,1574 ---- # endif } + /* ! * Set the program counter to be at a particular place in the code. */ ! public changepc (p) ! Node p; { ! Address goaddr; ! String fn; ! long ln; ! Symbol oldfunc; ! ! /* if (noexec) ! error("program is not executable");*/ ! oldfunc = curfunc; ! if (p->value.arg[0]->op == O_QLINE) { ! fn = p->value.arg[0]->value.arg[0]->value.scon; ! ln = p->value.arg[0]->value.arg[1]->value.lcon; ! goaddr = objaddr(ln, fn); ! } else { ! eval(p->value.arg[0]); ! goaddr = pop(long); ! } ! if (goaddr != NOADDR) { ! setcurfunc(whatblock(goaddr)); ! if ((curfunc != oldfunc) && (!(varIsSet("$unsafegoto")))) { ! curfunc = oldfunc; ! error("Goto address is not within current function. (set $unsafegoto to override)"); ! } else { ! setreg(PROGCTR, pc = goaddr); ! getsrcpos(); ! printstatus(); ! } ! } } /* *************** *** 1659,1662 **** --- 1705,1865 ---- " mapped to %.17g\n", xw[0],xw[1],xw[2], dsign?"-":"", g1, n, *(double *)t); return ; + } + /* + * Execute a listi command. + */ + + private listi (p) + Node p; + { + static Address old_pc; + Address addr1, addr2; + long t1, t2; + Symbol f; + Node wnode; + int wsize; + + wnode = findvar(identname("$listwindow",true)); + if ( !wnode ) + wsize = inst_windowsize; + else { + eval(wnode); + wsize = pop(integer); + } + + if (p->value.arg[0]->op == O_SYM) + { + f = p->value.arg[0]->value.sym; + addr1 = firstline(f); + if (addr1 == NOADDR) { + error("no source lines for \"%s\"", symname(f)); + } + printninst(wsize,addr1); + } + else + { + eval(p->value.arg[0]); + t1 = pop(long); + addr1 = (Address) t1; + eval(p->value.arg[1]); + t2 = pop(long); + addr2 = (Address) t2; + if ((t1 < 0) || (t2 < 0)) + { + beginerrmsg(); + fprintf(stderr, "Addresses must be positive\n"); + return; + } + if (addr2 == 0) + { + if (addr1 == 0) /* No line numbers specified */ + { + if (prtaddr && (old_pc == pc)) + printninst(wsize,prtaddr); + else + printninst(wsize,pc); + } + else /* Only 1st line specified */ + { + printninst(wsize,addr1); + } + } /* end if no ending line specified */ + else + { + if (addr1 == 0) /* print assembly code given source line # */ + { + addr1 = objaddr(addr2,cursource); + if (addr1 == NOADDR) { + error("No assembly code for that source line number"); + } + printninst(wsize,addr1); + } + else if (addr2 < addr1) + { + beginerrmsg(); + fprintf(stderr, "second number must be greater than first\n"); + return; + } + else /* Both lines specified */ + { + if ((addr2 - addr1) < wsize) + printninst(wsize,addr1); + else + printinst(addr1,addr2, false); + } + } + } + old_pc = pc; + } + + /* + * Execute a registers command to print out the registers in readable form. + */ + #define NGREG 16 + /* Register mnemonics */ + char *regnames[] = { + "r0", /* register 00 */ + "r1", /* register 01 */ + "r2", /* register 02 */ + "r3", /* register 03 */ + "r4", /* register 04 */ + "r5", /* register 05 */ + "r6", /* register 06 */ + "r7", /* register 07 */ + "r8", /* register 08 */ + "r9", /* register 09 */ + "r10", /* register 0A */ + "r11", /* register 0B */ + "r12", /* register 0C */ + "sp", /* register 0D */ + "r14", /* register 0E */ + "r15", /* register 0F */ + }; + + registers () { + int p, i; + + for (p = 0; p < (NREG-1) / 4; ++p) + { + for (i = 0; i < NREG-1; i += 4) + { + printf("%5s: ", regnames[p + i]); + printf("%08x ", reg(p + i)); + } + printf("\n"); + } + printf("%5s: ","pc"); + printf("%08X ", reg(PROGCTR)); + printf("\n"); + + printf("\n"); + if (varIsSet("$flregs")) + { + prflregs(); + printf("\n"); + } + + } + + /* + * Print out the values of the floating point registers. + */ + prflregs() + { + int i; + union { + double d; + float f[2]; + long l[2]; + } u; + + + printf("\n"); + for (i = 0; i < NFLREG; i ++) + { + printf(" dr%d: %08.8x ", i,reg(i+NREG)); + prtreal(true, (double) reg(i+NREG)); + printf("\n"); + } } *** /usr/src/ucb/dbx/commands.y Fri Dec 9 11:56:39 1988 --- commands.y Thu Oct 12 14:37:33 1989 *************** *** 1,6 **** ! /* $Header:commands.y 12.0$ */ ! /* $ACIS:commands.y 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/RCS/commands.y,v $ */ %{ /* Copyright (c) 1982 Regents of the University of California */ --- 1,5 ---- ! /* $Header: commands.y,v 12.1 89/10/12 17:37:32 brunner Locked $ */ ! /* $Source: /fish/dbx/RCS/commands.y,v $ */ %{ /* Copyright (c) 1982 Regents of the University of California */ *************** *** 21,33 **** #include "lists.h" private String curformat = "X"; %} %term ! ALIAS AND ASSIGN AT CALL CATCH CONT DEBUG DELETE DIV DOWN DUMP ! EDIT FILE FUNC GRIPE HELP IF IGNORE IN LIST MOD NEXT NEXTI NIL NOT OR ! PRINT PSYM QUIT RERUN RETURN RUN SET SH SKIP SOURCE STATUS STEP STEPI STOP STOPI TRACE TRACEI UNALIAS UNSET UP USE WHATIS WHEN WHERE WHEREIS WHICH --- 20,34 ---- #include "lists.h" private String curformat = "X"; + boolean instlevel = false; %} %term ! ALIAS ALL AND ASSIGN AT CALL CATCH CLEAR CLEARI CONT DEBUG DELETE DIV DOWN DUMP ! EDIT FILE FUNC GOTO GOTOI HELP IF IGNORE IN LIST LISTI MOD NEXT NEXTI NIL NOT OR ! PRINT PSYM QUIT REGISTERS RERUN RETURN RUN SET SH SKIP SOURCE ! STATUS STEP STEPI STOP STOPI TRACE TRACEI UNALIAS UNSET UP USE WHATIS WHEN WHERE WHEREIS WHICH *************** *** 64,75 **** %type <y_char> CHAR %type <y_real> REAL %type <y_string> STRING redirectout filename opt_filename mode ! %type <y_name> ALIAS AND ASSIGN AT CALL CATCH CONT %type <y_name> DEBUG DELETE DIV DOWN DUMP ! %type <y_name> EDIT FILE FUNC GRIPE HELP IF IGNORE IN LIST MOD %type <y_name> NEXT NEXTI NIL NOT OR ! %type <y_name> PRINT PSYM QUIT RERUN RETURN RUN SET SH SKIP SOURCE STATUS ! %type <y_name> STEP STEPI STOP STOPI TRACE TRACEI %type <y_name> UNALIAS UNSET UP USE WHATIS WHEN WHERE WHEREIS WHICH %type <y_name> name NAME keyword %type <y_node> opt_qual_symbol symbol --- 65,76 ---- %type <y_char> CHAR %type <y_real> REAL %type <y_string> STRING redirectout filename opt_filename mode ! %type <y_name> ALIAS ALL AND ASSIGN AT CALL CATCH CLEAR CLEARI CONT %type <y_name> DEBUG DELETE DIV DOWN DUMP ! %type <y_name> EDIT FILE FUNC GOTO GOTOI HELP IF IGNORE IN LIST LISTI MOD %type <y_name> NEXT NEXTI NIL NOT OR ! %type <y_name> PRINT PSYM QUIT REGISTERS RERUN RETURN RUN SET SH SKIP ! %type <y_name> SOURCE STATUS STEP STEPI STOP STOPI TRACE TRACEI %type <y_name> UNALIAS UNSET UP USE WHATIS WHEN WHERE WHEREIS WHICH %type <y_name> name NAME keyword %type <y_node> opt_qual_symbol symbol *************** *** 76,83 **** %type <y_node> command rcommand cmd step what where examine %type <y_node> event opt_exp_list opt_cond %type <y_node> exp_list exp term boolean_exp constant address ! %type <y_node> integer_list alias_command list_command line_number ! %type <y_cmdlist> actions %type <y_list> sourcepath name_list %% --- 77,85 ---- %type <y_node> command rcommand cmd step what where examine %type <y_node> event opt_exp_list opt_cond %type <y_node> exp_list exp term boolean_exp constant address ! %type <y_node> integer_list alias_command listi_command list_command ! %type <y_node> line_number ! %type <y_cmdlist> actions actionlist %type <y_list> sourcepath name_list %% *************** *** 155,160 **** --- 157,177 ---- $$ = build(O_CATCH, 0); } | + CLEAR line_number + { + $$ = build(O_CLEAR, build(O_SCON, strdup(cursource)), $2); + } + | + CLEARI address + { + $$ = build(O_CLEARI, $2); + } + | + CLEAR STRING ':' line_number + { + $$ = build(O_CLEAR, build(O_SCON, $2), $4); + } + | CONT { $$ = build(O_CONT, (long) DEFSIG); *************** *** 170,175 **** --- 187,197 ---- $$ = build(O_DELETE, $2); } | + DELETE ALL + { + $$ = build(O_DELALL); + } + | DOWN { $$ = build(O_DOWN, build(O_LCON, (long) 1)); *************** *** 200,213 **** $$ = build(O_FUNC, $2); } | ! GRIPE { ! $$ = build(O_GRIPE); } | HELP { ! $$ = build(O_HELP); } | IGNORE signal --- 222,253 ---- $$ = build(O_FUNC, $2); } | ! GOTO line_number { ! if (!instlevel) ! $$ = build(O_GOTO, build(O_QLINE, build(O_SCON, strdup(cursource)), $2)); ! else ! $$ = build(O_GOTO, unrval($2)); } | + GOTO STRING ':' line_number + { + $$ = build(O_GOTO, build(O_QLINE, build(O_SCON, $2), $4)); + } + | + GOTOI address + { + $$ = build(O_GOTO, $2); + } + | + HELP name + { + $$ = build(O_HELP,build(O_NAME,$2)); + } + | HELP { ! $$ = build(O_HELP, 0); } | IGNORE signal *************** *** 220,225 **** --- 260,270 ---- $$ = build(O_IGNORE, 0); } | + listi_command + { + $$ = $1; + } + | list_command { $$ = $1; *************** *** 291,296 **** --- 336,346 ---- $$ = build($1, nil, $2, $3); } | + stop what where opt_cond + { + $$ = build($1, $2, $3, $4); + } + | stop what opt_cond { $$ = build($1, $2, nil, $3); *************** *** 364,372 **** $$ = build(O_WHATIS, $2); } | ! WHEN event '{' actions '}' { ! $$ = build(O_ADDEVENT, $2, $4); } | WHEREIS name --- 414,422 ---- $$ = build(O_WHATIS, $2); } | ! WHEN event actions { ! $$ = build(O_ADDEVENT, $2, $3); } | WHEREIS name *************** *** 456,478 **** step: STEP { ! $$ = build(O_STEP, true, false); } | STEPI { ! $$ = build(O_STEP, false, false); } | NEXT { ! $$ = build(O_STEP, true, true); } | NEXTI { ! $$ = build(O_STEP, false, true); } ; shellmode: /* empty */ --- 506,548 ---- step: STEP { ! $$ = build(O_STEP, true, false, 1); } | STEPI { ! $$ = build(O_STEP, false, false, 1); } | NEXT { ! $$ = build(O_STEP, true, true, 1); } | NEXTI { ! $$ = build(O_STEP, false, true, 1); } + | + STEP INT + { + $$ = build(O_STEP, true, false, $2); + } + | + STEPI INT + { + $$ = build(O_STEP, false, false, $2); + } + | + NEXT INT + { + $$ = build(O_STEP, true, true, $2); + } + | + NEXTI INT + { + $$ = build(O_STEP, false, true, $2); + } ; shellmode: /* empty */ *************** *** 498,515 **** exp ; actions: ! actions cmd ';' { ! $$ = $1; ! cmdlist_append($2, $$); } | ! cmd ';' { ! $$ = list_alloc(); ! cmdlist_append($1, $$); } ; cmd: command | --- 568,594 ---- exp ; actions: ! '{' actionlist '}' { ! $$ = $2; } | ! '{' actionlist ';' '}' { ! $$ = $2; } ; + actionlist: + cmd + { + $$ = buildcmdlist($1); + } + | + actionlist ';' cmd + { + cmdlist_append($3, $$); + } + ; cmd: command | *************** *** 565,570 **** --- 644,654 ---- $$ = build(O_DUMP, build(O_SYM, curfunc)); } | + REGISTERS + { + $$ = build(O_REGS, nil); + } + | STATUS { $$ = build(O_STATUS); *************** *** 615,625 **** --- 699,711 ---- trace: TRACE { + instlevel = false; $$ = O_TRACE; } | TRACEI { + instlevel = true; $$ = O_TRACEI; } ; *************** *** 626,636 **** --- 712,724 ---- stop: STOP { + instlevel = false; $$ = O_STOP; } | STOPI { + instlevel = true; $$ = O_STOPI; } ; *************** *** 651,660 **** $$ = unrval($2); } | ! AT line_number { $$ = build(O_QLINE, build(O_SCON, strdup(cursource)), $2); } | AT STRING ':' line_number { --- 739,756 ---- $$ = unrval($2); } | ! /* AT line_number { $$ = build(O_QLINE, build(O_SCON, strdup(cursource)), $2); } + */ + AT address + { + if (!instlevel) + $$ = build(O_QLINE, build(O_SCON, strdup(cursource)), $2); + else + $$ = unrval($2); + } | AT STRING ':' line_number { *************** *** 689,694 **** --- 785,816 ---- $$ = nil; } ; + listi_command: + LISTI + { + $$ = build(O_LISTI, build(O_LCON, (long) 0), build(O_LCON, (long) 0)); + } + | + LISTI address + { + $$ = build(O_LISTI, $2, build(O_LCON, (long) 0)); + } + | + LISTI address ',' address + { + $$ = build(O_LISTI, $2, $4); + } + | + LISTI opt_qual_symbol + { + $$ = build(O_LISTI, $2); + } + | + LISTI AT line_number + { + $$ = build(O_LISTI, build(O_LCON, (long) 0), $3); + } + ; list_command: LIST { *************** *** 764,770 **** $$ = build(O_LCON, (long) prtaddr); } | ! '&' term { $$ = amper($2); } --- 886,893 ---- $$ = build(O_LCON, (long) prtaddr); } | ! /* '&' term*/ ! '&' exp %prec NOT { $$ = amper($2); } *************** *** 1080,1089 **** $$ = $1; } keyword: ! ALIAS | AND | ASSIGN | AT | CALL | CATCH | CONT | DEBUG | DELETE | DIV | ! DOWN | DUMP | EDIT | FILE | FUNC | GRIPE | HELP | IGNORE | IN | LIST | ! MOD | NEXT | NEXTI | NIL | NOT | OR | PRINT | PSYM | QUIT | ! RERUN | RETURN | RUN | SET | SH | SKIP | SOURCE | STATUS | STEP | STEPI | STOP | STOPI | TRACE | TRACEI | UNALIAS | UNSET | UP | USE | WHATIS | WHEN | WHERE | WHEREIS | WHICH ; --- 1203,1213 ---- $$ = $1; } keyword: ! ALIAS | ALL | AND | ASSIGN | AT | CALL | CATCH | CLEAR | CLEARI | CONT | DEBUG | DELETE | DIV | ! DOWN | DUMP | EDIT | FILE | FUNC | GOTO | GOTOI | HELP | IGNORE | IN | LIST | ! LISTI | MOD | NEXT | NEXTI | NIL | NOT | OR | PRINT | PSYM | QUIT | ! REGISTERS | RERUN | RETURN | RUN | SET | SH | SKIP | SOURCE | ! STATUS | STEP | STEPI | STOP | STOPI | TRACE | TRACEI | UNALIAS | UNSET | UP | USE | WHATIS | WHEN | WHERE | WHEREIS | WHICH ; *** /usr/src/ucb/dbx/c.c Fri Dec 9 11:56:33 1988 --- c.c Thu Oct 12 14:36:53 1989 *************** *** 1,9 **** ! /* $Header:c.c 12.0$ */ ! /* $ACIS:c.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/RCS/c.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:c.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: c.c,v 12.1 89/10/12 17:36:52 brunner Locked $ */ ! /* $Source: /fish/dbx/RCS/c.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: c.c,v 12.1 89/10/12 17:36:52 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 35,40 **** --- 34,40 ---- #define isrange(t, name) (t->class == RANGE && istypename(t->type, name)) + extern Boolean expandunions; private Language langC; private Language langCplpl; *************** *** 450,458 **** public c_printval (s) Symbol s; { ! register Symbol t; ! register Address a; ! integer i, len; switch (s->class) { case CONST: --- 450,458 ---- public c_printval (s) Symbol s; { ! Symbol t; ! Address a; ! int i, len; switch (s->class) { case CONST: *************** *** 464,469 **** --- 464,476 ---- c_printval(s->type); break; + case VARNT: + if ( expandunions ) + printunion(s); + else + goto DEFAULT; + break; + case FIELD: if (isbitfield(s)) { i = extractField(s); *************** *** 560,565 **** --- 567,573 ---- break; default: + DEFAULT: if (ord(s->class) > ord(TYPEREF)) { panic("printval: bad class %d", ord(s->class)); } *************** *** 584,590 **** savesp = sp; printf("("); f = s->chain; ! for (;;) { off = f->symvalue.field.offset; len = f->symvalue.field.length; n = (off + len + BITSPERBYTE - 1) div BITSPERBYTE; --- 592,598 ---- savesp = sp; printf("("); f = s->chain; ! for (;f;) { off = f->symvalue.field.offset; len = f->symvalue.field.length; n = (off + len + BITSPERBYTE - 1) div BITSPERBYTE; *************** *** 597,602 **** --- 605,645 ---- printf(", "); } printf(")"); + } + + printunion(s) + Symbol s; + { + Symbol t; + long i; + Stack *sp_top, *sp_base; + + sp_top = sp; + sp_base = sp - size(s); + + printf( "union: ("); + for ( s = s->chain; s; s = s->chain ){ + printf( "%s = ", symname(s)); + + sp = sp_base + size(s); + if ( isbitfield(s) ){ + i = extractField(s); + t = rtype(s->type); + if ( t->class == SCAL ) + printEnum(i, t); + else + printRangeVal(i, t); + } + else + c_printval(s->type); + sp = sp_top; + + if ( s->chain ){ + printf( ", "); + } + } + sp = sp_base; + printf( ")"); } /* *** /usr/src/ucb/dbx/tree.c Fri Dec 9 11:57:50 1988 --- tree.c Thu Oct 12 14:37:31 1989 *************** *** 1,9 **** ! /* $Header:tree.c 12.0$ */ ! /* $ACIS:tree.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/RCS/tree.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:tree.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: tree.c,v 12.1 89/10/12 17:37:30 brunner Locked $ */ ! /* $Source: /fish/dbx/RCS/tree.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: tree.c,v 12.1 89/10/12 17:37:30 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 39,44 **** --- 38,44 ---- #include "events.h" #define MAXNARGS 5 + extern boolean hexaddr; struct Node { Operator op; *************** *** 62,67 **** --- 62,68 ---- struct { Boolean source; Boolean skipcalls; + int count; } step; struct { String mode; *************** *** 178,183 **** --- 179,185 ---- case O_STEP: p->value.step.source = va_arg(ap, Boolean); p->value.step.skipcalls = va_arg(ap, Boolean); + p->value.step.count = va_arg(ap, int); break; case O_EXAMINE: *************** *** 281,287 **** case O_SYM: s = p->value.sym; if (isblock(s)) { ! r = build(O_LCON, codeloc(s)); } else { notregsym(s); r = build(O_LCON, address(s, nil)); --- 283,291 ---- case O_SYM: s = p->value.sym; if (isblock(s)) { ! if ( s->class == PROC || s->class == FUNC && !isinline(s) ) ! r = build(O_LCON, dataloc(s)); ! else r = build(O_LCON, codeloc(s)); } else { notregsym(s); r = build(O_LCON, address(s, nil)); *************** *** 348,355 **** --- 352,361 ---- switch (cmd->op) { case O_PRINTIFCHANGED: + case O_PRINTIIFCHANGED: case O_PRINTSRCPOS: case O_STOPIFCHANGED: + case O_STOPIIFCHANGED: case O_TRACEON: break; *************** *** 470,476 **** prtree(f, ifcmd->value.event.cond); done = true; } ! } else if (ifcmd->op == O_STOPIFCHANGED) { fprintf(f, "stop"); fprintI(f, cmd->value.trace.inst); fprintf(f, " "); --- 476,482 ---- prtree(f, ifcmd->value.event.cond); done = true; } ! } else if (ifcmd->op == O_STOPIFCHANGED || ifcmd->op == O_STOPIIFCHANGED){ fprintf(f, "stop"); fprintI(f, cmd->value.trace.inst); fprintf(f, " "); *************** *** 521,527 **** break; case O_LCON: ! fprintf(f, "%d", p->value.lcon); break; case O_CCON: --- 527,538 ---- break; case O_LCON: ! if (hexaddr) { ! fprintf(f, "0x"); ! if( (int) p->value.lcon < 0x10000000 ) addrprint(f,p->value.lcon,false); ! else fprintf(f,"%x" ,p->value.lcon); ! } else ! fprintf(f, "%d", p->value.lcon); break; case O_CCON: Eric Brunner, IBM AWD Palo Alto inet: brunner@monet.berkeley.edu or brunner%ibmsupt@uunet.uu.net uucp: uunet!ibmsupt!brunner (415) 855-4486