libiberty/ChangeLog:
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 8542b8a9a5b3464b4b538edbe4c4e30e89a27ec6..11fd1df94689287770fbfada74e0e2b302bf7c93 100644 (file)
@@ -1,7 +1,7 @@
 /* Print values for GNU debugger GDB.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
    Foundation, Inc.
 
    This file is part of GDB.
@@ -41,6 +41,8 @@
 #include "completer.h"         /* for completion functions */
 #include "ui-out.h"
 #include "gdb_assert.h"
+#include "block.h"
+#include "disasm.h"
 
 extern int asm_demangle;       /* Whether to demangle syms in asm printouts */
 extern int addressprint;       /* Whether to print hex addresses in HLL " */
@@ -136,8 +138,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,
@@ -176,8 +176,6 @@ static void print_formatted (struct value *, int, int, struct ui_file *);
 
 static struct format_data decode_format (char **, int, int);
 
-static int print_insn (CORE_ADDR, struct ui_file *);
-
 static void sym_info (char *, int);
 \f
 
@@ -311,7 +309,7 @@ print_formatted (struct value *val, register int format, int size,
       /* We often wrap here if there are long symbolic names.  */
       wrap_here ("    ");
       next_address = VALUE_ADDRESS (val)
-       + print_insn (VALUE_ADDRESS (val), stream);
+       + gdb_print_insn (VALUE_ADDRESS (val), stream);
       next_section = VALUE_BFD_SECTION (val);
       break;
 
@@ -344,7 +342,7 @@ print_formatted (struct value *val, register int format, int size,
    with a format.  */
 
 void
-print_scalar_formatted (char *valaddr, struct type *type, int format, int size,
+print_scalar_formatted (void *valaddr, struct type *type, int format, int size,
                        struct ui_file *stream)
 {
   LONGEST val_long;
@@ -626,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.  */
 
@@ -650,10 +639,10 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
   if (symbol)
     {
       name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
-      if (do_demangle)
-       name_temp = SYMBOL_SOURCE_NAME (symbol);
+      if (do_demangle || asm_demangle)
+       name_temp = SYMBOL_PRINT_NAME (symbol);
       else
-       name_temp = SYMBOL_LINKAGE_NAME (symbol);
+       name_temp = DEPRECATED_SYMBOL_NAME (symbol);
     }
 
   if (msymbol != NULL)
@@ -665,23 +654,15 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
          symbol = 0;
          symtab = 0;
          name_location = SYMBOL_VALUE_ADDRESS (msymbol);
-         if (do_demangle)
-           name_temp = SYMBOL_SOURCE_NAME (msymbol);
+         if (do_demangle || asm_demangle)
+           name_temp = SYMBOL_PRINT_NAME (msymbol);
          else
-           name_temp = SYMBOL_LINKAGE_NAME (msymbol);
+           name_temp = DEPRECATED_SYMBOL_NAME (msymbol);
        }
     }
   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
@@ -1062,10 +1043,10 @@ sym_info (char *arg, int from_tty)
        offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol);
        if (offset)
          printf_filtered ("%s + %u in ",
-                          SYMBOL_SOURCE_NAME (msymbol), offset);
+                          SYMBOL_PRINT_NAME (msymbol), offset);
        else
          printf_filtered ("%s in ",
-                          SYMBOL_SOURCE_NAME (msymbol));
+                          SYMBOL_PRINT_NAME (msymbol));
        if (pc_in_unmapped_range (addr, sect))
          printf_filtered ("load address range of ");
        if (section_is_overlay (sect))
@@ -1095,7 +1076,7 @@ address_info (char *exp, int from_tty)
   if (exp == 0)
     error ("Argument required.");
 
-  sym = lookup_symbol (exp, get_selected_block (0), VAR_NAMESPACE,
+  sym = lookup_symbol (exp, get_selected_block (0), VAR_DOMAIN,
                       &is_a_field_of_this, (struct symtab **) NULL);
   if (sym == NULL)
     {
@@ -1104,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;
        }
 
@@ -1136,7 +1121,7 @@ address_info (char *exp, int from_tty)
     }
 
   printf_filtered ("Symbol \"");
-  fprintf_symbol_filtered (gdb_stdout, SYMBOL_NAME (sym),
+  fprintf_symbol_filtered (gdb_stdout, DEPRECATED_SYMBOL_NAME (sym),
                           current_language->la_language, DMGL_ANSI);
   printf_filtered ("\" is ");
   val = SYMBOL_VALUE (sym);
@@ -1163,6 +1148,11 @@ address_info (char *exp, int from_tty)
        }
       break;
 
+    case LOC_COMPUTED:
+    case LOC_COMPUTED_ARG:
+      (SYMBOL_LOCATION_FUNCS (sym)->describe_location) (sym, gdb_stdout);
+      break;
+
     case LOC_REGISTER:
       printf_filtered ("a variable in register %s", REGISTER_NAME (val));
       break;
@@ -1234,14 +1224,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);
@@ -1255,7 +1239,7 @@ address_info (char *exp, int from_tty)
       {
        struct minimal_symbol *msym;
 
-       msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);
+       msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, NULL);
        if (msym == NULL)
          printf_filtered ("unresolved");
        else
@@ -1275,12 +1259,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;
@@ -1378,7 +1368,9 @@ display_command (char *exp, int from_tty)
   int display_it = 1;
 
 #if defined(TUI)
-  if (tui_version && *exp == '$')
+  /* NOTE: cagney/2003-02-13 The `tui_active' was previously
+     `tui_version'.  */
+  if (tui_active && *exp == '$')
     display_it = (tui_set_layout (exp) == TUI_FAILURE);
 #endif
 
@@ -1826,6 +1818,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
            case LOC_REGPARM_ADDR:
            case LOC_LOCAL_ARG:
            case LOC_BASEREG_ARG:
+           case LOC_COMPUTED_ARG:
              break;
 
            /* Other types of symbols we just skip over.  */
@@ -1846,12 +1839,12 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
             Null parameter names occur on the RS/6000, for traceback tables.
             FIXME, should we even print them?  */
 
-         if (*SYMBOL_NAME (sym))
+         if (*DEPRECATED_SYMBOL_NAME (sym))
            {
              struct symbol *nsym;
              nsym = lookup_symbol
-               (SYMBOL_NAME (sym),
-                b, VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL);
+               (DEPRECATED_SYMBOL_NAME (sym),
+                b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL);
              if (SYMBOL_CLASS (nsym) == LOC_REGISTER)
                {
                  /* There is a LOC_ARG/LOC_REGISTER pair.  This means that
@@ -1894,7 +1887,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
          annotate_arg_begin ();
 
          list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
-         fprintf_symbol_filtered (stb->stream, SYMBOL_SOURCE_NAME (sym),
+         fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym),
                                   SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI);
          ui_out_field_stream (uiout, "name", stb);
          annotate_arg_name_end ();
@@ -1962,28 +1955,13 @@ print_frame_nameless_args (struct frame_info *fi, long start, int num,
   for (i = 0; i < num; i++)
     {
       QUIT;
-#ifdef NAMELESS_ARG_VALUE
-      NAMELESS_ARG_VALUE (fi, start, &arg_value);
-#else
-      argsaddr = FRAME_ARGS_ADDRESS (fi);
+      argsaddr = get_frame_args_address (fi);
       if (!argsaddr)
        return;
-
       arg_value = read_memory_integer (argsaddr + start, sizeof (int));
-#endif
-
       if (!first)
        fprintf_filtered (stream, ", ");
-
-#ifdef PRINT_NAMELESS_INTEGER
-      PRINT_NAMELESS_INTEGER (stream, arg_value);
-#else
-#ifdef PRINT_TYPELESS_INTEGER
-      PRINT_TYPELESS_INTEGER (stream, builtin_type_int, (LONGEST) arg_value);
-#else
       fprintf_filtered (stream, "%ld", arg_value);
-#endif /* PRINT_TYPELESS_INTEGER */
-#endif /* PRINT_NAMELESS_INTEGER */
       first = 0;
       start += sizeof (int);
     }
@@ -2260,135 +2238,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.  */
-
-static int
-print_insn (CORE_ADDR memaddr, struct ui_file *stream)
-{
-  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
-    TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
-  else
-    TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
-
-  if (TARGET_ARCHITECTURE != NULL)
-    TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach;
-  /* else: should set .mach=0 but some disassemblers don't grok this */
-
-  TARGET_PRINT_INSN_INFO->stream = stream;
-
-  return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO);
-}
-\f
 
 void
 _initialize_printcmd (void)
@@ -2417,15 +2266,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.030188 seconds and 4 git commands to generate.