* gdb.cp/gdb2495.exp: Skip if gdb,nosignals.
[deliverable/binutils-gdb.git] / gdb / sh64-tdep.c
index 7fd9c94b95713d0a62d39e809f892dbe4bad84df..5b70732408ac1617856c3f7a1c1f12b3453e40f3 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for Renesas Super-H, for GDB.
 
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "regcache.h"
 #include "osabi.h"
+#include "valprint.h"
 
 #include "elf-bfd.h"
 
@@ -211,7 +212,7 @@ sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
    MSYMBOL_IS_SPECIAL   tests the "special" bit in a minimal symbol  */
 
 #define MSYMBOL_IS_SPECIAL(msym) \
-  (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
+  MSYMBOL_TARGET_FLAG_1 (msym)
 
 static void
 sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
@@ -221,7 +222,7 @@ sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
 
   if (((elf_symbol_type *)(sym))->internal_elf_sym.st_other == STO_SH5_ISA32)
     {
-      MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) | 0x80000000);
+      MSYMBOL_TARGET_FLAG_1 (msym) = 1;
       SYMBOL_VALUE_ADDRESS (msym) |= 1;
     }
 }
@@ -480,8 +481,10 @@ after_prologue (CORE_ADDR pc)
 }
 
 static CORE_ADDR 
-look_for_args_moves (CORE_ADDR start_pc, int media_mode)
+look_for_args_moves (struct gdbarch *gdbarch,
+                    CORE_ADDR start_pc, int media_mode)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR here, end;
   int w;
   int insn_size = (media_mode ? 4 : 2);
@@ -490,7 +493,8 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
     {
       if (media_mode)
        {
-         w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+         w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+                                  insn_size, byte_order);
          here += insn_size;
          if (IS_MEDIA_IND_ARG_MOV (w))
            {
@@ -499,7 +503,7 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
                 the SP has been saved, unfortunately.  */
         
              int next_insn = read_memory_integer (UNMAKE_ISA32_ADDR (here),
-                                                  insn_size);
+                                                  insn_size, byte_order);
              here += insn_size;
              if (IS_MEDIA_MOV_TO_R14 (next_insn))
                start_pc = here;          
@@ -514,7 +518,7 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
        }
       else
        {
-         w = read_memory_integer (here, insn_size);
+         w = read_memory_integer (here, insn_size, byte_order);
          w = w & 0xffff;
          here += insn_size;
          if (IS_COMPACT_IND_ARG_MOV (w))
@@ -523,7 +527,8 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
                 is where the debug info says it is. This can happen after
                 the SP has been saved, unfortunately.  */
         
-             int next_insn = 0xffff & read_memory_integer (here, insn_size);
+             int next_insn = 0xffff & read_memory_integer (here, insn_size,
+                                                           byte_order);
              here += insn_size;
              if (IS_COMPACT_MOV_TO_R14 (next_insn))
                start_pc = here;
@@ -556,11 +561,13 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
              /* This must be followed by a JSR @r0 instruction and by
                  a NOP instruction. After these, the prologue is over!  */
         
-             int next_insn = 0xffff & read_memory_integer (here, insn_size);
+             int next_insn = 0xffff & read_memory_integer (here, insn_size,
+                                                           byte_order);
              here += insn_size;
              if (IS_JSR_R0 (next_insn))
                {
-                 next_insn = 0xffff & read_memory_integer (here, insn_size);
+                 next_insn = 0xffff & read_memory_integer (here, insn_size,
+                                                           byte_order);
                  here += insn_size;
 
                  if (IS_NOP (next_insn))
@@ -576,8 +583,9 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
 }
 
 static CORE_ADDR
-sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
+sh64_skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR here, end;
   int updated_fp = 0;
   int insn_size = 4;
@@ -597,7 +605,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
 
       if (media_mode)
        {
-         int w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+         int w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+                                      insn_size, byte_order);
          here += insn_size;
          if (IS_STQ_R18_R14 (w) || IS_STQ_R18_R15 (w) || IS_STQ_R14_R15 (w)
              || IS_STL_R14_R15 (w) || IS_STL_R18_R15 (w)
@@ -616,13 +625,14 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
                /* Don't bail out yet, we may have arguments stored in
                   registers here, according to the debug info, so that
                   gdb can print the frames correctly.  */
-               start_pc = look_for_args_moves (here - insn_size, media_mode);
+               start_pc = look_for_args_moves (gdbarch,
+                                               here - insn_size, media_mode);
                break;
              }
        }
       else
        {
-         int w = 0xffff & read_memory_integer (here, insn_size);
+         int w = 0xffff & read_memory_integer (here, insn_size, byte_order);
          here += insn_size;
 
          if (IS_STS_R0 (w) || IS_STS_PR (w)
@@ -642,7 +652,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
                /* Don't bail out yet, we may have arguments stored in
                   registers here, according to the debug info, so that
                   gdb can print the frames correctly.  */
-               start_pc = look_for_args_moves (here - insn_size, media_mode);
+               start_pc = look_for_args_moves (gdbarch,
+                                               here - insn_size, media_mode);
                break;
              }
        }
@@ -666,7 +677,7 @@ sh64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (post_prologue_pc != 0)
     return max (pc, post_prologue_pc);
   else
-    return sh64_skip_prologue_hard_way (pc);
+    return sh64_skip_prologue_hard_way (gdbarch, pc);
 }
 
 /* Should call_function allocate stack space for a struct return?  */
@@ -844,6 +855,7 @@ sh64_analyze_prologue (struct gdbarch *gdbarch,
   int gdb_register_number;
   int register_number;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   
   cache->sp_offset = 0;
 
@@ -865,13 +877,14 @@ sh64_analyze_prologue (struct gdbarch *gdbarch,
     {
       insn = read_memory_integer (cache->media_mode ? UNMAKE_ISA32_ADDR (pc)
                                                    : pc,
-                                 insn_size);
+                                 insn_size, byte_order);
 
       if (!cache->media_mode)
        {
          if (IS_STS_PR (insn))
            {
-             int next_insn = read_memory_integer (pc + insn_size, insn_size);
+             int next_insn = read_memory_integer (pc + insn_size,
+                                                  insn_size, byte_order);
              if (IS_MOV_TO_R15 (next_insn))
                {
                  cache->saved_regs[PR_REGNUM] =
@@ -1028,6 +1041,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
                      CORE_ADDR sp, int struct_return,
                      CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_offset, stack_alloc;
   int int_argreg;
   int float_argreg;
@@ -1108,7 +1122,8 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
              if (int_argreg <= ARGLAST_REGNUM)
                {                       
                  /* there's room in a register */
-                 regval = extract_unsigned_integer (val, argreg_size);
+                 regval = extract_unsigned_integer (val, argreg_size,
+                                                    byte_order);
                  regcache_cooked_write_unsigned (regcache, int_argreg, regval);
                }
              /* Store the value 8 bytes at a time.  This means that
@@ -1196,6 +1211,7 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache,
                           void *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
@@ -1315,8 +1331,8 @@ sh64_show_media_regs (struct frame_info *frame)
 
   printf_filtered
     ("PC=%s SR=%016llx \n",
-     paddr (get_frame_register_unsigned (frame,
-                                        gdbarch_pc_regnum (gdbarch))),
+     phex (get_frame_register_unsigned (frame,
+                                       gdbarch_pc_regnum (gdbarch)), 8),
      (long long) get_frame_register_unsigned (frame, SR_REGNUM));
 
   printf_filtered
@@ -1368,7 +1384,7 @@ sh64_show_compact_regs (struct frame_info *frame)
 
   printf_filtered
     ("PC=%s \n",
-     paddr (get_frame_register_unsigned (frame, PC_C_REGNUM)));
+     phex (get_frame_register_unsigned (frame, PC_C_REGNUM), 8));
 
   printf_filtered
     ("GBR=%08lx MACH=%08lx MACL=%08lx PR=%08lx T=%08lx\n",
@@ -1497,10 +1513,8 @@ REGISTER_BYTE returns the register byte for the base register.
 static struct type *
 sh64_build_float_register_type (struct gdbarch *gdbarch, int high)
 {
-  struct type *temp;
-
-  temp = create_range_type (NULL, builtin_type_int32, 0, high);
-  return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
+  return lookup_array_range_type (builtin_type (gdbarch)->builtin_float,
+                                 0, high);
 }
 
 /* Return the GDB type object for the "standard" data type
@@ -1576,7 +1590,7 @@ sh64_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
       || (regnum >= DR0_C_REGNUM 
          && regnum <= DR_LAST_C_REGNUM))
     {
-      DOUBLEST val = deprecated_extract_floating (from, TYPE_LENGTH(type));
+      DOUBLEST val = extract_typed_floating (from, type);
       floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, 
                                 &val, to);
     }
@@ -1588,6 +1602,7 @@ static void
 sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
                           int reg_nr, gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum;
   int portion;
   int offset = 0;
@@ -1727,17 +1742,17 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
       /* Get FPSCR into a local buffer */
       regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
       /* Get value as an int.  */
-      fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+      fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       /* Get SR into a local buffer */
       regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
       /* Get value as an int.  */
-      sr_value = extract_unsigned_integer (temp_buffer, 4);
+      sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       /* Build the new value.  */
       fpscr_c_part1_value = fpscr_value & 0x3fffd;
       fpscr_c_part2_value = (sr_value & 0x7000) << 6;
       fpscr_c_value = fpscr_c_part1_value | fpscr_c_part2_value;
       /* Store that in out buffer!!! */
-      store_unsigned_integer (buffer, 4, fpscr_c_value);
+      store_unsigned_integer (buffer, 4, byte_order, fpscr_c_value);
       /* FIXME There is surely an endianness gotcha here.  */
     }
 
@@ -1755,6 +1770,7 @@ static void
 sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
                            int reg_nr, const gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum, portion;
   int offset;
   char temp_buffer[MAX_REGISTER_SIZE];
@@ -1893,7 +1909,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
        */
       /* *INDENT-ON* */
       /* Get value as an int.  */
-      fpscr_c_value = extract_unsigned_integer (buffer, 4);
+      fpscr_c_value = extract_unsigned_integer (buffer, 4, byte_order);
 
       /* Build the new values.  */
       fpscr_mask = 0x0003fffd;
@@ -1903,17 +1919,17 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
       sr_value = (fpscr_value & sr_mask) >> 6;
       
       regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
-      old_fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+      old_fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       old_fpscr_value &= 0xfffc0002;
       fpscr_value |= old_fpscr_value;
-      store_unsigned_integer (temp_buffer, 4, fpscr_value);
+      store_unsigned_integer (temp_buffer, 4, byte_order, fpscr_value);
       regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
       
       regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
-      old_sr_value = extract_unsigned_integer (temp_buffer, 4);
+      old_sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       old_sr_value &= 0xffff8fff;
       sr_value |= old_sr_value;
-      store_unsigned_integer (temp_buffer, 4, sr_value);
+      store_unsigned_integer (temp_buffer, 4, byte_order, sr_value);
       regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
     }
 
@@ -2092,6 +2108,7 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
                  struct frame_info *frame, int regnum)
 {
   unsigned char raw_buffer[MAX_REGISTER_SIZE];
+  struct value_print_options opts;
 
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
   print_spaces_filtered (15 - strlen (gdbarch_register_name
@@ -2100,12 +2117,16 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
   /* Get the data in raw format.  */
   if (!frame_register_read (frame, regnum, raw_buffer))
     fprintf_filtered (file, "*value not available*\n");
-      
+
+  get_formatted_print_options (&opts, 'x');
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-            file, 'x', 1, 0, Val_pretty_default, current_language);
+            file, 0, &opts, current_language);
   fprintf_filtered (file, "\t");
+  get_formatted_print_options (&opts, 0);
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-            file, 0, 1, 0, Val_pretty_default, current_language);
+            file, 0, &opts, current_language);
   fprintf_filtered (file, "\n");
 }
 
@@ -2317,6 +2338,7 @@ sh64_frame_prev_register (struct frame_info *this_frame,
 {
   struct sh64_frame_cache *cache = sh64_frame_cache (this_frame, this_cache);
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   gdb_assert (regnum >= 0);
 
@@ -2335,7 +2357,8 @@ sh64_frame_prev_register (struct frame_info *this_frame,
           && (regnum == MEDIA_FP_REGNUM || regnum == PR_REGNUM))
         {
          CORE_ADDR val;
-         val = read_memory_unsigned_integer (cache->saved_regs[regnum], 4);
+         val = read_memory_unsigned_integer (cache->saved_regs[regnum],
+                                             4, byte_order);
          return frame_unwind_got_constant (this_frame, regnum, val);
         }
 
This page took 0.153631 seconds and 4 git commands to generate.