gdb: Convert language la_watch_location_expression field to a method
[deliverable/binutils-gdb.git] / sim / lm32 / sim-if.c
index 364fc7d8982d5de0eb538a67231383270648ff88..9e868981641b2636d9a2e7ed01aee5fb6ca02073 100644 (file)
@@ -1,7 +1,7 @@
 /* Main simulator entry points specific to Lattice Mico32.
    Contributed by Jon Beniston <jon@beniston.com>
    
-   Copyright (C) 2009-2016 Free Software Foundation, Inc.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-
-static void free_state (SIM_DESC);
-static void print_lm32_misc_cpu (SIM_CPU * cpu, int verbose);
-static DECLARE_OPTION_HANDLER (lm32_option_handler);
-
-enum
-{
-  OPTION_ENDIAN = OPTION_START,
-};
-
-/* GDB passes -E, even though it's fixed, so we have to handle it here. common code only handles it if SIM_HAVE_BIENDIAN is defined, which it isn't for lm32.  */
-static const OPTION lm32_options[] = {
-  {{"endian", required_argument, NULL, OPTION_ENDIAN},
-   'E', "big", "Set endianness",
-   lm32_option_handler},
-  {{NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL}
-};
-
-/* Records simulator descriptor so utilities like lm32_dump_regs can be
-   called from gdb.  */
-SIM_DESC current_state;
 \f
 /* Cover function of sim_state_free to free the cpu buffers as well.  */
 
@@ -71,61 +50,33 @@ find_base (bfd *prog_bfd)
   found = 0;
   for (s = prog_bfd->sections; s; s = s->next)
     {
-      if ((strcmp (bfd_get_section_name (prog_bfd, s), ".boot") == 0)
-         || (strcmp (bfd_get_section_name (prog_bfd, s), ".text") == 0)
-         || (strcmp (bfd_get_section_name (prog_bfd, s), ".data") == 0)
-         || (strcmp (bfd_get_section_name (prog_bfd, s), ".bss") == 0))
+      if ((strcmp (bfd_section_name (s), ".boot") == 0)
+         || (strcmp (bfd_section_name (s), ".text") == 0)
+         || (strcmp (bfd_section_name (s), ".data") == 0)
+         || (strcmp (bfd_section_name (s), ".bss") == 0))
        {
          if (!found)
            {
-             base = bfd_get_section_vma (prog_bfd, s);
+             base = bfd_section_vma (s);
              found = 1;
            }
          else
-           base =
-             bfd_get_section_vma (prog_bfd,
-                                  s) < base ? bfd_get_section_vma (prog_bfd,
-                                                                   s) : base;
+           base = bfd_section_vma (s) < base ? bfd_section_vma (s) : base;
        }
     }
   return base & ~(0xffffUL);
 }
 
 static unsigned long
-find_limit (bfd *prog_bfd)
+find_limit (SIM_DESC sd)
 {
-  struct bfd_symbol **asymbols;
-  long symsize;
-  long symbol_count;
-  long s;
+  bfd_vma addr;
 
-  symsize = bfd_get_symtab_upper_bound (prog_bfd);
-  if (symsize < 0)
-    return 0;
-  asymbols = (asymbol **) xmalloc (symsize);
-  symbol_count = bfd_canonicalize_symtab (prog_bfd, asymbols);
-  if (symbol_count < 0)
+  addr = trace_sym_value (sd, "_fstack");
+  if (addr == -1)
     return 0;
 
-  for (s = 0; s < symbol_count; s++)
-    {
-      if (!strcmp (asymbols[s]->name, "_fstack"))
-       return (asymbols[s]->value + 65536) & ~(0xffffUL);
-    }
-  return 0;
-}
-
-/* Handle lm32 specific options.  */
-
-static SIM_RC
-lm32_option_handler (sd, cpu, opt, arg, is_command)
-     SIM_DESC sd;
-     sim_cpu *cpu;
-     int opt;
-     char *arg;
-     int is_command;
-{
-  return SIM_RC_OK;
+  return (addr + 65536) & ~(0xffffUL);
 }
 
 /* Create an instance of the simulator.  */
@@ -135,7 +86,7 @@ sim_open (kind, callback, abfd, argv)
      SIM_OPEN_KIND kind;
      host_callback *callback;
      struct bfd *abfd;
-     char **argv;
+     char * const *argv;
 {
   SIM_DESC sd = sim_state_alloc (kind, callback);
   char c;
@@ -154,11 +105,8 @@ sim_open (kind, callback, abfd, argv)
       free_state (sd);
       return 0;
     }
-  sim_add_option_table (sd, NULL, lm32_options);
 
-  /* getopt will print the error message so we just have to exit if this fails.
-     FIXME: Hmmm...  in the case of gdb we need getopt to call
-     print_filtered.  */
+  /* The parser will print an error message for us, so we silently return.  */
   if (sim_parse_args (sd, argv) != SIM_RC_OK)
     {
       free_state (sd);
@@ -196,7 +144,7 @@ sim_open (kind, callback, abfd, argv)
        {
          /* It doesn't, so we should try to allocate enough memory to hold program.  */
          base = find_base (STATE_PROG_BFD (sd));
-         limit = find_limit (STATE_PROG_BFD (sd));
+         limit = find_limit (sd);
          if (limit == 0)
            {
              sim_io_eprintf (sd,
@@ -240,10 +188,6 @@ sim_open (kind, callback, abfd, argv)
      Must be done after lm32_cgen_cpu_open.  */
   cgen_init (sd);
 
-  /* Store in a global so things like lm32_dump_regs can be invoked
-     from the gdb command line.  */
-  current_state = sd;
-
   return sd;
 }
 \f
@@ -251,8 +195,8 @@ SIM_RC
 sim_create_inferior (sd, abfd, argv, envp)
      SIM_DESC sd;
      struct bfd *abfd;
-     char **argv;
-     char **envp;
+     char * const *argv;
+     char * const *envp;
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
This page took 0.025558 seconds and 4 git commands to generate.