brunner@bullhead.uucp (10/21/89)
Subject: Fix for dbx (part 2) 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/ibmrt 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/ibmrt/coredump.c Fri Dec 9 11:56:20 1988 --- coredump.c Thu Oct 12 14:27:38 1989 *************** *** 1,9 **** ! /* $Header:coredump.c 12.0$ */ ! /* $ACIS:coredump.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/ibmrt/RCS/coredump.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:coredump.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: coredump.c,v 12.1 89/10/12 17:27:35 brunner Locked $ */ ! /* $Source: /fish/dbx/ibmrt/RCS/coredump.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: coredump.c,v 12.1 89/10/12 17:27:35 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 26,32 **** #include <machine/reg.h> #include <machine/vmparam.h> #include <a.out.h> ! #ifndef public #include "machine.h" --- 25,31 ---- #include <machine/reg.h> #include <machine/vmparam.h> #include <a.out.h> ! #include <sys/stat.h> #ifndef public #include "machine.h" *************** *** 124,134 **** register struct user *up; char uarea[ctob(UPAGES)]; objfile = fopen(objname, "r"); if (objfile == nil) { fatal("can't read \"%s\"", objname); } ! get(objfile, hdr); if (vaddrs) { datamap.begin = 0; datamap.end = 0xffffffff; --- 123,152 ---- register struct user *up; char uarea[ctob(UPAGES)]; + struct stat c_stat, o_stat; + + /* stat core & object, if older core, error */ + + stat(objname,&o_stat); + stat(corefile,&c_stat); + if ( o_stat.st_mtime > c_stat.st_mtime ){ + badcore = true; + coredump_close(); + return; + } + + objfile = fopen(objname, "r"); if (objfile == nil) { fatal("can't read \"%s\"", objname); } ! ! if ( !get(objfile, hdr) ){ ! badcore = true; ! coredump_close(); ! return; ! } ! if (vaddrs) { datamap.begin = 0; datamap.end = 0xffffffff; *************** *** 137,142 **** --- 155,166 ---- } else { fread(uarea, ctob(UPAGES), 1, corefile); up = (struct user *) (&uarea[(int)uoffset]); + if(strncmp(up->u_comm,objname,strlen(objname))){ + badcore = true; + coredump_close(); + return; + } + /* u_exdata is not part of 4.3 uarea if (up->u_exdata.ux_tsize != hdr.a_text || up->u_exdata.ux_dsize != hdr.a_data || *************** *** 153,166 **** stkmap.seekaddr = datamap.seekaddr + ctob(up->u_dsize); switch (hdr.a_magic) { case OMAGIC: ! datamap.begin = CODESTART; datamap.end = CODESTART + ctob(up->u_tsize) + ctob(up->u_dsize); break; case NMAGIC: case ZMAGIC: ! datamap.begin = (Address) ! ptob(btop(ctob(up->u_tsize) - 1) + 1) + CODESTART; datamap.end = datamap.begin + ctob(up->u_dsize); break; --- 177,191 ---- stkmap.seekaddr = datamap.seekaddr + ctob(up->u_dsize); switch (hdr.a_magic) { case OMAGIC: ! datamap.begin = CODESTART ; /* this may be wrong too??? */ datamap.end = CODESTART + ctob(up->u_tsize) + ctob(up->u_dsize); break; case NMAGIC: case ZMAGIC: ! datamap.begin = (Address) 0x10000000; ! /* ptob(btop(ctob(up->u_tsize) - 1) + 1) + CODESTART;*/ ! /* the data segment on the RT starts at 0x10000000 */ datamap.end = datamap.begin + ctob(up->u_dsize); break; *************** *** 172,178 **** public coredump_close () { ! fclose(objfile); } public coredump_readtext (buff, addr, nbytes) --- 197,205 ---- public coredump_close () { ! coredump = false; ! if ( corefile ) fclose(corefile); ! if ( objfile ) fclose(objfile); } public coredump_readtext (buff, addr, nbytes) *************** *** 331,336 **** --- 358,364 ---- integer nbytes; { integer fileaddr; + if (a < stkmap.begin) { fileaddr = datamap.seekaddr + a - datamap.begin; *** /usr/src/ucb/dbx/ibmrt/decode.c Fri Dec 9 11:56:22 1988 --- decode.c Thu Oct 12 14:27:42 1989 *************** *** 1,9 **** ! /* $Header:decode.c 12.0$ */ ! /* $ACIS:decode.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/ibmrt/RCS/decode.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:decode.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: decode.c,v 12.1 89/10/12 17:27:38 brunner Locked $ */ ! /* $Source: /fish/dbx/ibmrt/RCS/decode.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: decode.c,v 12.1 89/10/12 17:27:38 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 106,112 **** info = ltab[ ifmt = tp->fmt]; newaddr = addr + info; /* add length of instruction to address */ ! printf("%08x ",addr); cp = tp->opc; bp = buf+1; while( *buf++ = *cp++); --- 105,114 ---- info = ltab[ ifmt = tp->fmt]; newaddr = addr + info; /* add length of instruction to address */ ! /* Print the instruction address */ ! addrprint(stdout, addr, true); ! ! /* printf("%08x ",addr);*/ cp = tp->opc; bp = buf+1; while( *buf++ = *cp++); *************** *** 385,390 **** --- 387,401 ---- return addr; } + private boolean skipfunc (f) + Symbol f; + { + boolean b; + + b = (boolean) (!inst_tracing && nlhdr.nlines && f && nosource(f)); + return b; + } + public Address nextaddr (startaddr, isnext) Address startaddr; Boolean isnext; *************** *** 394,399 **** --- 405,411 ---- YOpCode inst; int info; int opcode, extend; + Symbol s; addr = usignal(process); if (addr != 0 && addr != 1) { *************** *** 422,427 **** --- 434,448 ---- } } else { addr = dojump(startaddr, info, true); + s = whatblock(addr); + + if (skipfunc(s)) + { + /* get the return address and continue to it */ + addr = reg(15); + contto(addr); + bpact(); + } } break; case 0xe: /* extended branch - calls? */ *************** *** 435,440 **** --- 456,470 ---- } } else { addr = dojump(startaddr, info, true); + s = whatblock(addr); + + if (skipfunc(s)) + { + /* get the return address and continue to it */ + addr = reg(15); + contto(addr); + bpact(); + } } break; /* *************** *** 454,491 **** #define CALLSIZE 4 /* size of call instruction */ ! public beginproc (p, argc) ! Symbol p; ! int argc; { ! Word dest; ! Word save, callinst; ! Address addr; ! Name n; ! Symbol data; ! char buf[100]; ! sprintf(buf, ".%s", symname(p)); ! n = identname(buf, false); ! data = lookup(n); ! if (data == nil || data->class != VAR) { ! error("no data area for %s\n", symname(p)); ! } ! addr = 4; ! iread(&save, addr, CALLSIZE); ! pc = 6; ! dest = codeloc(p); ! callinst = 0xdb00ecff; ! iwrite(&callinst, addr, CALLSIZE); ! setreg(15, dest); ! setreg(PROGCTR, pc); ! setreg(0, data->symvalue.offset); ! pstep(process, DEFSIG); ! iwrite(&save, addr, CALLSIZE); ! pc = reg(PROGCTR); ! if (not isbperr()) { ! printstatus(); ! } } /* --- 484,506 ---- #define CALLSIZE 4 /* size of call instruction */ ! public beginproc (p) ! Symbol p; { ! if ( !dataloc(p) ) ! error("no data area for %s\n", symname(p)); ! ! /* alter PC, set r0 to dataloc, set r15 to current PC for return addr */ ! pc = reg(PROGCTR); ! setreg(PROGCTR,codeloc(p)); ! setreg(0,dataloc(p)); ! setreg(15,pc); ! pc = codeloc(p); ! ! if ( !isbperr() ) { ! printstatus(); ! } } /* *************** *** 539,541 **** --- 554,597 ---- } sp += n; } + + /* + * Print out the address of an instruction or a destination. Nicely. + */ + + public addrprint(f, addr, pad) + File f; + Address addr; + Boolean pad; + { + static Address funcaddr = 0; + static Symbol lastfunc = nil; + static char *funcname = nil; + Symbol newfunc; + int offset, l; + + if((newfunc = whatblock(addr)) && symname(newfunc)) { + /* Find the containing function */ + fprintf(f, "%08x ",addr); + /* newfunc = whatblock(addr);*/ + if (newfunc != lastfunc) { + funcaddr = codeloc(newfunc); + funcname = symname(newfunc); + lastfunc = newfunc; + } + offset = addr - funcaddr; + + if (offset) + l = fprintf(f,"(%s+0x%x) ",funcname, offset); + else + l = fprintf(f,"(%s) ",funcname); + if ( pad ) + while ( l++ < 16 ) + fputc(' ',f); + } + else { + fprintf(f,"%08x ",addr); + } + } + + *** /usr/src/ucb/dbx/ibmrt/frame.c Fri Dec 9 11:56:25 1988 --- frame.c Thu Oct 12 14:27:47 1989 *************** *** 1,9 **** ! /* $Header:frame.c 12.0$ */ ! /* $ACIS:frame.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/ibmrt/RCS/frame.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:frame.c 12.0$"; #endif --- 1,8 ---- ! /* $Header: frame.c,v 12.1 89/10/12 17:27:43 brunner Locked $ */ ! /* $Source: /fish/dbx/ibmrt/RCS/frame.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: frame.c,v 12.1 89/10/12 17:27:43 brunner Locked $"; #endif *************** *** 173,178 **** --- 172,179 ---- register Address a; char buf[4]; + addr = tracetable_addr(addr); + for (a = addr; ; a++) { if (!ValidText(a)) { break; *************** *** 330,335 **** --- 331,337 ---- frp->reg[i] = reg(i); } } + else { error("getcurframe: findframe failed for addr 0x%x\n",a); } } /* *************** *** 355,363 **** return nil; } if (frp->prolog) { ! callpc = frp->reg[15]; } else { dread(&callpc, frp->ap - LINKSIZE - 4, sizeof(callpc)); } if (inSignalHandler(callpc)) { sc = (struct sigcontext *) (frp->reg[1] + 3*sizeof(Word)); --- 357,366 ---- return nil; } if (frp->prolog) { ! callpc = frp->reg[15]-4; } else { dread(&callpc, frp->ap - LINKSIZE - 4, sizeof(callpc)); + callpc -= 4; } if (inSignalHandler(callpc)) { sc = (struct sigcontext *) (frp->reg[1] + 3*sizeof(Word)); *************** *** 696,757 **** * Push the value associated with the current function. */ ! public pushretval (len, isindirect) ! integer len; ! boolean isindirect; { ! Word r0; ! r0 = reg(2); ! if (isindirect) { ! rpush((Address) r0, len); ! } else { ! switch (len) { ! case sizeof(char): ! push(char, r0); ! break; ! case sizeof(short): ! push(short, r0); ! break; ! default: ! if (len == sizeof(Word)) { ! push(Word, r0); ! } else if (len == 2*sizeof(Word)) { ! push(Word, r0); ! push(Word, reg(3)); ! } else { ! error("[internal error: bad size %d in pushretval]", len); ! } ! break; ! } } ! } ! /* ! * Flush the debuggee's standard output. ! * ! * This is VERY dependent on the use of stdio. ! */ ! public flushoutput () ! { ! Symbol p, iob; ! ! p = lookup(identname("fflush", true)); ! while (p != nil and not isblock(p)) { ! p = p->next_sym; ! } ! if (p != nil) { ! iob = lookup(identname("_iob", true)); ! if (iob != nil) { ! pushenv(); ! pc = codeloc(p) - FUNCOFFSET; ! setreg(2, address(iob, nil) + sizeof(*stdout)); ! beginproc(p, 1); ! stepto(return_addr()); ! popenv(); } } } --- 699,763 ---- * Push the value associated with the current function. */ ! #define isdouble(t) ( t->class == RANGE && \ ! (t->symvalue.rangev.upper == 0 && t->symvalue.rangev.lower == 8) ) ! ! #define isfloat(t) ( t->class == RANGE && \ ! (t->symvalue.rangev.upper == 0 && t->symvalue.rangev.lower == 4) ) ! ! public pushretval (s) ! Symbol s; { ! int len; ! boolean indirect; ! Symbol t; ! Word reg2; ! union { ! double d; ! float f; ! long l[2]; ! } u; ! len = size(s); ! t = rtype(s); ! indirect = (t->class == RECORD || t->class == VARNT ); ! reg2 = reg(2); /* funky RT function return in r2 */ ! if ( indirect ){ ! rpush((Address) reg2, len); ! } ! else if ( isfloat(t) ){ /* in case they use float regs someday.. */ ! u.l[0] = reg2; ! push(float, u.f); } ! else if ( isdouble(t) ){ ! u.l[0] = reg2; ! u.l[1] = reg(3); ! push(double, u.d ) ! } ! else { ! switch ( len ){ ! case sizeof(char): ! push(char, reg2); ! break; ! case sizeof(short): ! push(short, reg2); ! break; ! default: ! if ( len == sizeof(Word) ){ ! push(Word, reg2); ! } ! else if ( len == 2*sizeof(Word) ){ ! push(Word, reg2); ! push(Word, reg(3)); ! } ! else { ! error("[internal error: bad size %d in pushretval]", len); ! } ! break; } } } *** /usr/src/ucb/dbx/ibmrt/procinfo.c Fri Dec 9 11:56:28 1988 --- procinfo.c Thu Oct 12 14:30:51 1989 *************** *** 1,9 **** ! /* $Header:procinfo.c 12.0$ */ ! /* $ACIS:procinfo.c 12.0$ */ ! /* $Source: /ibm/acis/usr/src/ucb/dbx/ibmrt/RCS/procinfo.c,v $ */ #ifndef lint ! static char *rcsid = "$Header:procinfo.c 12.0$"; #endif /* Copyright (c) 1982 Regents of the University of California */ --- 1,8 ---- ! /* $Header: procinfo.c,v 12.1 89/10/12 17:30:50 brunner Locked $ */ ! /* $Source: /fish/dbx/ibmrt/RCS/procinfo.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: procinfo.c,v 12.1 89/10/12 17:30:50 brunner Locked $"; #endif /* Copyright (c) 1982 Regents of the University of California */ *************** *** 104,110 **** } for (i = 0; i < NFLREG; i++) { sprintf(buf, "$fr%d", i); ! defregname(identname(buf, false), i + NREG); } defregname(identname("$ap", true), ARGP); defregname(identname("$fp", true), FRP); --- 103,110 ---- } for (i = 0; i < NFLREG; i++) { sprintf(buf, "$fr%d", i); ! /* defregname(identname(buf, false), i + NREG);*/ ! deffregname(identname(buf, false), i + NREG,8); } defregname(identname("$ap", true), ARGP); defregname(identname("$fp", true), FRP); Eric Brunner, IBM AWD Palo Alto inet: brunner@monet.berkeley.edu or brunner%ibmsupt@uunet.uu.net uucp: uunet!ibmsupt!brunner (415) 855-4486