aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-04-04 22:38:04 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-04-04 22:41:24 +0100
commit7b01c1cc1d111ba0afa51e60fa9842d3b971e2d1 (patch)
treeba53406de8080613704aa3247a77dd9a360e1521 /sim/common
parent0578e87f93b09e4cc41d3982eb1672bcfc81042d (diff)
downloadbinutils-7b01c1cc1d111ba0afa51e60fa9842d3b971e2d1.zip
binutils-7b01c1cc1d111ba0afa51e60fa9842d3b971e2d1.tar.gz
binutils-7b01c1cc1d111ba0afa51e60fa9842d3b971e2d1.tar.bz2
sim: fixes for libopcodes styled disassembler
In commit: commit 60a3da00bd5407f07d64dff82a4dae98230dfaac Date: Sat Jan 22 11:38:18 2022 +0000 objdump/opcodes: add syntax highlighting to disassembler output I broke several sim/ targets by forgetting to update their uses of the libopcodes disassembler to take account of the new styled printing. These should all be fixed by this commit. I've not tried to add actual styled output to the simulator traces, instead, the styled print routines just ignore the style and print the output unstyled.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/cgen-trace.c19
-rw-r--r--sim/common/cgen-trace.h1
-rw-r--r--sim/common/sim-trace.c14
3 files changed, 32 insertions, 2 deletions
diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index 149ea8a..12f6126 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -320,6 +320,22 @@ sim_disasm_sprintf (SFILE *f, const char *format, ...)
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
@@ -383,7 +399,8 @@ sim_cgen_disassemble_insn (SIM_CPU *cpu, const CGEN_INSN *insn,
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
diff --git a/sim/common/cgen-trace.h b/sim/common/cgen-trace.h
index 84b4935..3e2b4a9 100644
--- a/sim/common/cgen-trace.h
+++ b/sim/common/cgen-trace.h
@@ -78,6 +78,7 @@ typedef struct {
/* 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__
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index 0b63bdb..952c351 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -906,6 +906,18 @@ dis_printf (SIM_CPU *cpu, const char *fmt, ...)
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)
{
@@ -922,7 +934,7 @@ 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);