Print this page
patch fix-lint
3317 dis(1) should support cross-target disassembly

*** 25,34 **** --- 25,35 ---- */ /* * Copyright 2009 Jason King. All rights reserved. * Use is subject to license terms. + * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> */ #include <sys/byteorder.h> #include <stdarg.h>
*** 46,57 **** extern size_t strlen(const char *); extern int strcmp(const char *, const char *); extern int strncmp(const char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); extern size_t strlcpy(char *, const char *, size_t); - extern int snprintf(char *, size_t, const char *, ...); - extern int vsnprintf(char *, size_t, const char *, va_list); /* * This file has the functions that do all the dirty work of outputting the * disassembled instruction * --- 47,56 ----
*** 696,713 **** */ /* ARGSUSED1 */ int fmt_call(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; int32_t disp; size_t curlen; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f1.op, 2); prt_field("disp30", f->f1.disp30, 30); } disp = sign_extend(f->f1.disp30, 30) * 4; --- 695,713 ---- */ /* ARGSUSED1 */ int fmt_call(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int32_t disp; size_t curlen; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f1.op, 2); prt_field("disp30", f->f1.disp30, 30); } disp = sign_extend(f->f1.disp30, 30) * 4;
*** 716,743 **** bprintf(dhp, (octal != 0) ? "%s0%-11lo" : "%s0x%-10lx", (disp < 0) ? "-" : "+", (disp < 0) ? (-disp) : disp); ! (void) strlcat(dhp->dh_buf, " <", dhp->dh_buflen); ! curlen = strlen(dhp->dh_buf); dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp, ! dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL, NULL); ! (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen); return (0); } int fmt_sethi(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f2.op, 2); prt_field("op2", f->f2.op2, 3); prt_field("rd", f->f2.rd, 5); prt_field("imm22", f->f2.imm22, 22); } --- 716,744 ---- bprintf(dhp, (octal != 0) ? "%s0%-11lo" : "%s0x%-10lx", (disp < 0) ? "-" : "+", (disp < 0) ? (-disp) : disp); ! (void) strlcat(dhx->dhx_buf, " <", dhx->dhx_buflen); ! curlen = strlen(dhx->dhx_buf); dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp, ! dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL, NULL); ! (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen); return (0); } int fmt_sethi(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f2.op, 2); prt_field("op2", f->f2.op2, 3); prt_field("rd", f->f2.rd, 5); prt_field("imm22", f->f2.imm22, 22); }
*** 769,778 **** --- 770,780 ---- /* ARGSUSED3 */ int fmt_branch(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; const char *name = inp->in_data.in_def.in_name; const char *r = NULL; const char *annul = ""; const char *pred = "";
*** 783,793 **** size_t curlen; int32_t disp; uint32_t flags = inp->in_data.in_def.in_flags; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f2.op, 2); prt_field("op2", f->f2.op2, 3); switch (FLG_DISP_VAL(flags)) { case DISP22: --- 785,795 ---- size_t curlen; int32_t disp; uint32_t flags = inp->in_data.in_def.in_flags; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f2.op, 2); prt_field("op2", f->f2.op2, 3); switch (FLG_DISP_VAL(flags)) { case DISP22:
*** 814,824 **** break; } } if (f->f2b.op2 == 0x01 && idx == 0x00 && f->f2b.p == 1 && ! f->f2b.cc == 0x02 && ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0)) { name = "iprefetch"; flags = FLG_RS1(REG_NONE)|FLG_DISP(DISP19); } --- 816,826 ---- break; } } if (f->f2b.op2 == 0x01 && idx == 0x00 && f->f2b.p == 1 && ! f->f2b.cc == 0x02 && ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0)) { name = "iprefetch"; flags = FLG_RS1(REG_NONE)|FLG_DISP(DISP19); }
*** 852,867 **** if ((flags & FLG_PRED) != 0) { if (f->f2b.p == 0) { pred = ",pn"; } else { ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0) pred = ",pt"; } } ! (void) snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred); prt_name(dhp, buf, 1); switch (FLG_DISP_VAL(flags)) { case DISP22: --- 854,869 ---- if ((flags & FLG_PRED) != 0) { if (f->f2b.p == 0) { pred = ",pn"; } else { ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0) pred = ",pt"; } } ! (void) dis_snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred); prt_name(dhp, buf, 1); switch (FLG_DISP_VAL(flags)) { case DISP22:
*** 886,900 **** (disp < 0) ? "-" : "+", (disp < 0) ? (-disp) : disp); break; } ! curlen = strlen(dhp->dh_buf); dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp, ! dhp->dh_buf + curlen, dhp->dh_buflen - curlen - 1, NULL, NULL); ! (void) strlcat(dhp->dh_buf, ">", dhp->dh_buflen); return (0); } --- 888,902 ---- (disp < 0) ? "-" : "+", (disp < 0) ? (-disp) : disp); break; } ! curlen = strlen(dhx->dhx_buf); dhp->dh_lookup(dhp->dh_data, dhp->dh_addr + (int64_t)disp, ! dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen - 1, NULL, NULL); ! (void) strlcat(dhx->dhx_buf, ">", dhx->dhx_buflen); return (0); }
*** 913,929 **** * casxa [%rs1]#ASI_P_L, %rs2, %rd -> casxl [%rs1], %rs2, %rd */ static int fmt_cas(dis_handle_t *dhp, uint32_t instr, const char *name) { ifmt_t *f = (ifmt_t *)&instr; const char *asistr = NULL; int noasi = 0; asistr = get_asi_name(f->f3.asi); ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) { if (f->f3.op3 == 0x3c && f->f3.i == 0) { if (f->f3.asi == 0x80) { noasi = 1; name = "cas"; } --- 915,932 ---- * casxa [%rs1]#ASI_P_L, %rs2, %rd -> casxl [%rs1], %rs2, %rd */ static int fmt_cas(dis_handle_t *dhp, uint32_t instr, const char *name) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char *asistr = NULL; int noasi = 0; asistr = get_asi_name(f->f3.asi); ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) != 0) { if (f->f3.op3 == 0x3c && f->f3.i == 0) { if (f->f3.asi == 0x80) { noasi = 1; name = "cas"; }
*** 950,960 **** prt_name(dhp, name, 1); bprintf(dhp, "[%s]", reg_names[f->f3.rs1]); if (noasi == 0) { ! (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen); prt_asi(dhp, instr); } bprintf(dhp, ", %s, %s", reg_names[f->f3.rs2], reg_names[f->f3.rd]); --- 953,963 ---- prt_name(dhp, name, 1); bprintf(dhp, "[%s]", reg_names[f->f3.rs1]); if (noasi == 0) { ! (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen); prt_asi(dhp, instr); } bprintf(dhp, ", %s, %s", reg_names[f->f3.rs2], reg_names[f->f3.rd]);
*** 997,1014 **** * sttw -> st */ int fmt_ls(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; const char *regstr = NULL; const char *asistr = NULL; const char *iname = inp->in_data.in_def.in_name; uint32_t flags = inp->in_data.in_def.in_flags; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("rs1", f->f3.rs1, 5); prt_field("i", f->f3.i, 1); if (f->f3.i != 0) { --- 1000,1018 ---- * sttw -> st */ int fmt_ls(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char *regstr = NULL; const char *asistr = NULL; const char *iname = inp->in_data.in_def.in_name; uint32_t flags = inp->in_data.in_def.in_flags; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("rs1", f->f3.rs1, 5); prt_field("i", f->f3.i, 1); if (f->f3.i != 0) {
*** 1027,1046 **** prt_name(dhp, iname, 1); prt_address(dhp, instr, 0); if (idx == 0x3d) { ! (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen); prt_asi(dhp, instr); } ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); /* fcn field is the same as rd */ if (prefetch_str[f->f3.rd] != NULL) ! (void) strlcat(dhp->dh_buf, prefetch_str[f->f3.rd], ! dhp->dh_buflen); else prt_imm(dhp, f->f3.rd, 0); if (idx == 0x3d && f->f3.i == 0) { asistr = get_asi_name(f->f3.asi); --- 1031,1050 ---- prt_name(dhp, iname, 1); prt_address(dhp, instr, 0); if (idx == 0x3d) { ! (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen); prt_asi(dhp, instr); } ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); /* fcn field is the same as rd */ if (prefetch_str[f->f3.rd] != NULL) ! (void) strlcat(dhx->dhx_buf, prefetch_str[f->f3.rd], ! dhx->dhx_buflen); else prt_imm(dhp, f->f3.rd, 0); if (idx == 0x3d && f->f3.i == 0) { asistr = get_asi_name(f->f3.asi);
*** 1057,1078 **** /* synthetic instructions & special cases */ switch (idx) { case 0x00: /* ld */ ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) iname = "lduw"; break; case 0x03: ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) iname = "ldtw"; break; case 0x04: /* stw */ ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) iname = "stuw"; if ((dhp->dh_flags & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break; --- 1061,1082 ---- /* synthetic instructions & special cases */ switch (idx) { case 0x00: /* ld */ ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) iname = "lduw"; break; case 0x03: ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) iname = "ldtw"; break; case 0x04: /* stw */ ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) iname = "stuw"; if ((dhp->dh_flags & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break;
*** 1106,1116 **** flags = FLG_RD(REG_NONE); } break; case 0x07: ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) iname = "sttw"; break; case 0x0e: /* stx */ --- 1110,1120 ---- flags = FLG_RD(REG_NONE); } break; case 0x07: ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) iname = "sttw"; break; case 0x0e: /* stx */
*** 1125,1142 **** } break; case 0x13: /* ldtwa */ ! if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) iname = "ldtwa"; break; case 0x17: /* sttwa */ ! if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) iname = "sttwa"; break; case 0x21: --- 1129,1146 ---- } break; case 0x13: /* ldtwa */ ! if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) iname = "ldtwa"; break; case 0x17: /* sttwa */ ! if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) iname = "sttwa"; break; case 0x21:
*** 1210,1238 **** prt_name(dhp, iname, 1); if ((flags & FLG_STORE) != 0) { if (regstr[0] != '\0') { ! (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen); ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); } prt_address(dhp, instr, 0); if ((flags & FLG_ASI) != 0) { ! (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen); prt_asi(dhp, instr); } } else { prt_address(dhp, instr, 0); if ((flags & FLG_ASI) != 0) { ! (void) strlcat(dhp->dh_buf, " ", dhp->dh_buflen); prt_asi(dhp, instr); } if (regstr[0] != '\0') { ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); ! (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen); } } if ((flags & FLG_ASI) != 0 && asistr != NULL) bprintf(dhp, "\t<%s>", asistr); --- 1214,1242 ---- prt_name(dhp, iname, 1); if ((flags & FLG_STORE) != 0) { if (regstr[0] != '\0') { ! (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen); ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); } prt_address(dhp, instr, 0); if ((flags & FLG_ASI) != 0) { ! (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen); prt_asi(dhp, instr); } } else { prt_address(dhp, instr, 0); if ((flags & FLG_ASI) != 0) { ! (void) strlcat(dhx->dhx_buf, " ", dhx->dhx_buflen); prt_asi(dhp, instr); } if (regstr[0] != '\0') { ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); ! (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen); } } if ((flags & FLG_ASI) != 0 && asistr != NULL) bprintf(dhp, "\t<%s>", asistr);
*** 1241,1254 **** } static int fmt_cpop(dis_handle_t *dhp, uint32_t instr, const inst_t *inp) { ifmt_t *f = (ifmt_t *)&instr; int flags = FLG_P1(REG_CP)|FLG_P2(REG_CP)|FLG_NOIMM|FLG_P3(REG_CP); ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->fcp.op, 2); prt_field("op3", f->fcp.op3, 6); prt_field("opc", f->fcp.opc, 9); prt_field("rs1", f->fcp.rs1, 5); prt_field("rs2", f->fcp.rs2, 5); --- 1245,1259 ---- } static int fmt_cpop(dis_handle_t *dhp, uint32_t instr, const inst_t *inp) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int flags = FLG_P1(REG_CP)|FLG_P2(REG_CP)|FLG_NOIMM|FLG_P3(REG_CP); ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->fcp.op, 2); prt_field("op3", f->fcp.op3, 6); prt_field("opc", f->fcp.opc, 9); prt_field("rs1", f->fcp.rs1, 5); prt_field("rs2", f->fcp.rs2, 5);
*** 1256,1274 **** } prt_name(dhp, inp->in_data.in_def.in_name, 1); prt_imm(dhp, f->fcp.opc, 0); ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); (void) prt_aluargs(dhp, instr, flags); return (0); } static int dis_fmt_rdwr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { const char *psr_str = "%psr"; const char *wim_str = "%wim"; const char *tbr_str = "%tbr"; const char *name = inp->in_data.in_def.in_name; --- 1261,1280 ---- } prt_name(dhp, inp->in_data.in_def.in_name, 1); prt_imm(dhp, f->fcp.opc, 0); ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); (void) prt_aluargs(dhp, instr, flags); return (0); } static int dis_fmt_rdwr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; const char *psr_str = "%psr"; const char *wim_str = "%wim"; const char *tbr_str = "%tbr"; const char *name = inp->in_data.in_def.in_name;
*** 1390,1400 **** IMM_SIGNED); return (0); } /* synth: mov */ ! if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break; if (v9 == 0) { if (f->f3.rs1 == 0) { --- 1396,1406 ---- IMM_SIGNED); return (0); } /* synth: mov */ ! if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break; if (v9 == 0) { if (f->f3.rs1 == 0) {
*** 1462,1486 **** if (pr_rs2 != 0) { if (f->f3.i == 1) prt_imm(dhp, sign_extend(f->f3a.simm13, 13), IMM_SIGNED); else ! (void) strlcat(dhp->dh_buf, ! reg_names[f->f3.rs2], dhp->dh_buflen); ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); } ! (void) strlcat(dhp->dh_buf, regstr, dhp->dh_buflen); } return (0); } /* ARGSUSED3 */ int fmt_trap(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; int v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0); int p_rs1, p_t; --- 1468,1493 ---- if (pr_rs2 != 0) { if (f->f3.i == 1) prt_imm(dhp, sign_extend(f->f3a.simm13, 13), IMM_SIGNED); else ! (void) strlcat(dhx->dhx_buf, ! reg_names[f->f3.rs2], dhx->dhx_buflen); ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); } ! (void) strlcat(dhx->dhx_buf, regstr, dhx->dhx_buflen); } return (0); } /* ARGSUSED3 */ int fmt_trap(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0); int p_rs1, p_t;
*** 1495,1505 **** if (f->ftcc2.i == 0 && f->ftcc2.undef2 != 0) return (-1); p_rs1 = ((f->ftcc.rs1 != 0) || ! ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0)); if (f->ftcc.i == 0) { p_t = (f->f3.rs2 != 0 || p_rs1 == 0); bprintf(dhp, "%-9s %s%s%s%s%s", inp->in_data.in_def.in_name, --- 1502,1512 ---- if (f->ftcc2.i == 0 && f->ftcc2.undef2 != 0) return (-1); p_rs1 = ((f->ftcc.rs1 != 0) || ! ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0)); if (f->ftcc.i == 0) { p_t = (f->f3.rs2 != 0 || p_rs1 == 0); bprintf(dhp, "%-9s %s%s%s%s%s", inp->in_data.in_def.in_name,
*** 1553,1566 **** /* ARGSUSED3 */ static int prt_jmpl(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { const char *name = inp->in_data.in_def.in_name; ifmt_t *f = (ifmt_t *)&instr; ! if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)) name = "call"; if (f->f3.rd == 0) { if (f->f3.i == 1 && f->f3a.simm13 == 8) { if (f->f3.rs1 == 15) { --- 1560,1574 ---- /* ARGSUSED3 */ static int prt_jmpl(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; const char *name = inp->in_data.in_def.in_name; ifmt_t *f = (ifmt_t *)&instr; ! if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)) name = "call"; if (f->f3.rd == 0) { if (f->f3.i == 1 && f->f3a.simm13 == 8) { if (f->f3.rs1 == 15) {
*** 1581,1608 **** prt_address(dhp, instr, 1); if (f->f3.rd == 0) return (0); ! if (f->f3.rd == 15 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0)) return (0); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } int fmt_alu(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; const char *name = inp->in_data.in_def.in_name; int flags = inp->in_data.in_def.in_flags; int arg = 0; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("rs1", f->f3.rs1, 5); switch (idx) { --- 1589,1617 ---- prt_address(dhp, instr, 1); if (f->f3.rd == 0) return (0); ! if (f->f3.rd == 15 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0)) return (0); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } int fmt_alu(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char *name = inp->in_data.in_def.in_name; int flags = inp->in_data.in_def.in_flags; int arg = 0; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("rs1", f->f3.rs1, 5); switch (idx) {
*** 1621,1631 **** switch (idx) { case 0x00: /* add */ ! if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "inc"; --- 1630,1640 ---- switch (idx) { case 0x00: /* add */ ! if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "inc";
*** 1642,1656 **** break; case 0x02: /* or */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; ! if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) != 0) { if (f->f3.rs1 == f->f3.rd) { name = "bset"; flags = FLG_P1(REG_NONE); break; } --- 1651,1665 ---- break; case 0x02: /* or */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; ! if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) != 0) { if (f->f3.rs1 == f->f3.rd) { name = "bset"; flags = FLG_P1(REG_NONE); break; }
*** 1672,1682 **** break; case 0x04: /* sub */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 == 0 && f->f3.i == 0 && f->f3.rs2 == f->f3.rd) { name = "neg"; --- 1681,1691 ---- break; case 0x04: /* sub */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 == 0 && f->f3.i == 0 && f->f3.rs2 == f->f3.rd) { name = "neg";
*** 1688,1698 **** name = "neg"; flags = FLG_P1(REG_NONE); break; } ! if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "dec"; --- 1697,1707 ---- name = "neg"; flags = FLG_P1(REG_NONE); break; } ! if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "dec";
*** 1709,1719 **** break; case 0x07: /* xnor */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; /* * xnor -> not when you have: --- 1718,1728 ---- break; case 0x07: /* xnor */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; /* * xnor -> not when you have:
*** 1735,1745 **** break; case 0x10: /* addcc */ ! if ((dhp->dh_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "inccc"; --- 1744,1754 ---- break; case 0x10: /* addcc */ ! if ((dhx->dhx_debug & DIS_DEBUG_SYN_ALL) == 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "inccc";
*** 1759,1773 **** /* andcc */ if (f->f3.rd != 0) break; ! if ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break; ! if (((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) == 0)) break; name = "btst"; flags = FLG_P1(REG_NONE); --- 1768,1782 ---- /* andcc */ if (f->f3.rd != 0) break; ! if ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0) break; ! if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0) && ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) == 0)) break; name = "btst"; flags = FLG_P1(REG_NONE);
*** 1775,1785 **** break; case 0x12: /* orcc */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 == 0 && f->f3.rd == 0 && f->f3.i == 0) { name = "tst"; --- 1784,1794 ---- break; case 0x12: /* orcc */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 == 0 && f->f3.rd == 0 && f->f3.i == 0) { name = "tst";
*** 1796,1816 **** break; case 0x14: /* subcc */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rd == 0) { name = "cmp"; flags = FLG_P3(REG_NONE); break; } ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "deccc"; --- 1805,1825 ---- break; case 0x14: /* subcc */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rd == 0) { name = "cmp"; flags = FLG_P3(REG_NONE); break; } ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0) break; if (f->f3.rs1 == f->f3.rd && f->f3.i == 1 && f->f3a.simm13 == 1) { name = "deccc";
*** 1866,1883 **** return (0); case 0x3c: case 0x3d: /* save / restore */ ! if ((dhp->dh_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 != 0 || f->f3.rs2 != 0 || f->f3.rd != 0) break; ! if (f->f3.i != 0 && ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0)) break; prt_name(dhp, name, 0); return (0); } --- 1875,1892 ---- return (0); case 0x3c: case 0x3d: /* save / restore */ ! if ((dhx->dhx_debug & (DIS_DEBUG_SYN_ALL|DIS_DEBUG_COMPAT)) == 0) break; if (f->f3.rs1 != 0 || f->f3.rs2 != 0 || f->f3.rd != 0) break; ! if (f->f3.i != 0 && ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0)) break; prt_name(dhp, name, 0); return (0); }
*** 1917,1930 **** /* ARGSUSED3 */ int fmt_movcc(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; const char **regs = NULL; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3c.op, 2); prt_field("op3", f->f3c.op3, 6); prt_field("cond", f->f3c.cond, 4); prt_field("cc2", f->f3c.cc2, 1); prt_field("cc", f->f3c.cc, 2); --- 1926,1940 ---- /* ARGSUSED3 */ int fmt_movcc(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char **regs = NULL; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3c.op, 2); prt_field("op3", f->f3c.op3, 6); prt_field("cond", f->f3c.cond, 4); prt_field("cc2", f->f3c.cc2, 1); prt_field("cc", f->f3c.cc, 2);
*** 1951,1999 **** bprintf(dhp, "%s, ", regs[f->f3c.cc]); if (f->f3c.i == 1) prt_imm(dhp, sign_extend(f->f3c.simm11, 11), IMM_SIGNED); else ! (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2], ! dhp->dh_buflen); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } /* ARGSUSED3 */ int fmt_movr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; prt_name(dhp, inp->in_data.in_def.in_name, 1); bprintf(dhp, "%s, ", reg_names[f->f3d.rs1]); if (f->f3d.i == 1) prt_imm(dhp, sign_extend(f->f3d.simm10, 10), IMM_SIGNED); else ! (void) strlcat(dhp->dh_buf, reg_names[f->f3.rs2], ! dhp->dh_buflen); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } /* ARGSUSED3 */ int fmt_fpop1(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; int flags = inp->in_data.in_def.in_flags; flags |= FLG_NOIMM; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); prt_field("rs1", f->f3.rs1, 5); prt_field("rs2", f->f3.rs2, 5); --- 1961,2011 ---- bprintf(dhp, "%s, ", regs[f->f3c.cc]); if (f->f3c.i == 1) prt_imm(dhp, sign_extend(f->f3c.simm11, 11), IMM_SIGNED); else ! (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2], ! dhx->dhx_buflen); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } /* ARGSUSED3 */ int fmt_movr(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; prt_name(dhp, inp->in_data.in_def.in_name, 1); bprintf(dhp, "%s, ", reg_names[f->f3d.rs1]); if (f->f3d.i == 1) prt_imm(dhp, sign_extend(f->f3d.simm10, 10), IMM_SIGNED); else ! (void) strlcat(dhx->dhx_buf, reg_names[f->f3.rs2], ! dhx->dhx_buflen); bprintf(dhp, ", %s", reg_names[f->f3.rd]); return (0); } /* ARGSUSED3 */ int fmt_fpop1(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int flags = inp->in_data.in_def.in_flags; flags |= FLG_NOIMM; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); prt_field("rs1", f->f3.rs1, 5); prt_field("rs2", f->f3.rs2, 5);
*** 2017,2042 **** static const char *condstr_fcc[16] = { "n", "nz", "lg", "ul", "l", "ug", "g", "u", "a", "e", "ue", "ge", "uge", "le", "ule", "o" }; ifmt_t *f = (ifmt_t *)&instr; const char *ccstr = ""; char name[15]; int flags = inp->in_data.in_def.in_flags; int is_cmp = (idx == 0x51 || idx == 0x52 || idx == 0x53 || idx == 0x55 || idx == 0x56 || idx == 0x57); int is_fmov = (idx & 0x3f); int is_v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0); ! int is_compat = ((dhp->dh_debug & DIS_DEBUG_COMPAT) != 0); int p_cc = 0; is_fmov = (is_fmov == 0x1 || is_fmov == 0x2 || is_fmov == 0x3); ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); switch (idx & 0x3f) { --- 2029,2055 ---- static const char *condstr_fcc[16] = { "n", "nz", "lg", "ul", "l", "ug", "g", "u", "a", "e", "ue", "ge", "uge", "le", "ule", "o" }; + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char *ccstr = ""; char name[15]; int flags = inp->in_data.in_def.in_flags; int is_cmp = (idx == 0x51 || idx == 0x52 || idx == 0x53 || idx == 0x55 || idx == 0x56 || idx == 0x57); int is_fmov = (idx & 0x3f); int is_v9 = ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0); ! int is_compat = ((dhx->dhx_debug & DIS_DEBUG_COMPAT) != 0); int p_cc = 0; is_fmov = (is_fmov == 0x1 || is_fmov == 0x2 || is_fmov == 0x3); ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); switch (idx & 0x3f) {
*** 2102,2115 **** } int fmt_vis(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { ifmt_t *f = (ifmt_t *)&instr; int flags = inp->in_data.in_def.in_flags; ! if ((dhp->dh_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); if (idx == 0x081) { --- 2115,2129 ---- } int fmt_vis(dis_handle_t *dhp, uint32_t instr, const inst_t *inp, int idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int flags = inp->in_data.in_def.in_flags; ! if ((dhx->dhx_debug & DIS_DEBUG_PRTFMT) != 0) { prt_field("op", f->f3.op, 2); prt_field("op3", f->f3.op3, 6); prt_field("opf", f->fcmp.opf, 9); if (idx == 0x081) {
*** 2249,2258 **** --- 2263,2273 ---- * such as with the %icc/%xcc sets */ static const char * get_regname(dis_handle_t *dhp, int regset, uint32_t idx) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; const char *regname = NULL; switch (regset) { case REG_INT: regname = reg_names[idx];
*** 2261,2280 **** case REG_FP: regname = freg_names[idx]; break; case REG_FPD: ! if (((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) || ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) regname = fdreg_names[idx]; else regname = compat_fdreg_names[idx]; break; case REG_FPQ: ! if ((dhp->dh_debug & DIS_DEBUG_COMPAT) == 0) regname = fqreg_names[idx]; else regname = freg_names[idx]; break; --- 2276,2295 ---- case REG_FP: regname = freg_names[idx]; break; case REG_FPD: ! if (((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) || ((dhp->dh_flags & (DIS_SPARC_V9|DIS_SPARC_V9_SGI)) != 0)) regname = fdreg_names[idx]; else regname = compat_fdreg_names[idx]; break; case REG_FPQ: ! if ((dhx->dhx_debug & DIS_DEBUG_COMPAT) == 0) regname = fqreg_names[idx]; else regname = freg_names[idx]; break;
*** 2348,2362 **** * [%g0] is output */ static void prt_address(dis_handle_t *dhp, uint32_t instr, int nobrackets) { ifmt_t *f = (ifmt_t *)&instr; int32_t simm13; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! int p1 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0); ! int p2 = ((dhp->dh_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0); if (f->f3a.i == 0) { p1 |= ((f->f3a.rs1 != 0) || f->f3.rs2 == 0); p2 |= (f->f3.rs2 != 0); --- 2363,2378 ---- * [%g0] is output */ static void prt_address(dis_handle_t *dhp, uint32_t instr, int nobrackets) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; int32_t simm13; int octal = ((dhp->dh_flags & DIS_OCTAL) != 0); ! int p1 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0); ! int p2 = ((dhx->dhx_debug & (DIS_DEBUG_COMPAT|DIS_DEBUG_SYN_ALL)) == 0); if (f->f3a.i == 0) { p1 |= ((f->f3a.rs1 != 0) || f->f3.rs2 == 0); p2 |= (f->f3.rs2 != 0);
*** 2419,2428 **** --- 2435,2445 ---- * floating point operations */ static void prt_aluargs(dis_handle_t *dhp, uint32_t instr, uint32_t flags) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; ifmt_t *f = (ifmt_t *)&instr; const char *r1, *r2, *r3; int p1, p2, p3; unsigned int opf = 0;
*** 2445,2478 **** if ((f->fcmp.op == 2) && (f->fcmp.op3 == 0x36) && (f->fcmp.cc != 0)) opf = f->fcmp.opf; if ((opf == 0x151) || (opf == 0x152)) { ! (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen); ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); p3 = 0; } if (p1 != 0) { ! (void) strlcat(dhp->dh_buf, r1, dhp->dh_buflen); if (p2 != 0 || p3 != 0) ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); } if (p2 != 0) { if (f->f3.i == 0 || ((flags & FLG_NOIMM) != 0)) ! (void) strlcat(dhp->dh_buf, r2, dhp->dh_buflen); else prt_imm(dhp, sign_extend(f->f3a.simm13, 13), IMM_SIGNED); if (p3 != 0) ! (void) strlcat(dhp->dh_buf, ", ", dhp->dh_buflen); } if (p3 != 0) ! (void) strlcat(dhp->dh_buf, r3, dhp->dh_buflen); } static const char * get_asi_name(uint8_t asi) { --- 2462,2495 ---- if ((f->fcmp.op == 2) && (f->fcmp.op3 == 0x36) && (f->fcmp.cc != 0)) opf = f->fcmp.opf; if ((opf == 0x151) || (opf == 0x152)) { ! (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen); ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); p3 = 0; } if (p1 != 0) { ! (void) strlcat(dhx->dhx_buf, r1, dhx->dhx_buflen); if (p2 != 0 || p3 != 0) ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); } if (p2 != 0) { if (f->f3.i == 0 || ((flags & FLG_NOIMM) != 0)) ! (void) strlcat(dhx->dhx_buf, r2, dhx->dhx_buflen); else prt_imm(dhp, sign_extend(f->f3a.simm13, 13), IMM_SIGNED); if (p3 != 0) ! (void) strlcat(dhx->dhx_buf, ", ", dhx->dhx_buflen); } if (p3 != 0) ! (void) strlcat(dhx->dhx_buf, r3, dhx->dhx_buflen); } static const char * get_asi_name(uint8_t asi) {
*** 2740,2754 **** * PRINTF LIKE 1 */ static void bprintf(dis_handle_t *dhp, const char *fmt, ...) { size_t curlen; va_list ap; ! curlen = strlen(dhp->dh_buf); va_start(ap, fmt); ! (void) vsnprintf(dhp->dh_buf + curlen, dhp->dh_buflen - curlen, fmt, ! ap); va_end(ap); } --- 2757,2772 ---- * PRINTF LIKE 1 */ static void bprintf(dis_handle_t *dhp, const char *fmt, ...) { + dis_handle_sparc_t *dhx = dhp->dh_arch_private; size_t curlen; va_list ap; ! curlen = strlen(dhx->dhx_buf); va_start(ap, fmt); ! (void) dis_vsnprintf(dhx->dhx_buf + curlen, dhx->dhx_buflen - ! curlen, fmt, ap); va_end(ap); }