gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / or1k-tdep.c
index 54b365e9586215cb1cd5d7bccdc7338f3520734f..75df206a2bd409eeebef9074cbbac842d08b80be 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-dependent code for the 32-bit OpenRISC 1000, for the GDB.
-   Copyright (C) 2008-2017 Free Software Foundation, Inc.
+   Copyright (C) 2008-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "block.h"
 #include "reggroups.h"
 #include "arch-utils.h"
-#include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
-#include "dwarf2-frame.h"
+#include "dwarf2/frame.h"
 #include "trad-frame.h"
 #include "regset.h"
 #include "remote.h"
 
 /* Global debug flag.  */
 
-static int or1k_debug = 0;
+static bool or1k_debug = false;
 
 static void
 show_or1k_debug (struct ui_file *file, int from_tty,
-                 struct cmd_list_element *c, const char *value)
+                struct cmd_list_element *c, const char *value)
 {
   fprintf_filtered (file, _("OpenRISC debugging is %s.\n"), value);
 }
@@ -132,8 +131,8 @@ or1k_analyse_inst (uint32_t inst, const char *format, ...)
 
          /* Check we got something, and if so skip on.  */
          if (start_ptr == end_ptr)
-           error ("bitstring \"%s\" at offset %d has no length field.\n",
-                       format, i);
+           error (_("bitstring \"%s\" at offset %d has no length field."),
+                  format, i);
 
          i += end_ptr - start_ptr;
 
@@ -141,8 +140,8 @@ or1k_analyse_inst (uint32_t inst, const char *format, ...)
             still give a fatal error, because these are fixed strings that
             just should not be wrong.  */
          if ('b' != format[i++])
-           error ("bitstring \"%s\" at offset %d has no terminating 'b'.\n",
-                       format, i);
+           error (_("bitstring \"%s\" at offset %d has no terminating 'b'."),
+                  format, i);
 
          /* Break out the field.  There is a special case with a bit width
             of 32.  */
@@ -158,8 +157,8 @@ or1k_analyse_inst (uint32_t inst, const char *format, ...)
          break;
 
        default:
-         error ("invalid character in bitstring \"%s\" at offset %d.\n",
-                     format, i);
+         error (_("invalid character in bitstring \"%s\" at offset %d."),
+                format, i);
          break;
        }
     }
@@ -246,7 +245,7 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype,
                   gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  enum type_code rv_type = TYPE_CODE (valtype);
+  enum type_code rv_type = valtype->code ();
   unsigned int rv_size = TYPE_LENGTH (valtype);
   int bpw = (gdbarch_tdep (gdbarch))->bytes_per_word;
 
@@ -297,7 +296,7 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype,
          else
            memcpy (buf, writebuf, rv_size);
 
-         regcache_cooked_write (regcache, OR1K_RV_REGNUM, buf);
+         regcache->cooked_write (OR1K_RV_REGNUM, buf);
 
          free (buf);
        }
@@ -330,8 +329,8 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype,
          memcpy (buf_hi, writebuf, rv_size - bpw);
          memcpy (buf_lo, writebuf + bpw, bpw);
 
-         regcache_cooked_write (regcache, OR1K_RV_REGNUM, buf_hi);
-         regcache_cooked_write (regcache, OR1K_RV_REGNUM + 1, buf_lo);
+         regcache->cooked_write (OR1K_RV_REGNUM, buf_hi);
+         regcache->cooked_write (OR1K_RV_REGNUM + 1, buf_lo);
 
          free (buf_lo);
          free (buf_hi);
@@ -372,9 +371,9 @@ or1k_single_step_through_delay (struct gdbarch *gdbarch,
     return 0;
 
   insn = cgen_lookup_insn (tdep->gdb_cgen_cpu_desc,
-                           NULL,
-                           or1k_fetch_instruction (gdbarch, ppc),
-                           NULL, 32, &tmp_fields, 0);
+                          NULL,
+                          or1k_fetch_instruction (gdbarch, ppc),
+                          NULL, 32, &tmp_fields, 0);
 
   /* NULL here would mean the last instruction was not understood by cgen.
      This should not usually happen, but if does its not a delay slot.  */
@@ -541,8 +540,8 @@ or1k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
   pc = frame_unwind_register_unsigned (next_frame, OR1K_NPC_REGNUM);
 
   if (or1k_debug)
-    fprintf_unfiltered (gdb_stdlog, "or1k_unwind_pc, pc=0x%p\n",
-                       (void *) pc);
+    fprintf_unfiltered (gdb_stdlog, "or1k_unwind_pc, pc=%s\n",
+                       paddress (gdbarch, pc));
 
   return pc;
 }
@@ -561,8 +560,8 @@ or1k_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
   sp = frame_unwind_register_unsigned (next_frame, OR1K_SP_REGNUM);
 
   if (or1k_debug)
-    fprintf_unfiltered (gdb_stdlog, "or1k_unwind_sp, sp=0x%p\n",
-                       (void *) sp);
+    fprintf_unfiltered (gdb_stdlog, "or1k_unwind_sp, sp=%s\n",
+                       paddress (gdbarch, sp));
 
   return sp;
 }
@@ -595,7 +594,8 @@ static CORE_ADDR
 or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr,
                      int nargs, struct value **args, CORE_ADDR sp,
-                     int struct_return, CORE_ADDR struct_addr)
+                     function_call_return_method return_method,
+                     CORE_ADDR struct_addr)
 {
 
   int argreg;
@@ -617,7 +617,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   /* Location for a returned structure.  This is passed as a silent first
      argument.  */
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       regcache_cooked_write_unsigned (regcache, OR1K_FIRST_ARG_REGNUM,
                                      struct_addr);
@@ -633,9 +633,9 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
       int len = TYPE_LENGTH (arg_type);
-      enum type_code typecode = TYPE_CODE (arg_type);
+      enum type_code typecode = arg_type->code ();
 
-      if (TYPE_VARARGS (func_type) && argnum >= TYPE_NFIELDS (func_type))
+      if (TYPE_VARARGS (func_type) && argnum >= func_type->num_fields ())
        break; /* end or regular args, varargs go to stack.  */
 
       /* Extract the value, either a reference or the data.  */
@@ -723,7 +723,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
       int len = TYPE_LENGTH (arg_type);
-      enum type_code typecode = TYPE_CODE (arg_type);
+      enum type_code typecode = arg_type->code ();
 
       if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
          || (len > bpw * 2))
@@ -755,7 +755,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
       int len = TYPE_LENGTH (arg_type);
-      enum type_code typecode = TYPE_CODE (arg_type);
+      enum type_code typecode = arg_type->code ();
       /* The EABI passes structures that do not fit in a register by
          reference.  In all other cases, pass the structure by value.  */
       if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
@@ -789,14 +789,6 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   return sp;
 }
 
-/* Implement the dummy_id gdbarch method.  */
-
-static struct frame_id
-or1k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  return frame_id_build (get_frame_sp (this_frame),
-                        get_frame_pc (this_frame));
-}
 \f
 
 /* Support functions for frame handling.  */
@@ -832,7 +824,7 @@ or1k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
    l.sw    lr_loc(r1),r9        # Link (return) address
 
-   The link register is usally saved at fp_loc - 4.  It may not be saved at
+   The link register is usually saved at fp_loc - 4.  It may not be saved at
    all in a leaf function.
 
    l.sw    reg_loc(r1),ry       # Save any callee saved regs
@@ -882,8 +874,8 @@ or1k_frame_cache (struct frame_info *this_frame, void **prologue_cache)
 
   if (or1k_debug)
     fprintf_unfiltered (gdb_stdlog,
-                       "or1k_frame_cache, prologue_cache = 0x%p\n",
-                       *prologue_cache);
+                       "or1k_frame_cache, prologue_cache = %s\n",
+                       host_address_to_string (*prologue_cache));
 
   /* Nothing to do if we already have this info.  */
   if (NULL != *prologue_cache)
@@ -942,8 +934,8 @@ or1k_frame_cache (struct frame_info *this_frame, void **prologue_cache)
      have executed the code.  Check we have a sane prologue size, and if
      zero we are frameless and can give up here.  */
   if (end_addr < start_addr)
-    error ("end addr 0x%08x is less than start addr 0x%08x\n",
-               (unsigned int) end_addr, (unsigned int) start_addr);
+    error (_("end addr %s is less than start addr %s"),
+          paddress (gdbarch, end_addr), paddress (gdbarch, start_addr));
 
   if (end_addr == start_addr)
     frame_size = 0;
@@ -1068,10 +1060,10 @@ or1k_frame_cache (struct frame_info *this_frame, void **prologue_cache)
 
   if (or1k_debug)
     {
-      fprintf_unfiltered (gdb_stdlog, "  this_sp_for_id = 0x%p\n",
-                         (void *) this_sp_for_id);
-      fprintf_unfiltered (gdb_stdlog, "  start_addr     = 0x%p\n",
-                         (void *) start_addr);
+      fprintf_unfiltered (gdb_stdlog, "  this_sp_for_id = %s\n",
+                         paddress (gdbarch, this_sp_for_id));
+      fprintf_unfiltered (gdb_stdlog, "  start_addr     = %s\n",
+                         paddress (gdbarch, start_addr));
     }
 
   return info;
@@ -1184,7 +1176,6 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
   set_gdbarch_push_dummy_code (gdbarch, or1k_push_dummy_code);
   set_gdbarch_push_dummy_call (gdbarch, or1k_push_dummy_call);
-  set_gdbarch_dummy_id (gdbarch, or1k_dummy_id);
 
   /* Frame unwinders.  Use DWARF debug info if available, otherwise use our
      own unwinder.  */
@@ -1255,6 +1246,9 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       tdesc_use_registers (gdbarch, tdesc, tdesc_data);
     }
 
+  /* Hook in ABI-specific overrides, if they have been registered.  */
+  gdbarch_init_osabi (info, gdbarch);
+
   return gdbarch;
 }
 
@@ -1275,8 +1269,9 @@ or1k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 }
 \f
 
+void _initialize_or1k_tdep ();
 void
-_initialize_or1k_tdep (void)
+_initialize_or1k_tdep ()
 {
   /* Register this architecture.  */
   gdbarch_register (bfd_arch_or1k, or1k_gdbarch_init, or1k_dump_tdep);
This page took 0.028612 seconds and 4 git commands to generate.