2011-02-28 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / mt-tdep.c
index b0da869aab263d0f942c848e6927fc140444b253..f67ddfa719f3bdece714d516f0933298104480fe 100644 (file)
@@ -1,6 +1,7 @@
 /* Target-dependent code for Morpho mt processor, for GDB.
 
-   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -339,6 +340,8 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
                 struct type *type, struct regcache *regcache,
                 gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (TYPE_LENGTH (type) > 4)
     {
       /* Return values > 4 bytes are returned in memory, 
@@ -369,7 +372,8 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
 
          /* Return values of <= 4 bytes are returned in R11.  */
          regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &temp);
-         store_unsigned_integer (readbuf, TYPE_LENGTH (type), temp);
+         store_unsigned_integer (readbuf, TYPE_LENGTH (type),
+                                 byte_order, temp);
        }
 
       if (writebuf)
@@ -403,6 +407,7 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
 static CORE_ADDR
 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;
   unsigned long instr;
@@ -430,7 +435,7 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   /* No function symbol, or no line symbol.  Use prologue scanning method.  */
   for (;; pc += 4)
     {
-      instr = read_memory_unsigned_integer (pc, 4);
+      instr = read_memory_unsigned_integer (pc, 4, byte_order);
       if (instr == 0x12000000) /* nop */
        continue;
       if (instr == 0x12ddc000) /* copy sp into fp */
@@ -451,7 +456,7 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
    instruction in the instruction set.
 
    The BP for ms1 is defined as 0x68000000 (BREAK).
-   The BP for ms2 is defined as 0x69000000 (illegal)  */
+   The BP for ms2 is defined as 0x69000000 (illegal).  */
 
 static const gdb_byte *
 mt_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
@@ -474,13 +479,15 @@ static int
 mt_select_coprocessor (struct gdbarch *gdbarch,
                        struct regcache *regcache, int regno)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned index, base;
   gdb_byte copro[4];
 
-  /* Get the copro pseudo regnum. */
+  /* Get the copro pseudo regnum.  */
   regcache_raw_read (regcache, MT_COPRO_REGNUM, copro);
-  base = (extract_signed_integer (&copro[0], 2) * MT_COPRO_PSEUDOREG_DIM_2
-         + extract_signed_integer (&copro[2], 2));
+  base = ((extract_signed_integer (&copro[0], 2, byte_order)
+          * MT_COPRO_PSEUDOREG_DIM_2)
+         + extract_signed_integer (&copro[2], 2, byte_order));
 
   regno -= MT_COPRO_PSEUDOREG_ARRAY;
   index = regno % MT_COPRO_PSEUDOREG_REGS;
@@ -491,8 +498,10 @@ mt_select_coprocessor (struct gdbarch *gdbarch,
         coprocessor register cache.  */
       unsigned ix;
 
-      store_signed_integer (&copro[0], 2, regno / MT_COPRO_PSEUDOREG_DIM_2);
-      store_signed_integer (&copro[2], 2, regno % MT_COPRO_PSEUDOREG_DIM_2);
+      store_signed_integer (&copro[0], 2, byte_order,
+                           regno / MT_COPRO_PSEUDOREG_DIM_2);
+      store_signed_integer (&copro[2], 2, byte_order,
+                           regno % MT_COPRO_PSEUDOREG_DIM_2);
       regcache_raw_write (regcache, MT_COPRO_REGNUM, copro);
       
       /* We must flush the cache, as it is now invalid.  */
@@ -519,6 +528,8 @@ static void
 mt_pseudo_register_read (struct gdbarch *gdbarch,
                          struct regcache *regcache, int regno, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   switch (regno)
     {
     case MT_COPRO_REGNUM:
@@ -537,7 +548,7 @@ mt_pseudo_register_read (struct gdbarch *gdbarch,
          regcache_cooked_read_unsigned (regcache, MT_EXMAC_REGNUM, &ext_mac);
          newmac =
            (oldmac & 0xffffffff) | ((long long) (ext_mac & 0xff) << 32);
-         store_signed_integer (buf, 8, newmac);
+         store_signed_integer (buf, 8, byte_order, newmac);
        }
       else
        regcache_raw_read (regcache, MT_MAC_REGNUM, buf);
@@ -567,6 +578,7 @@ mt_pseudo_register_write (struct gdbarch *gdbarch,
                           struct regcache *regcache,
                           int regno, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
 
   switch (regno)
@@ -587,7 +599,7 @@ mt_pseudo_register_write (struct gdbarch *gdbarch,
          unsigned int oldmac, ext_mac;
          ULONGEST newmac;
 
-         newmac = extract_unsigned_integer (buf, 8);
+         newmac = extract_unsigned_integer (buf, 8, byte_order);
          oldmac = newmac & 0xffffffff;
          ext_mac = (newmac >> 32) & 0xff;
          regcache_cooked_write_unsigned (regcache, MT_MAC_REGNUM, oldmac);
@@ -626,6 +638,8 @@ mt_registers_info (struct gdbarch *gdbarch,
                   struct ui_file *file,
                   struct frame_info *frame, int regnum, int all)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (regnum == -1)
     {
       int lim;
@@ -672,10 +686,10 @@ mt_registers_info (struct gdbarch *gdbarch,
 
          for (i = 0; i < regsize; i++)
            fprintf_filtered (file, "%02x", (unsigned int)
-                             extract_unsigned_integer (buff + i, 1));
+                             extract_unsigned_integer (buff + i, 1, byte_order));
          fputs_filtered ("\t", file);
          print_longest (file, 'd', 0,
-                        extract_unsigned_integer (buff, regsize));
+                        extract_unsigned_integer (buff, regsize, byte_order));
          fputs_filtered ("\n", file);
        }
       else if (regnum == MT_COPRO_REGNUM
@@ -697,8 +711,8 @@ mt_registers_info (struct gdbarch *gdbarch,
          get_raw_print_options (&opts);
          opts.deref_ref = 1;
          val_print (register_type (gdbarch, regnum), buf,
-                    0, 0, file, 0, &opts,
-                    current_language);
+                    0, 0, file, 0, NULL,
+                    &opts, current_language);
          fputs_filtered ("\n", file);
        }
       else if (regnum == MT_MAC_REGNUM || regnum == MT_MAC_PSEUDOREG_REGNUM)
@@ -709,13 +723,13 @@ mt_registers_info (struct gdbarch *gdbarch,
          /* Get the two "real" mac registers.  */
          frame_register_read (frame, MT_MAC_REGNUM, buf);
          oldmac = extract_unsigned_integer
-           (buf, register_size (gdbarch, MT_MAC_REGNUM));
+           (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);
              ext_mac = extract_unsigned_integer
-               (buf, register_size (gdbarch, MT_EXMAC_REGNUM));
+               (buf, register_size (gdbarch, MT_EXMAC_REGNUM), byte_order);
            }
          else
            ext_mac = 0;
@@ -755,6 +769,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                     int struct_return, CORE_ADDR struct_addr)
 {
 #define wordsize 4
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[MT_MAX_STRUCT_SIZE];
   int argreg = MT_1ST_ARGREG;
   int split_param_len = 0;
@@ -778,7 +793,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          regcache_cooked_write_unsigned (regcache, argreg++,
                                          extract_unsigned_integer
                                          (value_contents (args[i]),
-                                          wordsize));
+                                          wordsize, byte_order));
          break;
        case 8:
        case 12:
@@ -791,7 +806,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                  /* This word of the argument is passed in a register.  */
                  regcache_cooked_write_unsigned (regcache, argreg++,
                                                  extract_unsigned_integer
-                                                 (val, wordsize));
+                                                 (val, wordsize, byte_order));
                  typelen -= wordsize;
                  val += wordsize;
                }
@@ -862,7 +877,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
 struct mt_unwind_cache
 {
-  /* The previous frame's inner most stack address.  
+  /* The previous frame's inner most stack address.
      Used as this frame ID's stack_addr.  */
   CORE_ADDR prev_sp;
   CORE_ADDR frame_base;
@@ -900,7 +915,7 @@ mt_frame_unwind_cache (struct frame_info *this_frame,
   info->frameless_p = 1;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
-  /* Grab the frame-relative values of SP and FP, needed below. 
+  /* Grab the frame-relative values of SP and FP, needed below.
      The frame_saved_register function will find them on the
      stack or in the registers as appropriate.  */
   sp = get_frame_register_unsigned (this_frame, MT_SP_REGNUM);
@@ -918,17 +933,17 @@ mt_frame_unwind_cache (struct frame_info *this_frame,
   for (next_addr = start_addr; next_addr < end_addr; next_addr += 4)
     {
       instr = get_frame_memory_unsigned (this_frame, next_addr, 4);
-      if (delayed_store)       /* previous instr was a push */
+      if (delayed_store)       /* Previous instr was a push.  */
        {
          upper_half = delayed_store >> 16;
          regnum = upper_half & 0xf;
          offset = delayed_store & 0xffff;
          switch (upper_half & 0xfff0)
            {
-           case 0x43c0:        /* push using frame pointer */
+           case 0x43c0:        /* push using frame pointer */
              info->saved_regs[regnum].addr = offset;
              break;
-           case 0x43d0:        /* push using stack pointer */
+           case 0x43d0:        /* push using stack pointer */
              info->saved_regs[regnum].addr = offset;
              break;
            default:            /* lint */
@@ -942,7 +957,8 @@ mt_frame_unwind_cache (struct frame_info *this_frame,
        case 0x12000000:        /* NO-OP */
          continue;
        case 0x12ddc000:        /* copy sp into fp */
-         info->frameless_p = 0;        /* Record that the frame pointer is in use.  */
+         info->frameless_p = 0;        /* Record that the frame
+                                          pointer is in use.  */
          continue;
        default:
          upper_half = instr >> 16;
@@ -975,9 +991,9 @@ mt_frame_unwind_cache (struct frame_info *this_frame,
             keep scanning until we reach it (or we reach end_addr).  */
 
          if (prologue_end_addr && (prologue_end_addr > (next_addr + 4)))
-           continue;           /* Keep scanning, recording saved_regs etc.  */
+           continue;   /* Keep scanning, recording saved_regs etc.  */
          else
-           break;              /* Quit scanning: breakpoint can be set here.  */
+           break;      /* Quit scanning: breakpoint can be set here.  */
        }
     }
 
@@ -1170,7 +1186,7 @@ mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_unwind_pc (gdbarch, mt_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, mt_unwind_sp);
 
-  /* Methods for saving / extracting a dummy frame's ID.  
+  /* Methods for saving / extracting a dummy frame's ID.
      The ID's stack address must match the SP value returned by
      PUSH_DUMMY_CALL, and saved by generic_save_dummy_frame_tos.  */
   set_gdbarch_dummy_id (gdbarch, mt_dummy_id);
This page took 0.027042 seconds and 4 git commands to generate.