From 7b01c1cc1d111ba0afa51e60fa9842d3b971e2d1 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 4 Apr 2022 22:38:04 +0100 Subject: 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. --- sim/erc32/interf.c | 3 ++- sim/erc32/sis.c | 18 +++++++++++++++++- sim/erc32/sis.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'sim/erc32') diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c index d04d07c..78dec6f 100644 --- a/sim/erc32/interf.c +++ b/sim/erc32/interf.c @@ -244,7 +244,8 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback, #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 diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c index 66a27d0..12eb21f 100644 --- a/sim/erc32/sis.c +++ b/sim/erc32/sis.c @@ -139,6 +139,21 @@ run_sim(struct pstate *sregs, uint64_t icount, int dis) } 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) { @@ -212,7 +227,8 @@ 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 diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h index 33f16c7..3a27667 100644 --- a/sim/erc32/sis.h +++ b/sim/erc32/sis.h @@ -18,6 +18,7 @@ #include "sim/sim.h" #include #include +#include "dis-asm.h" #if HOST_BYTE_ORDER == BIG_ENDIAN #define HOST_BIG_ENDIAN @@ -203,6 +204,8 @@ extern void init_regs (struct pstate *sregs); /* 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); -- cgit v1.1