More 64-bit fixes and cleanups. [jmk] --rw-rw-r-- M 208448 glenda sys 61334 Jan 3 16:06 sys/src/libmach/2db.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/2db.c:1296,1301 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/2db.c:1296,1303 return 0; } + #pragma varargck argpos bprint 2 + static void bprint(Inst *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/2db.c:1315,1321 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/2db.c:1317,1324 static void plocal(Inst *ip, Operand *ap) { - int ret, offset; + int ret; + long offset; uvlong moved; Symbol s; /n/sourcesdump/2006/0103/plan9/sys/src/libmach/2db.c:1533,1539 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/2db.c:1536,1542 case ADisp: /* references off the static base */ if (reg == 6 && mach->sb && ap->disp) { ip->curr += symoff(ip->curr, left, ap->disp+mach->sb, CANY); - bprint(ip, "(SB)", reg); + bprint(ip, "(SB)"); break; } /* reference autos and parameters off the stack */ [jmk] --rw-rw-r-- M 208448 glenda sys 21586 Jan 3 16:06 sys/src/libmach/5db.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/5db.c:212,217 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/5db.c:212,219 return 1; } + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/5db.c:254,260 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/5db.c:256,262 class == CAUTO ? " auto" : "param", offset); return 0; } - bprint(i, "%s%c%d%s", s.name, class == CPARAM ? '+' : '-', s.value, reg); + bprint(i, "%s%c%lld%s", s.name, class == CPARAM ? '+' : '-', s.value, reg); return 1; } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/5db.c:885,895 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/5db.c:887,897 break; case 'M': - bprint(i, "%d", (i->w>>8) & 0xf); + bprint(i, "%lud", (i->w>>8) & 0xf); break; case 'm': - bprint(i, "%d", (i->w>>7) & 0x1f); + bprint(i, "%lud", (i->w>>7) & 0x1f); break; case 'h': [jmk] --rw-rw-r-- M 208448 glenda sys 17355 Jan 3 16:06 sys/src/libmach/7db.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/7db.c:169,174 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/7db.c:169,176 return 1; } + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/7db.c:256,262 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/7db.c:258,264 if (i->rb == 29 && mach->sb) { bprint(i, "%s\t%c%d,", m, r, i->ra); i->curr += symoff(i->curr, i->end-i->curr, i->mem+mach->sb, CANY); - bprint(i, "(SB)", r, i->ra); + bprint(i, "(SB)"); return; } format(o->mnemonic, i, o->ken); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/7db.c:769,775 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/7db.c:771,777 case 'v': if (i->islit) - bprint(i, "$%lx", i->literal); + bprint(i, "$%ux", i->literal); else bprint(i, "R%d", i->rb); break; [jmk] --rw-rw-r-- M 208448 glenda sys 50889 Jan 3 16:06 sys/src/libmach/8db.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/8db.c:1701,1706 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/8db.c:1701,1708 return op; } + #pragma varargck argpos bprint 2 + static void bprint(Instr *ip, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/8db.c:1750,1756 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/8db.c:1752,1759 static void plocal(Instr *ip) { - int ret, offset; + int ret; + long offset; Symbol s; char *reg; /n/sourcesdump/2006/0103/plan9/sys/src/libmach/8db.c:1975,1981 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/8db.c:1978,1984 bprint(ip, "CBW"); break; case 'd': - bprint(ip,"%lux:%lux",ip->seg,ip->disp); + bprint(ip,"%ux:%lux",ip->seg,ip->disp); break; case 'm': if (ip->mod == 3 && ip->osize != 'B') { [jmk] --rw-rw-r-- M 208448 glenda sys 21222 Jan 3 16:06 sys/src/libmach/kdb.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:277,282 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:277,302 [0x1F] "swapa", loada, 0, }; + #pragma varargck argpos bprint 2 + #pragma varargck type "T" char* + + /* convert to lower case from upper, according to dascase */ + static int + Tfmt(Fmt *f) + { + char buf[128]; + char *s, *t, *oa; + + oa = va_arg(f->args, char*); + if(dascase){ + for(s=oa,t=buf; *t = *s; s++,t++) + if('A'<=*t && *t<='Z') + *t += 'a'-'A'; + return fmtstrcpy(f, buf); + } + return fmtstrcpy(f, oa); + } + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:375,381 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:395,401 break; case 1: - bprint(&instr, "%X", "CALL\t"); + bprint(&instr, "%T", "CALL\t"); instr.curr += symoff(instr.curr, instr.end-instr.curr, pc+instr.disp30*4, CTEXT); if (!dascase) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:406,429 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:426,432 return instr.size*4; } - /* convert to lower case from upper, according to dascase */ static int - Xfmt(Fmt *f) - { - char buf[128]; - char *s, *t, *oa; - - oa = va_arg(f->args, char*); - if(dascase){ - for(s=oa,t=buf; *t = *s; s++,t++) - if('A'<=*t && *t<='Z') - *t += 'a'-'A'; - return fmtstrcpy(f, buf); - } - return fmtstrcpy(f, oa); - } - - static int sparcinst(Map *map, uvlong pc, char modifier, char *buf, int n) { static int fmtinstalled = 0; /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:431,437 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:434,440 /* a modifier of 'I' toggles the dissassembler type */ if (!fmtinstalled) { fmtinstalled = 1; - fmtinstall('X', Xfmt); + fmtinstall('T', Tfmt); } if ((asstype == ASUNSPARC && modifier == 'i') || (asstype == ASPARC && modifier == 'I')) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:483,489 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:486,492 return -1; if (s.value > i->simm13) { if(getauto(&s, s.value-i->simm13, CAUTO, &s)) { - bprint(i, "%s+%d(SP)", s.name, s.value); + bprint(i, "%s+%lld(SP)", s.name, s.value); return 1; } } else { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:518,534 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:521,537 } bprint(i, "%s", s.name); if (s.value != off) - bprint(i, "+%lux", s.value-off); + bprint(i, "+%llux", s.value-off); bprint(i, "(SB)"); return; } - bprint(i, "%lux(R%d)", i->simm13, i->rs1); + bprint(i, "%ux(R%d)", i->simm13, i->rs1); } static void unimp(Instr *i, char *m) { - bprint(i, "%X", m); + bprint(i, "%T", m); } static char *bratab[16] = { /* page 91 */ /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:595,603 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:598,606 imm = i->simmdisp22; if(i->a) - bprint(i, "%X%X.%c\t", m, tab[i->cond], 'A'+dascase); + bprint(i, "%T%T.%c\t", m, tab[i->cond], 'A'+dascase); else - bprint(i, "%X%X\t", m, tab[i->cond]); + bprint(i, "%T%T\t", m, tab[i->cond]); i->curr += symoff(i->curr, i->end-i->curr, i->addr+4*imm, CTEXT); if (!dascase) bprint(i, "(SB)"); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:625,633 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:628,636 trap(Instr *i, char *m) /* page 101 */ { if(i->i == 0) - bprint(i, "%X%X\tR%d+R%d", m, bratab[i->cond], i->rs2, i->rs1); + bprint(i, "%T%T\tR%d+R%d", m, bratab[i->cond], i->rs2, i->rs1); else - bprint(i, "%X%X\t$%lux+R%d", m, bratab[i->cond], i->simm13, i->rs1); + bprint(i, "%T%T\t$%ux+R%d", m, bratab[i->cond], i->simm13, i->rs1); } static void /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:637,643 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:640,646 imm = i->immdisp22<<10; if(dascase){ - bprint(i, "%X\t%lux, R%d", m, imm, i->rd); + bprint(i, "%T\t%lux, R%d", m, imm, i->rd); return; } if(imm==0 && i->rd==0){ /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:733,757 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:736,760 if(i->i == 0){ if(i->rs1 == i->rd) if(dascase) - bprint(i, "%X\tR%d, R%d", m, i->rs1, i->rs2); + bprint(i, "%T\tR%d, R%d", m, i->rs1, i->rs2); else - bprint(i, "%X\tR%d, R%d", m, i->rs2, i->rs1); + bprint(i, "%T\tR%d, R%d", m, i->rs2, i->rs1); else if(dascase) - bprint(i, "%X\tR%d, R%d, R%d", m, i->rs1, i->rs2, i->rd); + bprint(i, "%T\tR%d, R%d, R%d", m, i->rs1, i->rs2, i->rd); else - bprint(i, "%X\tR%d, R%d, R%d", m, i->rs2, i->rs1, i->rd); + bprint(i, "%T\tR%d, R%d, R%d", m, i->rs2, i->rs1, i->rd); }else{ if(i->rs1 == i->rd) if(dascase) - bprint(i, "%X\t$%d,R%d", m, i->simm13&0x1F, i->rs1); + bprint(i, "%T\t$%d,R%d", m, i->simm13&0x1F, i->rs1); else - bprint(i, "%X\tR%d, $%d", m, i->rs1, i->simm13&0x1F); + bprint(i, "%T\tR%d, $%d", m, i->rs1, i->simm13&0x1F); else if(dascase) - bprint(i, "%X\tR%d, $%d, R%d",m,i->rs1,i->simm13&0x1F,i->rd); + bprint(i, "%T\tR%d, $%d, R%d",m,i->rs1,i->simm13&0x1F,i->rd); else - bprint(i, "%X\t$%d, R%d, R%d",m,i->simm13&0x1F,i->rs1,i->rd); + bprint(i, "%T\t$%d, R%d, R%d",m,i->simm13&0x1F,i->rs1,i->rd); } } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:760,783 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:763,786 { if(i->i == 0){ if(dascase) - bprint(i, "%X\tR%d, R%d", m, i->rs1, i->rs2); + bprint(i, "%T\tR%d, R%d", m, i->rs1, i->rs2); else if(i->op3==2 && i->rs1==0 && i->rd) /* OR R2, R0, R1 */ bprint(i, "MOVW\tR%d", i->rs2); else - bprint(i, "%X\tR%d, R%d", m, i->rs2, i->rs1); + bprint(i, "%T\tR%d, R%d", m, i->rs2, i->rs1); }else{ if(dascase) - bprint(i, "%X\tR%d, $%lux", m, i->rs1, i->simm13); + bprint(i, "%T\tR%d, $%ux", m, i->rs1, i->simm13); else if(i->op3==0 && i->rd && i->rs1==0) /* ADD $x, R0, R1 */ - bprint(i, "MOVW\t$%lux", i->simm13); + bprint(i, "MOVW\t$%ux", i->simm13); else if(i->op3==0 && i->rd && i->rs1==2){ /* ADD $x, R2, R1 -> MOVW $x(SB), R1 */ bprint(i, "MOVW\t$"); address(i); } else - bprint(i, "%X\t$%lux, R%d", m, i->simm13, i->rs1); + bprint(i, "%T\t$%ux, R%d", m, i->simm13, i->rs1); } if(i->rs1 != i->rd) bprint(i, ", R%d", i->rd); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:793,799 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:796,802 if(i->i == 0) bprint(i, "CMP\tR%d, R%d", i->rs1, i->rs2); else - bprint(i, "CMP\tR%d, $%lux", i->rs1, i->simm13); + bprint(i, "CMP\tR%d, $%ux", i->rs1, i->simm13); } static char *regtab[4] = { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:810,816 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:813,819 if(i->i == 0) bprint(i, "%s\tR%d, R%d", m, i->rs1, i->rs2); else - bprint(i, "%s\tR%d, $%lux", m, i->rs1, i->simm13); + bprint(i, "%s\tR%d, $%ux", m, i->rs1, i->simm13); }else{ if(i->i && i->simm13==0) bprint(i, "MOVW\tR%d", i->rs1); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:817,823 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:820,826 else if(i->i == 0) bprint(i, "wr\tR%d, R%d", i->rs2, i->rs1); else - bprint(i, "wr\t$%lux, R%d", i->simm13, i->rs1); + bprint(i, "wr\t$%ux, R%d", i->simm13, i->rs1); } bprint(i, ", %s", regtab[i->op3&3]); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:842,855 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:845,858 { if(i->i == 0){ if(i->rd == 15) - bprint(i, "%X\t(R%d+R%d)", "CALL", i->rs2, i->rs1); + bprint(i, "%T\t(R%d+R%d)", "CALL", i->rs2, i->rs1); else - bprint(i, "%X\t(R%d+R%d), R%d", m, i->rs2, i->rs1, i->rd); + bprint(i, "%T\t(R%d+R%d), R%d", m, i->rs2, i->rs1, i->rd); }else{ if(!dascase && i->simm13==8 && i->rs1==15 && i->rd==0) bprint(i, "RETURN"); else{ - bprint(i, "%X\t", m); + bprint(i, "%T\t", m); address(i); bprint(i, ", R%d", i->rd); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/kdb.c:995,1009 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/kdb.c:998,1012 } for(j=0; fptab1[j].name; j++) if(fptab1[j].opf == i->opf){ - bprint(i, "%X\tF%d, F%d", fptab1[j].name, i->rs2, i->rd); + bprint(i, "%T\tF%d, F%d", fptab1[j].name, i->rs2, i->rd); return; } for(j=0; fptab2[j].name; j++) if(fptab2[j].opf == i->opf){ - bprint(i, "%X\tF%d, F%d, F%d", fptab2[j].name, i->rs1, i->rs2, i->rd); + bprint(i, "%T\tF%d, F%d, F%d", fptab2[j].name, i->rs1, i->rs2, i->rd); return; } - bprint(i, "%X%ux\tF%d, F%d, F%d", m, i->opf, i->rs1, i->rs2, i->rd); + bprint(i, "%T%ux\tF%d, F%d, F%d", m, i->opf, i->rs1, i->rs2, i->rd); } static int [jmk] --rw-rw-r-- M 208448 glenda sys 27544 Jan 3 16:06 sys/src/libmach/qdb.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:157,162 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:157,164 #define IBF(v,a,b) (((ulong)(v)>>(32-(b)-1)) & ~(~0L<<(((b)-(a)+1)))) #define IB(v,b) IBF((v),(b),(b)) + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:250,256 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:252,258 static int plocal(Instr *i) { - int offset; + long offset; Symbol s; if (!findsym(i->addr, CTEXT, &s) || !findlocal(&s, FRAMENAME, &s)) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:258,269 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:260,271 offset = s.value - i->immediate; if (offset > 0) { if(getauto(&s, offset, CAUTO, &s)) { - bprint(i, "%s+%d(SP)", s.name, s.value); + bprint(i, "%s+%lld(SP)", s.name, s.value); return 1; } } else { if (getauto(&s, -offset-4, CPARAM, &s)) { - bprint(i, "%s+%d(FP)", s.name, -offset); + bprint(i, "%s+%ld(FP)", s.name, -offset); return 1; } } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:289,301 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:291,303 } bprint(i, "%s", s.name); if (s.value != off) - bprint(i, "+%lux", off-s.value); + bprint(i, "+%llux", off-s.value); bprint(i, reg); return 1; } if(!anyoff) return 0; - bprint(i, "%lux%s", off, reg); + bprint(i, "%llux%s", off, reg); return 1; } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:307,313 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:309,315 if (i->ra == REGSB && mach->sb && pglobal(i, mach->sb+i->immediate, 0, "(SB)") >= 0) return; if(i->simm < 0) - bprint(i, "-%lx(R%d)", -i->simm, i->ra); + bprint(i, "-%x(R%d)", -i->simm, i->ra); else bprint(i, "%lux(R%d)", i->immediate, i->ra); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:389,395 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:391,397 address(i); bprint(i, ",R%d", i->rd); } else if(i->op==15 && v < 0) { - bprint(i, "SUB\t$%d,R%d", -v, i->ra); + bprint(i, "SUB\t$%ld,R%d", -v, i->ra); if(i->rd != i->ra) bprint(i, ",R%d", i->rd); } else { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:1058,1074 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:1060,1076 case 'l': if(i->simm < 0) - bprint(i, "-%lx(R%d)", -i->simm, i->ra); + bprint(i, "-%x(R%d)", -i->simm, i->ra); else - bprint(i, "%lx(R%d)", i->simm, i->ra); + bprint(i, "%x(R%d)", i->simm, i->ra); break; case 'i': - bprint(i, "$%ld", i->simm); + bprint(i, "$%d", i->simm); break; case 'I': - bprint(i, "$%lx", i->uimm); + bprint(i, "$%ux", i->uimm); break; case 'w': /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:1099,1109 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:1101,1111 break; case 'm': - bprint(i, "%lx", i->crm); + bprint(i, "%ux", i->crm); break; case 'M': - bprint(i, "%lx", i->fm); + bprint(i, "%ux", i->fm); break; case 'z': /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:157,162 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:157,164 #define IBF(v,a,b) (((ulong)(v)>>(32-(b)-1)) & ~(~0L<<(((b)-(a)+1)))) #define IB(v,b) IBF((v),(b),(b)) + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:250,256 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:252,258 static int plocal(Instr *i) { - int offset; + long offset; Symbol s; if (!findsym(i->addr, CTEXT, &s) || !findlocal(&s, FRAMENAME, &s)) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:258,269 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:260,271 offset = s.value - i->immediate; if (offset > 0) { if(getauto(&s, offset, CAUTO, &s)) { - bprint(i, "%s+%d(SP)", s.name, s.value); + bprint(i, "%s+%lld(SP)", s.name, s.value); return 1; } } else { if (getauto(&s, -offset-4, CPARAM, &s)) { - bprint(i, "%s+%d(FP)", s.name, -offset); + bprint(i, "%s+%ld(FP)", s.name, -offset); return 1; } } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:289,301 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:291,303 } bprint(i, "%s", s.name); if (s.value != off) - bprint(i, "+%lux", off-s.value); + bprint(i, "+%llux", off-s.value); bprint(i, reg); return 1; } if(!anyoff) return 0; - bprint(i, "%lux%s", off, reg); + bprint(i, "%llux%s", off, reg); return 1; } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:307,313 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:309,315 if (i->ra == REGSB && mach->sb && pglobal(i, mach->sb+i->immediate, 0, "(SB)") >= 0) return; if(i->simm < 0) - bprint(i, "-%lx(R%d)", -i->simm, i->ra); + bprint(i, "-%x(R%d)", -i->simm, i->ra); else bprint(i, "%lux(R%d)", i->immediate, i->ra); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:389,395 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:391,397 address(i); bprint(i, ",R%d", i->rd); } else if(i->op==15 && v < 0) { - bprint(i, "SUB\t$%d,R%d", -v, i->ra); + bprint(i, "SUB\t$%ld,R%d", -v, i->ra); if(i->rd != i->ra) bprint(i, ",R%d", i->rd); } else { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:1058,1074 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:1060,1076 case 'l': if(i->simm < 0) - bprint(i, "-%lx(R%d)", -i->simm, i->ra); + bprint(i, "-%x(R%d)", -i->simm, i->ra); else - bprint(i, "%lx(R%d)", i->simm, i->ra); + bprint(i, "%x(R%d)", i->simm, i->ra); break; case 'i': - bprint(i, "$%ld", i->simm); + bprint(i, "$%d", i->simm); break; case 'I': - bprint(i, "$%lx", i->uimm); + bprint(i, "$%ux", i->uimm); break; case 'w': /n/sourcesdump/2006/0103/plan9/sys/src/libmach/qdb.c:1099,1109 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/qdb.c:1101,1111 break; case 'm': - bprint(i, "%lx", i->crm); + bprint(i, "%ux", i->crm); break; case 'M': - bprint(i, "%lx", i->fm); + bprint(i, "%ux", i->fm); break; case 'z': [jmk] --rw-rw-r-- M 208448 jmk sys 21967 Jan 3 16:06 sys/src/libmach/udb.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:304,309 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:304,329 [0x1F] "swapa", loada, 0, }; + #pragma varargck argpos bprint 2 + #pragma varargck type "T" char* + + /* convert to lower case from upper, according to dascase */ + static int + Tfmt(Fmt *f) + { + char buf[128]; + char *s, *t, *oa; + + oa = va_arg(f->args, char*); + if(dascase){ + for(s=oa,t=buf; *t = *s; s++,t++) + if('A'<=*t && *t<='Z') + *t += 'a'-'A'; + return fmtstrcpy(f, buf); + } + return fmtstrcpy(f, oa); + } + static void bprint(Instr *i, char *fmt, ...) { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:402,408 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:422,428 break; case 1: - bprint(&instr, "%X", "CALL\t"); + bprint(&instr, "CALL\t"); instr.curr += symoff(instr.curr, instr.end-instr.curr, pc+instr.disp30*4, CTEXT); if (!dascase) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:433,456 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:453,459 return instr.size*4; } - /* convert to lower case from upper, according to dascase */ static int - Xfmt(Fmt *f) - { - char buf[128]; - char *s, *t, *oa; - - oa = va_arg(f->args, char*); - if(dascase){ - for(s=oa,t=buf; *t = *s; s++,t++) - if('A'<=*t && *t<='Z') - *t += 'a'-'A'; - return fmtstrcpy(f, buf); - } - return fmtstrcpy(f, oa); - } - - static int sparc64inst(Map *map, uvlong pc, char modifier, char *buf, int n) { static int fmtinstalled = 0; /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:458,464 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:461,467 /* a modifier of 'I' toggles the dissassembler type */ if (!fmtinstalled) { fmtinstalled = 1; - fmtinstall('X', Xfmt); + fmtinstall('T', Tfmt); } if ((asstype == ASUNSPARC && modifier == 'i') || (asstype == ASPARC && modifier == 'I')) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:503,509 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:506,512 static int plocal(Instr *i) { - int offset; + long offset; Symbol s; if (!findsym(i->addr, CTEXT, &s) || !findlocal(&s, FRAMENAME, &s)) /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:510,522 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:513,525 return -1; if (s.value > i->simm13) { if(getauto(&s, s.value-i->simm13, CAUTO, &s)) { - bprint(i, "%s+%d(SP)", s.name, s.value); + bprint(i, "%s+%lld(SP)", s.name, s.value); return 1; } } else { offset = i->simm13-s.value; if (getauto(&s, offset-4, CPARAM, &s)) { - bprint(i, "%s+%d(FP)", s.name, offset); + bprint(i, "%s+%ld(FP)", s.name, offset); return 1; } } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:545,561 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:548,564 } bprint(i, "%s", s.name); if (s.value != off) - bprint(i, "+%lux", s.value-off); + bprint(i, "+%llux", s.value-off); bprint(i, "(SB)"); return; } - bprint(i, "%lux(R%d)", i->simm13, i->rs1); + bprint(i, "%ux(R%d)", i->simm13, i->rs1); } static void unimp(Instr *i, char *m) { - bprint(i, "%X", m); + bprint(i, "%T", m); } static char *bratab[16] = { /* page 91 */ /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:622,630 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:625,633 imm = i->simmdisp22; if(i->a) - bprint(i, "%X%X.%c\t", m, tab[i->cond], 'A'+dascase); + bprint(i, "%T%T.%c\t", m, tab[i->cond], 'A'+dascase); else - bprint(i, "%X%X\t", m, tab[i->cond]); + bprint(i, "%T%T\t", m, tab[i->cond]); i->curr += symoff(i->curr, i->end-i->curr, i->addr+4*imm, CTEXT); if (!dascase) bprint(i, "(SB)"); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:652,660 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:655,663 trap(Instr *i, char *m) /* page 101 */ { if(i->i == 0) - bprint(i, "%X%X\tR%d+R%d", m, bratab[i->cond], i->rs2, i->rs1); + bprint(i, "%T%T\tR%d+R%d", m, bratab[i->cond], i->rs2, i->rs1); else - bprint(i, "%X%X\t$%lux+R%d", m, bratab[i->cond], i->simm13, i->rs1); + bprint(i, "%T%T\t$%ux+R%d", m, bratab[i->cond], i->simm13, i->rs1); } static void /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:664,670 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:667,673 imm = i->immdisp22<<10; if(dascase){ - bprint(i, "%X\t%lux, R%d", m, imm, i->rd); + bprint(i, "%T\t%lux, R%d", m, imm, i->rd); return; } if(imm==0 && i->rd==0){ /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:760,784 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:763,787 if(i->i == 0){ if(i->rs1 == i->rd) if(dascase) - bprint(i, "%X\tR%d, R%d", m, i->rs1, i->rs2); + bprint(i, "%T\tR%d, R%d", m, i->rs1, i->rs2); else - bprint(i, "%X\tR%d, R%d", m, i->rs2, i->rs1); + bprint(i, "%T\tR%d, R%d", m, i->rs2, i->rs1); else if(dascase) - bprint(i, "%X\tR%d, R%d, R%d", m, i->rs1, i->rs2, i->rd); + bprint(i, "%T\tR%d, R%d, R%d", m, i->rs1, i->rs2, i->rd); else - bprint(i, "%X\tR%d, R%d, R%d", m, i->rs2, i->rs1, i->rd); + bprint(i, "%T\tR%d, R%d, R%d", m, i->rs2, i->rs1, i->rd); }else{ if(i->rs1 == i->rd) if(dascase) - bprint(i, "%X\t$%d,R%d", m, i->simm13&0x1F, i->rs1); + bprint(i, "%T\t$%d,R%d", m, i->simm13&0x1F, i->rs1); else - bprint(i, "%X\tR%d, $%d", m, i->rs1, i->simm13&0x1F); + bprint(i, "%T\tR%d, $%d", m, i->rs1, i->simm13&0x1F); else if(dascase) - bprint(i, "%X\tR%d, $%d, R%d",m,i->rs1,i->simm13&0x1F,i->rd); + bprint(i, "%T\tR%d, $%d, R%d",m,i->rs1,i->simm13&0x1F,i->rd); else - bprint(i, "%X\t$%d, R%d, R%d",m,i->simm13&0x1F,i->rs1,i->rd); + bprint(i, "%T\t$%d, R%d, R%d",m,i->simm13&0x1F,i->rs1,i->rd); } } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:787,810 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:790,813 { if(i->i == 0){ if(dascase) - bprint(i, "%X\tR%d, R%d", m, i->rs1, i->rs2); + bprint(i, "%T\tR%d, R%d", m, i->rs1, i->rs2); else if(i->op3==2 && i->rs1==0 && i->rd) /* OR R2, R0, R1 */ bprint(i, "MOVW\tR%d", i->rs2); else - bprint(i, "%X\tR%d, R%d", m, i->rs2, i->rs1); + bprint(i, "%T\tR%d, R%d", m, i->rs2, i->rs1); }else{ if(dascase) - bprint(i, "%X\tR%d, $%lux", m, i->rs1, i->simm13); + bprint(i, "%T\tR%d, $%ux", m, i->rs1, i->simm13); else if(i->op3==0 && i->rd && i->rs1==0) /* ADD $x, R0, R1 */ - bprint(i, "MOVW\t$%lux", i->simm13); + bprint(i, "MOVW\t$%ux", i->simm13); else if(i->op3==0 && i->rd && i->rs1==2){ /* ADD $x, R2, R1 -> MOVW $x(SB), R1 */ bprint(i, "MOVW\t$"); address(i); } else - bprint(i, "%X\t$%lux, R%d", m, i->simm13, i->rs1); + bprint(i, "%T\t$%ux, R%d", m, i->simm13, i->rs1); } if(i->rs1 != i->rd) bprint(i, ", R%d", i->rd); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:820,826 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:823,829 if(i->i == 0) bprint(i, "CMP\tR%d, R%d", i->rs1, i->rs2); else - bprint(i, "CMP\tR%d, $%lux", i->rs1, i->simm13); + bprint(i, "CMP\tR%d, $%ux", i->rs1, i->simm13); } static char *regtab[4] = { /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:837,843 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:840,846 if(i->i == 0) bprint(i, "%s\tR%d, R%d", m, i->rs1, i->rs2); else - bprint(i, "%s\tR%d, $%lux", m, i->rs1, i->simm13); + bprint(i, "%s\tR%d, $%ux", m, i->rs1, i->simm13); }else{ if(i->i && i->simm13==0) bprint(i, "MOVW\tR%d", i->rs1); /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:844,850 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:847,853 else if(i->i == 0) bprint(i, "wr\tR%d, R%d", i->rs2, i->rs1); else - bprint(i, "wr\t$%lux, R%d", i->simm13, i->rs1); + bprint(i, "wr\t$%ux, R%d", i->simm13, i->rs1); } bprint(i, ", %s", regtab[i->op3&3]); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:869,882 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:872,885 { if(i->i == 0){ if(i->rd == 15) - bprint(i, "%X\t(R%d+R%d)", "CALL", i->rs2, i->rs1); + bprint(i, "%T\t(R%d+R%d)", "CALL", i->rs2, i->rs1); else - bprint(i, "%X\t(R%d+R%d), R%d", m, i->rs2, i->rs1, i->rd); + bprint(i, "%T\t(R%d+R%d), R%d", m, i->rs2, i->rs1, i->rd); }else{ if(!dascase && i->simm13==8 && i->rs1==15 && i->rd==0) bprint(i, "RETURN"); else{ - bprint(i, "%X\t", m); + bprint(i, "%T\t", m); address(i); bprint(i, ", R%d", i->rd); } /n/sourcesdump/2006/0103/plan9/sys/src/libmach/udb.c:1022,1036 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/udb.c:1025,1039 } for(j=0; fptab1[j].name; j++) if(fptab1[j].opf == i->opf){ - bprint(i, "%X\tF%d, F%d", fptab1[j].name, i->rs2, i->rd); + bprint(i, "%T\tF%d, F%d", fptab1[j].name, i->rs2, i->rd); return; } for(j=0; fptab2[j].name; j++) if(fptab2[j].opf == i->opf){ - bprint(i, "%X\tF%d, F%d, F%d", fptab2[j].name, i->rs1, i->rs2, i->rd); + bprint(i, "%T\tF%d, F%d, F%d", fptab2[j].name, i->rs1, i->rs2, i->rd); return; } - bprint(i, "%X%ux\tF%d, F%d, F%d", m, i->opf, i->rs1, i->rs2, i->rd); + bprint(i, "%T%ux\tF%d, F%d, F%d", m, i->opf, i->rs1, i->rs2, i->rd); } static int [jmk] --rw-rw-r-- M 208448 glenda sys 10293 Jan 3 18:02 sys/src/libmach/vcodas.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/vcodas.c:306,311 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/vcodas.c:306,313 return 1; } + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) { [jmk] --rw-rw-r-- M 208448 glenda sys 22299 Jan 3 18:02 sys/src/libmach/vdb.c /n/sourcesdump/2006/0103/plan9/sys/src/libmach/vdb.c:224,229 - /n/sourcesdump/2006/0104/plan9/sys/src/libmach/vdb.c:224,231 return 1; } + #pragma varargck argpos bprint 2 + static void bprint(Instr *i, char *fmt, ...) {