PR ld/21334: Always call `_bfd_elf_link_renumber_dynsyms' if required
[deliverable/binutils-gdb.git] / gdb / mt-tdep.c
index ee98d3d25caf39a4143f1fea90cfa75d32f4ecb0..1f94b017e7975eb06a95f00ff1b86e2a7fd61a29 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for Morpho mt processor, for GDB.
 
-   Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2005-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,7 +27,6 @@
 #include "dis-asm.h"
 #include "arch-utils.h"
 #include "gdbtypes.h"
-#include "gdb_string.h"
 #include "regcache.h"
 #include "reggroups.h"
 #include "gdbcore.h"
@@ -36,7 +34,6 @@
 #include "inferior.h"
 #include "dwarf2-frame.h"
 #include "infcall.h"
-#include "gdb_assert.h"
 #include "language.h"
 #include "valprint.h"
 
@@ -203,7 +200,7 @@ mt_register_name (struct gdbarch *gdbarch, int regnum)
        array_names[regnum] = stub;
        return stub;
       }
-    name = xmalloc (30);
+    name = (char *) xmalloc (30);
     sprintf (name, "copro_%d_%d_%s", dim_1, dim_2, stub);
     array_names[regnum] = name;
     return name;
@@ -336,7 +333,7 @@ mt_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
    values.  */
 
 static enum return_value_convention
-mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
+mt_return_value (struct gdbarch *gdbarch, struct value *function,
                 struct type *type, struct regcache *regcache,
                 gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -409,7 +406,7 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
-  char *func_name;
+  const char *func_name;
   unsigned long instr;
 
   if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
@@ -418,7 +415,7 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
       struct symbol *sym;
 
       /* Found a function.  */
-      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
+      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
       if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
        {
          /* Don't use this trick for assembly source files.  */
@@ -452,23 +449,32 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   return pc;
 }
 
-/* The breakpoint instruction must be the same size as the smallest
-   instruction in the instruction set.
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
 
-   The BP for ms1 is defined as 0x68000000 (BREAK).
-   The BP for ms2 is defined as 0x69000000 (illegal).  */
+static int
+mt_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+{
+  return 4;
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
 
 static const gdb_byte *
-mt_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
-                      int *bp_size)
+mt_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
+  /* The breakpoint instruction must be the same size as the smallest
+     instruction in the instruction set.
+
+     The BP for ms1 is defined as 0x68000000 (BREAK).
+     The BP for ms2 is defined as 0x69000000 (illegal).  */
   static gdb_byte ms1_breakpoint[] = { 0x68, 0, 0, 0 };
   static gdb_byte ms2_breakpoint[] = { 0x69, 0, 0, 0 };
 
-  *bp_size = 4;
+  *size = kind;
+
   if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
     return ms2_breakpoint;
-  
+
   return ms1_breakpoint;
 }
 
@@ -679,14 +685,13 @@ mt_registers_info (struct gdbarch *gdbarch,
        {
          /* Special output handling for 38-bit context register.  */
          unsigned char *buff;
-         unsigned int *bytes, i, regsize;
+         unsigned int i, regsize;
 
          regsize = register_size (gdbarch, regnum);
 
-         buff = alloca (regsize);
-         bytes = alloca (regsize * sizeof (*bytes));
+         buff = (unsigned char *) alloca (regsize);
 
-         frame_register_read (frame, regnum, buff);
+         deprecated_frame_register_read (frame, regnum, buff);
 
          fputs_filtered (gdbarch_register_name
                          (gdbarch, regnum), file);
@@ -707,11 +712,10 @@ mt_registers_info (struct gdbarch *gdbarch,
                || regnum == MT_COPRO_PSEUDOREG_REGNUM)
        {
          /* Special output handling for the 'coprocessor' register.  */
-         gdb_byte *buf;
          struct value_print_options opts;
+         struct value *val;
 
-         buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
-         frame_register_read (frame, MT_COPRO_REGNUM, buf);
+         val = get_frame_register_value (frame, MT_COPRO_REGNUM);
          /* And print.  */
          regnum = MT_COPRO_PSEUDOREG_REGNUM;
          fputs_filtered (gdbarch_register_name (gdbarch, regnum),
@@ -719,10 +723,10 @@ mt_registers_info (struct gdbarch *gdbarch,
          print_spaces_filtered (15 - strlen (gdbarch_register_name
                                                (gdbarch, regnum)),
                                 file);
-         get_raw_print_options (&opts);
+         get_no_prettyformat_print_options (&opts);
          opts.deref_ref = 1;
-         val_print (register_type (gdbarch, regnum), buf,
-                    0, 0, file, 0, NULL,
+         val_print (register_type (gdbarch, regnum),
+                    0, 0, file, 0, val,
                     &opts, current_language);
          fputs_filtered ("\n", file);
        }
@@ -732,13 +736,13 @@ mt_registers_info (struct gdbarch *gdbarch,
          gdb_byte buf[3 * sizeof (LONGEST)];
 
          /* Get the two "real" mac registers.  */
-         frame_register_read (frame, MT_MAC_REGNUM, buf);
+         deprecated_frame_register_read (frame, MT_MAC_REGNUM, buf);
          oldmac = extract_unsigned_integer
            (buf, register_size (gdbarch, MT_MAC_REGNUM), byte_order);
          if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
              || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
            {
-             frame_register_read (frame, MT_EXMAC_REGNUM, buf);
+             deprecated_frame_register_read (frame, MT_EXMAC_REGNUM, buf);
              ext_mac = extract_unsigned_integer
                (buf, register_size (gdbarch, MT_EXMAC_REGNUM), byte_order);
            }
@@ -846,16 +850,20 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (j = nargs - 1; j >= i; j--)
     {
       gdb_byte *val;
+      struct cleanup *back_to;
+      const gdb_byte *contents = value_contents (args[j]);
       
       /* Right-justify the value in an aligned-length buffer.  */
       typelen = TYPE_LENGTH (value_type (args[j]));
       slacklen = (wordsize - (typelen % wordsize)) % wordsize;
-      val = alloca (typelen + slacklen);
-      memcpy (val, value_contents (args[j]), typelen);
+      val = (gdb_byte *) xmalloc (typelen + slacklen);
+      back_to = make_cleanup (xfree, val);
+      memcpy (val, contents, typelen);
       memset (val + typelen, 0, slacklen);
       /* Now write this data to the stack.  */
       stack_dest -= typelen + slacklen;
       write_memory (stack_dest, val, typelen + slacklen);
+      do_cleanups (back_to);
     }
 
   /* Finally, if a param needs to be split between registers and stack, 
@@ -914,7 +922,7 @@ mt_frame_unwind_cache (struct frame_info *this_frame,
   ULONGEST sp, fp;
 
   if ((*this_prologue_cache))
-    return (*this_prologue_cache);
+    return (struct mt_unwind_cache *) (*this_prologue_cache);
 
   gdbarch = get_frame_arch (this_frame);
   info = FRAME_OBSTACK_ZALLOC (struct mt_unwind_cache);
@@ -1146,7 +1154,7 @@ mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
@@ -1162,7 +1170,8 @@ mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pseudo_register_write (gdbarch, mt_pseudo_register_write);
   set_gdbarch_skip_prologue (gdbarch, mt_skip_prologue);
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-  set_gdbarch_breakpoint_from_pc (gdbarch, mt_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch, mt_breakpoint_kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch, mt_sw_breakpoint_from_kind);
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
   set_gdbarch_frame_args_skip (gdbarch, 0);
   set_gdbarch_print_insn (gdbarch, print_insn_mt);
This page took 0.031383 seconds and 4 git commands to generate.