Patch from David Mosberger.
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index b74f558794463f9100c715a84f462995b5a1d2ce..05b5e7152f62d1ce74b268cee8b2d9c02e833d30 100644 (file)
@@ -40,6 +40,7 @@
 #include "objfiles.h"          /* ditto */
 #include "completer.h"         /* for completion functions */
 #include "ui-out.h"
+#include "gdb_assert.h"
 
 extern int asm_demangle;       /* Whether to demangle syms in asm printouts */
 extern int addressprint;       /* Whether to print hex addresses in HLL " */
@@ -135,8 +136,6 @@ static void enable_display (char *, int);
 
 static void disable_display_command (char *, int);
 
-static void disassemble_command (char *, int);
-
 static void printf_command (char *, int);
 
 static void print_frame_nameless_args (struct frame_info *, long,
@@ -390,10 +389,10 @@ print_scalar_formatted (char *valaddr, struct type *type, int format, int size,
     val_long = unpack_long (type, valaddr);
 
   /* If the value is a pointer, and pointers and addresses are not the
-     same, then at this point, the value's length is TARGET_ADDR_BIT, not
-     TYPE_LENGTH (type).  */
+     same, then at this point, the value's length (in target bytes) is
+     TARGET_ADDR_BIT/TARGET_CHAR_BIT, not TYPE_LENGTH (type).  */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
-    len = TARGET_ADDR_BIT;
+    len = TARGET_ADDR_BIT / 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
@@ -625,15 +624,6 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
        }
     }
 
-  /* On some targets, add in extra "flag" bits to PC for
-     disassembly.  This should ensure that "rounding errors" in
-     symbol addresses that are masked for disassembly favour the
-     the correct symbol. */
-
-#ifdef GDB_TARGET_UNMASK_DISAS_PC
-  addr = GDB_TARGET_UNMASK_DISAS_PC (addr);
-#endif
-
   /* First try to find the address in the symbol table, then
      in the minsyms.  Take the closest one.  */
 
@@ -673,14 +663,6 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
   if (symbol == NULL && msymbol == NULL)
     return 1;
 
-  /* On some targets, mask out extra "flag" bits from PC for handsome
-     disassembly. */
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
-  name_location = GDB_TARGET_MASK_DISAS_PC (name_location);
-  addr = GDB_TARGET_MASK_DISAS_PC (addr);
-#endif
-
   /* If the nearest symbol is too far away, don't print anything symbolic.  */
 
   /* For when CORE_ADDR is larger than unsigned int, we do math in
@@ -923,25 +905,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
       old_chain = make_cleanup (free_current_contents, &expr);
       cleanup = 1;
       val = evaluate_expression (expr);
-
-      /* C++: figure out what type we actually want to print it as.  */
-      type = VALUE_TYPE (val);
-
-      if (objectprint
-         && (TYPE_CODE (type) == TYPE_CODE_PTR
-             || TYPE_CODE (type) == TYPE_CODE_REF)
-         && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
-             || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION))
-       {
-         struct value *v;
-
-         v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type));
-         if (v != 0)
-           {
-             val = v;
-             type = VALUE_TYPE (val);
-           }
-       }
     }
   else
     val = access_value_history (0);
@@ -1122,7 +1085,11 @@ address_info (char *exp, int from_tty)
          printf_filtered ("Symbol \"");
          fprintf_symbol_filtered (gdb_stdout, exp,
                                   current_language->la_language, DMGL_ANSI);
-         printf_filtered ("\" is a field of the local class variable `this'\n");
+         printf_filtered ("\" is a field of the local class variable ");
+         if (current_language->la_language == language_objc)
+           printf_filtered ("`self'\n");       /* ObjC equivalent of "this" */
+         else
+           printf_filtered ("`this'\n");
          return;
        }
 
@@ -1252,14 +1219,8 @@ address_info (char *exp, int from_tty)
 
     case LOC_BLOCK:
       printf_filtered ("a function at address ");
-#ifdef GDB_TARGET_MASK_DISAS_PC
-      print_address_numeric
-       (load_addr = GDB_TARGET_MASK_DISAS_PC (BLOCK_START (SYMBOL_BLOCK_VALUE (sym))),
-        1, gdb_stdout);
-#else
       print_address_numeric (load_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
                             1, gdb_stdout);
-#endif
       if (section_is_overlay (section))
        {
          load_addr = overlay_unmapped_address (load_addr, section);
@@ -1293,12 +1254,18 @@ address_info (char *exp, int from_tty)
       }
       break;
 
-    case LOC_THREAD_LOCAL_STATIC:
+    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));
       break;
 
+    case LOC_THREAD_LOCAL_STATIC:
+      printf_filtered ("a thread-local variable at offset %ld in the "
+                       "thread-local storage for `%s'",
+                       val, SYMBOL_OBJFILE (sym)->name);
+      break;
+
     case LOC_OPTIMIZED_OUT:
       printf_filtered ("optimized out");
       break;
@@ -1804,6 +1771,10 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
   if (func)
     {
       b = SYMBOL_BLOCK_VALUE (func);
+      /* Function blocks are order sensitive, and thus should not be
+        hashed.  */
+      gdb_assert (BLOCK_HASHTABLE (b) == 0);
+
       ALL_BLOCK_SYMBOLS (b, i, sym)
         {
          QUIT;
@@ -2274,114 +2245,6 @@ printf_command (char *arg, int from_tty)
   }
   do_cleanups (old_cleanups);
 }
-\f
-/* Dump a specified section of assembly code.  With no command line
-   arguments, this command will dump the assembly code for the
-   function surrounding the pc value in the selected frame.  With one
-   argument, it will dump the assembly code surrounding that pc value.
-   Two arguments are interpeted as bounds within which to dump
-   assembly.  */
-
-/* ARGSUSED */
-static void
-disassemble_command (char *arg, int from_tty)
-{
-  CORE_ADDR low, high;
-  char *name;
-  CORE_ADDR pc, pc_masked;
-  char *space_index;
-#if 0
-  asection *section;
-#endif
-
-  name = NULL;
-  if (!arg)
-    {
-      if (!selected_frame)
-       error ("No frame selected.\n");
-
-      pc = get_frame_pc (selected_frame);
-      if (find_pc_partial_function (pc, &name, &low, &high) == 0)
-       error ("No function contains program counter for selected frame.\n");
-#if defined(TUI)
-      else if (tui_version)
-       low = tuiGetLowDisassemblyAddress (low, pc);
-#endif
-      low += FUNCTION_START_OFFSET;
-    }
-  else if (!(space_index = (char *) strchr (arg, ' ')))
-    {
-      /* One argument.  */
-      pc = parse_and_eval_address (arg);
-      if (find_pc_partial_function (pc, &name, &low, &high) == 0)
-       error ("No function contains specified address.\n");
-#if defined(TUI)
-      else if (tui_version)
-       low = tuiGetLowDisassemblyAddress (low, pc);
-#endif
-      low += FUNCTION_START_OFFSET;
-    }
-  else
-    {
-      /* Two arguments.  */
-      *space_index = '\0';
-      low = parse_and_eval_address (arg);
-      high = parse_and_eval_address (space_index + 1);
-    }
-
-#if defined(TUI)
-  if (!tui_is_window_visible (DISASSEM_WIN))
-#endif
-    {
-      printf_filtered ("Dump of assembler code ");
-      if (name != NULL)
-       {
-         printf_filtered ("for function %s:\n", name);
-       }
-      else
-       {
-         printf_filtered ("from ");
-         print_address_numeric (low, 1, gdb_stdout);
-         printf_filtered (" to ");
-         print_address_numeric (high, 1, gdb_stdout);
-         printf_filtered (":\n");
-       }
-
-      /* Dump the specified range.  */
-      pc = low;
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
-      pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
-#else
-      pc_masked = pc;
-#endif
-
-      while (pc_masked < high)
-       {
-         QUIT;
-         print_address (pc_masked, gdb_stdout);
-         printf_filtered (":\t");
-         /* We often wrap here if there are long symbolic names.  */
-         wrap_here ("    ");
-         pc += print_insn (pc, gdb_stdout);
-         printf_filtered ("\n");
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
-         pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
-#else
-         pc_masked = pc;
-#endif
-       }
-      printf_filtered ("End of assembler dump.\n");
-      gdb_flush (gdb_stdout);
-    }
-#if defined(TUI)
-  else
-    {
-      tui_show_assembly (low);
-    }
-#endif
-}
 
 /* Print the instruction at address MEMADDR in debugged memory,
    on STREAM.  Returns length of the instruction, in bytes.  */
@@ -2431,15 +2294,6 @@ Defaults for format and size letters are those previously used.\n\
 Default count is 1.  Default address is following last thing printed\n\
 with this command or \"print\".", NULL));
 
-  c = add_com ("disassemble", class_vars, disassemble_command,
-              "Disassemble a specified section of memory.\n\
-Default is the function surrounding the pc of the selected frame.\n\
-With a single argument, the function surrounding that address is dumped.\n\
-Two arguments are taken as a range of memory to dump.");
-  set_cmd_completer (c, location_completer);
-  if (xdb_commands)
-    add_com_alias ("va", "disassemble", class_xdb, 0);
-
 #if 0
   add_com ("whereis", class_vars, whereis_command,
           "Print line number and file of definition of variable.");
This page took 0.027371 seconds and 4 git commands to generate.