/* trace.c --- tracing output for the RL78 simulator.
- Copyright (C) 2005-2013 Free Software Foundation, Inc.
+ Copyright (C) 2005-2021 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of the GNU simulators.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* This must come before any other includes. */
+#include "defs.h"
-#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "cpu.h"
#include "mem.h"
#include "load.h"
+#include "trace.h"
+
+static disassembler_ftype rl78_disasm_fn = NULL;
static int
sim_dis_read (bfd_vma memaddr, bfd_byte * ptr, unsigned int length,
sim_disasm_init (bfd *prog)
{
current_bfd = prog;
+ rl78_disasm_fn = NULL;
}
typedef struct Files
int i;
struct stat s;
const char *found_filename, *slash;
+ FILE *file;
+ size_t ret;
found_filename = filename;
while (1)
files = f;
f->filename = xstrdup (filename);
f->data = (char *) xmalloc (s.st_size + 2);
- FILE *file = fopen (found_filename, "rb");
- fread (f->data, 1, s.st_size, file);
- f->data[s.st_size] = 0;
+ file = fopen (found_filename, "rb");
+ ret = fread (f->data, 1, s.st_size, file);
+ f->data[ret] = 0;
fclose (file);
f->nlines = 1;
if (s->flags & SEC_CODE || code_section == 0)
{
code_section = s;
- code_base = bfd_section_lma (current_bfd, s);
+ code_base = bfd_section_lma (s);
break;
}
}
trace = 0;
+ if (!rl78_disasm_fn)
+ {
+ if (rl78_g10_mode)
+ rl78_disasm_fn = print_insn_rl78_g10;
+ else if (g14_multiply)
+ rl78_disasm_fn = print_insn_rl78_g14;
+ else if (g13_multiply)
+ rl78_disasm_fn = print_insn_rl78_g13;
+ else
+ rl78_disasm_fn = print_insn_rl78;
+ }
+
if (filename && functionname && lineno)
{
if (lineno != prev_lineno || strcmp (prev_filename, filename))
printf ("\033[33m %08llx %06x: ", total_clocks, mypc);
#endif
- max = print_insn_rl78 (mypc, & info);
+ max = rl78_disasm_fn (mypc, & info);
for (i = 0; i < max; i ++)
printf ("%02x", mem_get_qi (mypc + i));