return ret;
}
+static int ATTRIBUTE_PRINTF (3, 4)
+op_styled_printf (char *buf, enum disassembler_style style,
+ const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = vsprintf (opbuf + strlen (opbuf), fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
static int
sim_dis_read (bfd_vma memaddr ATTRIBUTE_UNUSED,
bfd_byte * ptr,
}
memset (& info, 0, sizeof (info));
- INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
+ INIT_DISASSEMBLE_INFO (info, stdout, op_printf, op_styled_printf);
info.read_memory_func = sim_dis_read;
info.arch = bfd_get_arch (abfd);
info.mach = bfd_get_mach (abfd);
return n;
}
+/* sprintf to a "stream" with styling. */
+
+int
+sim_disasm_styled_sprintf (SFILE *f, enum disassembler_style style,
+ const char *format, ...)
+{
+ int n;
+ va_list args;
+
+ va_start (args, format);
+ vsprintf (f->current, format, args);
+ f->current += n = strlen (f->current);
+ va_end (args);
+ return n;
+}
+
/* Memory read support for an opcodes disassembler. */
int
sfile.buffer = sfile.current = buf;
INIT_DISASSEMBLE_INFO (disasm_info, (FILE *) &sfile,
- (fprintf_ftype) sim_disasm_sprintf);
+ (fprintf_ftype) sim_disasm_sprintf,
+ (fprintf_styled_ftype) sim_disasm_styled_sprintf);
disasm_info.endian =
(bfd_big_endian (STATE_PROG_BFD (sd)) ? BFD_ENDIAN_BIG
: bfd_little_endian (STATE_PROG_BFD (sd)) ? BFD_ENDIAN_LITTLE
/* String printer for the disassembler. */
extern int sim_disasm_sprintf (SFILE *, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern int sim_disasm_styled_sprintf (SFILE *, enum disassembler_style, const char *, ...) ATTRIBUTE_PRINTF_3;
/* For opcodes based disassemblers. */
#ifdef __BFD_H_SEEN__
return 0;
}
+static int ATTRIBUTE_PRINTF (3, 4)
+dis_styled_printf (SIM_CPU *cpu, enum disassembler_style style,
+ const char *fmt, ...)
+{
+ SIM_DESC sd = CPU_STATE (cpu);
+ va_list ap;
+ va_start (ap, fmt);
+ trace_vprintf (sd, cpu, fmt, ap);
+ va_end (ap);
+ return 0;
+}
+
void
trace_disasm (SIM_DESC sd, sim_cpu *cpu, address_word addr)
{
bfd_big_endian (trace_data->dis_bfd),
bfd_get_mach (trace_data->dis_bfd),
trace_data->dis_bfd);
- INIT_DISASSEMBLE_INFO (*info, cpu, dis_printf);
+ INIT_DISASSEMBLE_INFO (*info, cpu, dis_printf, dis_styled_printf);
info->read_memory_func = dis_read;
info->arch = bfd_get_arch (bfd);
info->mach = bfd_get_mach (bfd);
sfile.buffer = sfile.current = buf;
INIT_DISASSEMBLE_INFO (disasm_info, (FILE *) &sfile,
- (fprintf_ftype) sim_disasm_sprintf);
+ (fprintf_ftype) sim_disasm_sprintf,
+ (fprintf_styled_ftype) sim_disasm_styled_sprintf);
disasm_info.endian = BFD_ENDIAN_LITTLE;
disasm_info.read_memory_func = sim_disasm_read_memory;
disasm_info.memory_error_func = sim_disasm_perror_memory;
#ifdef F_GETFL
termsave = fcntl(0, F_GETFL, 0);
#endif
- INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
+ INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf,
+ fprintf_styled);
#ifdef HOST_LITTLE_ENDIAN
dinfo.endian = BFD_ENDIAN_LITTLE;
#else
return TIME_OUT;
}
+int
+fprintf_styled (void *stream, enum disassembler_style style,
+ const char *fmt, ...)
+{
+ int ret;
+ FILE *out = (FILE *) stream;
+ va_list args;
+
+ va_start (args, fmt);
+ ret = vfprintf (out, fmt, args);
+ va_end (args);
+
+ return ret;
+}
+
int
main(int argc, char **argv)
{
#endif
sregs.freq = freq;
- INIT_DISASSEMBLE_INFO(dinfo, stdout, (fprintf_ftype) fprintf);
+ INIT_DISASSEMBLE_INFO(dinfo, stdout, (fprintf_ftype) fprintf,
+ (fprintf_styled_ftype) fprintf_styled);
#ifdef HOST_LITTLE_ENDIAN
dinfo.endian = BFD_ENDIAN_LITTLE;
#else
#include "sim/sim.h"
#include <sim-config.h>
#include <stdint.h>
+#include "dis-asm.h"
#if HOST_BYTE_ORDER == BIG_ENDIAN
#define HOST_BIG_ENDIAN
/* interf.c */
extern int run_sim (struct pstate *sregs,
uint64_t icount, int dis);
+extern int fprintf_styled (void *stream, enum disassembler_style style,
+ const char *fmt, ...) ATTRIBUTE_PRINTF (3, 4);
/* float.c */
extern int get_accex (void);
return ret;
}
+static int
+op_styled_printf (char *buf, enum disassembler_style style, char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = vsprintf (opbuf + strlen (opbuf), fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
static bfd *current_bfd;
void
{
initted = 1;
memset (&info, 0, sizeof (info));
- INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
+ INIT_DISASSEMBLE_INFO (info, stdout, op_printf, op_styled_printf);
info.read_memory_func = sim_dis_read;
info.arch = bfd_get_arch (current_bfd);
info.mach = bfd_get_mach (current_bfd);
return ret;
}
+static int
+op_styled_printf (char *buf, enum disassembler_style style, char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = vsprintf (opbuf + strlen (opbuf), fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
static bfd * current_bfd = NULL;
static asymbol ** symtab = NULL;
static int symcount = 0;
initted = 1;
memset (& info, 0, sizeof (info));
- INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
+ INIT_DISASSEMBLE_INFO (info, stdout, op_printf, op_styled_printf);
info.read_memory_func = sim_dis_read;
info.arch = bfd_get_arch (current_bfd);
info.mach = bfd_get_mach (current_bfd);
return ret;
}
+static int ATTRIBUTE_PRINTF (3, 4)
+op_styled_printf (char *buf, enum disassembler_style style, char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = vsprintf (opbuf + strlen (opbuf), fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
static bfd * current_bfd = NULL;
static asymbol ** symtab = NULL;
static int symcount = 0;
initted = 1;
memset (& info, 0, sizeof (info));
- INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
+ INIT_DISASSEMBLE_INFO (info, stdout, op_printf, op_styled_printf);
info.read_memory_func = sim_dis_read;
info.arch = bfd_get_arch (current_bfd);
info.mach = bfd_get_mach (current_bfd);