2007-08-02 Michael Snyder <msnyder@access-company.com>
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 8843010679c1216046deb38e61eb7447c52b4fd9..d5fbeba2aba67b14587037da5a66d0450c0ab9b2 100644 (file)
@@ -70,6 +70,10 @@ static char last_size = 'w';
 
 static CORE_ADDR next_address;
 
+/* Number of delay instructions following current disassembled insn.  */
+
+static int branch_delay_insns;
+
 /* Last address examined.  */
 
 static CORE_ADDR last_examine_address;
@@ -212,14 +216,14 @@ decode_format (char **string_ptr, int oformat, int osize)
       case 'a':
       case 's':
        /* Pick the appropriate size for an address.  */
-       if (TARGET_PTR_BIT == 64)
+       if (gdbarch_ptr_bit (current_gdbarch) == 64)
          val.size = osize ? 'g' : osize;
-       else if (TARGET_PTR_BIT == 32)
+       else if (gdbarch_ptr_bit (current_gdbarch) == 32)
          val.size = osize ? 'w' : osize;
-       else if (TARGET_PTR_BIT == 16)
+       else if (gdbarch_ptr_bit (current_gdbarch) == 16)
          val.size = osize ? 'h' : osize;
        else
-         /* Bad value for TARGET_PTR_BIT.  */
+         /* Bad value for gdbarch_ptr_bit.  */
          internal_error (__FILE__, __LINE__,
                          _("failed internal consistency check"));
        break;
@@ -277,8 +281,9 @@ print_formatted (struct value *val, int format, int size,
 
       /* We often wrap here if there are long symbolic names.  */
       wrap_here ("    ");
-      next_address = VALUE_ADDRESS (val)
-       + gdb_print_insn (VALUE_ADDRESS (val), stream);
+      next_address = (VALUE_ADDRESS (val)
+                     + gdb_print_insn (VALUE_ADDRESS (val), stream,
+                                       &branch_delay_insns));
       break;
 
     default:
@@ -346,9 +351,9 @@ print_scalar_formatted (const void *valaddr, struct type *type,
 
   /* If the value is a pointer, and pointers and addresses are not the
      same, then at this point, the value's length (in target bytes) is
-     TARGET_ADDR_BIT/TARGET_CHAR_BIT, not TYPE_LENGTH (type).  */
+     gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type).  */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
-    len = TARGET_ADDR_BIT / TARGET_CHAR_BIT;
+    len = gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT;
 
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
@@ -560,7 +565,6 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
 {
   struct minimal_symbol *msymbol;
   struct symbol *symbol;
-  struct symtab *symtab = 0;
   CORE_ADDR name_location = 0;
   asection *section = 0;
   char *name_temp = "";
@@ -608,7 +612,6 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
          /* The msymbol is closer to the address than the symbol;
             use the msymbol instead.  */
          symbol = 0;
-         symtab = 0;
          name_location = SYMBOL_VALUE_ADDRESS (msymbol);
          if (do_demangle || asm_demangle)
            name_temp = SYMBOL_PRINT_NAME (msymbol);
@@ -645,16 +648,6 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
          *filename = xstrdup (sal.symtab->filename);
          *line = sal.line;
        }
-      else if (symtab && symbol && symbol->line)
-       {
-         *filename = xstrdup (symtab->filename);
-         *line = symbol->line;
-       }
-      else if (symtab)
-       {
-         *filename = xstrdup (symtab->filename);
-         *line = -1;
-       }
     }
   return 0;
 }
@@ -669,7 +662,7 @@ deprecated_print_address_numeric (CORE_ADDR addr, int use_local,
     fputs_filtered (paddress (addr), stream);
   else
     {
-      int addr_bit = TARGET_ADDR_BIT;
+      int addr_bit = gdbarch_addr_bit (current_gdbarch);
 
       if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
        addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
@@ -800,6 +793,10 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
            release_value (last_examine_value);
 
          print_formatted (last_examine_value, format, size, gdb_stdout);
+
+         /* Display any branch delay slots following the final insn.  */
+         if (format == 'i' && count == 1)
+           count += branch_delay_insns;
        }
       printf_filtered ("\n");
       gdb_flush (gdb_stdout);
@@ -1113,7 +1110,8 @@ address_info (char *exp, int from_tty)
       break;
 
     case LOC_REGISTER:
-      printf_filtered (_("a variable in register %s"), REGISTER_NAME (val));
+      printf_filtered (_("a variable in register %s"),
+                        gdbarch_register_name (current_gdbarch, val));
       break;
 
     case LOC_STATIC:
@@ -1144,12 +1142,13 @@ address_info (char *exp, int from_tty)
       break;
 
     case LOC_REGPARM:
-      printf_filtered (_("an argument in register %s"), REGISTER_NAME (val));
+      printf_filtered (_("an argument in register %s"),
+                        gdbarch_register_name (current_gdbarch, val));
       break;
 
     case LOC_REGPARM_ADDR:
       printf_filtered (_("address of an argument in register %s"),
-                      REGISTER_NAME (val));
+                      gdbarch_register_name (current_gdbarch, val));
       break;
 
     case LOC_ARG:
@@ -1170,12 +1169,12 @@ address_info (char *exp, int from_tty)
 
     case LOC_BASEREG:
       printf_filtered (_("a variable at offset %ld from register %s"),
-                      val, REGISTER_NAME (basereg));
+                      val, gdbarch_register_name (current_gdbarch, basereg));
       break;
 
     case LOC_BASEREG_ARG:
       printf_filtered (_("an argument at offset %ld from register %s"),
-                      val, REGISTER_NAME (basereg));
+                      val, gdbarch_register_name (current_gdbarch, basereg));
       break;
 
     case LOC_TYPEDEF:
@@ -1222,7 +1221,7 @@ address_info (char *exp, int from_tty)
     case LOC_HP_THREAD_LOCAL_STATIC:
       printf_filtered (_("\
 a thread-local variable at offset %ld from the thread base register %s"),
-                      val, REGISTER_NAME (basereg));
+                      val, gdbarch_register_name (current_gdbarch, basereg));
       break;
 
     case LOC_OPTIMIZED_OUT:
@@ -1509,7 +1508,7 @@ do_one_display (struct display *d)
       print_expression (d->exp, gdb_stdout);
       annotate_display_expression_end ();
 
-      if (d->format.count != 1)
+      if (d->format.count != 1 || d->format.format == 'i')
        printf_filtered ("\n");
       else
        printf_filtered ("  ");
@@ -1517,7 +1516,7 @@ do_one_display (struct display *d)
       val = evaluate_expression (d->exp);
       addr = value_as_address (val);
       if (d->format.format == 'i')
-       addr = ADDR_BITS_REMOVE (addr);
+       addr = gdbarch_addr_bits_remove (current_gdbarch, addr);
 
       annotate_display_value ();
 
This page took 0.027389 seconds and 4 git commands to generate.