s390_decode_special_and_irgen(bytes + S390_SPECIAL_OP_PREAMBLE_SIZE);
} else {
/* Handle normal instructions. */
- if (UNLIKELY(vex_traceflags & VEX_TRACE_FE))
- s390_disasm(bytes);
+ if (UNLIKELY(vex_traceflags & VEX_TRACE_FE)) {
+ HChar *str = s390_disasm(bytes, /* padmnm */ 1);
+ vex_printf("%s\n", str ? str : "disassembly failed");
+ }
switch (insn_length) {
case 2:
vex_printf(" ");
vex_printf("%02x%02x", bytes[i], bytes[i + 1]);
}
+ if (status == S390_DECODE_UNIMPLEMENTED_INSN ||
+ status == S390_DECODE_SPECIFICATION_EXCEPTION) {
+ const HChar *str = s390_disasm(bytes, /* padmnm */ 0);
+ vex_printf(" %s", str == NULL ? "??????" : str);
+ }
vex_printf("\n");
}
static __inline__ UChar *
emit(UChar *p, const UChar *insn, UInt len)
{
- if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
- s390_disasm(insn);
+ if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) {
+ HChar *str = s390_disasm(insn, /* padmnm */ 1);
+ vex_printf("%s\n", str ? str : "disassembly failed");
+ }
return (UChar *)__builtin_memcpy(p, insn, len) + len;
}
static int current_arch_mask = 0;
static int option_use_insn_len_bits_p = 0;
static int option_print_insn_desc = 0;
-
+static int pad_mnemonic;
static const char *
padmnm(const char *mnm)
{
static char buf[S390_MAX_MNEMONIC_LEN + 1];
- if (vex_strlen(mnm) > S390_MAX_MNEMONIC_LEN)
- return "failed: buf too small";
+ if (pad_mnemonic) {
+ if (vex_strlen(mnm) > S390_MAX_MNEMONIC_LEN)
+ return "failed: buf too small";
- vex_sprintf(buf, "%-*s", S390_MAX_MNEMONIC_LEN, mnm);
+ vex_sprintf(buf, "%-*s", S390_MAX_MNEMONIC_LEN, mnm);
+ } else {
+ vex_sprintf(buf, "%s", mnm);
+ }
return buf;
}
}
-void
-s390_disasm(const unsigned char insn[])
+/* Watch out: returned string is allocated in a static buffer and will
+ be overwritten in the next invocation. */
+HChar *
+s390_disasm(const unsigned char insn[], int pad_mnm)
{
static int initialised = 0;
static SFILE disasm;
s390_disasm_init(&disasm, vex_vsprintf);
}
+ pad_mnemonic = pad_mnm;
disasm.pos = 0; /* reset */
disasm.buf[0] = '\0';
the current address: .+offset of .-offset */
int rc = print_insn_s390(/* address */ 0, insn, disasm.info);
- vex_printf("%s\n", (rc == 0) ? "disassemly failed" : disasm.buf);
+ return rc == 0 ? NULL : disasm.buf;
}
#include "libvex_basictypes.h"
-void s390_disasm(const UChar *);
+HChar *s390_disasm(const UChar *, Int);
/*---------------------------------------------------------------*/
/*--- end s390_disasm.h ---*/