sim: rl78: rename open symbol to avoid collisions
[deliverable/binutils-gdb.git] / sim / rl78 / trace.c
index 12f78935f89fe4258be2db6355ef956bce8dcc0b..1b4b365af1e3b707d84d2dca6c412e0ed8281762 100644 (file)
@@ -1,7 +1,6 @@
 /* trace.c --- tracing output for the RL78 simulator.
 
-   Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011
-   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.
@@ -20,8 +19,9 @@
    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>
@@ -37,6 +37,9 @@
 #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,
@@ -112,6 +115,7 @@ void
 sim_disasm_init (bfd *prog)
 {
   current_bfd = prog;
+  rl78_disasm_fn = NULL;
 }
 
 typedef struct Files
@@ -136,6 +140,8 @@ load_file_and_line (const char *filename, int lineno)
       int i;
       struct stat s;
       const char *found_filename, *slash;
+      FILE *file;
+      size_t ret;
 
       found_filename = filename;
       while (1)
@@ -153,9 +159,9 @@ load_file_and_line (const char *filename, int lineno)
       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;
@@ -222,7 +228,7 @@ sim_get_current_source_location (const char **  pfilename,
          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;
            }
        }
@@ -257,6 +263,18 @@ sim_disasm_one (void)
 
   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))
@@ -324,7 +342,7 @@ sim_disasm_one (void)
   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));
This page took 0.026358 seconds and 4 git commands to generate.