* gdb/fileio.h: New file.
[deliverable/binutils-gdb.git] / gdb / stack.c
index a3a55c2f1613efe6649f57b7278bf2b5151d1817..a1a786bc88067c110d7bb554e4831cc6c7019734 100644 (file)
@@ -1,7 +1,7 @@
 /* Print and select stack frames for GDB, the GNU debugger.
 
    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.
@@ -39,6 +39,9 @@
 #include "inferior.h"
 #include "annotate.h"
 #include "ui-out.h"
+#include "block.h"
+#include "stack.h"
+#include "gdb_assert.h"
 
 /* Prototypes for exported functions. */
 
@@ -70,8 +73,6 @@ void frame_command (char *, int);
 
 static void current_frame_command (char *, int);
 
-static void select_frame_command (char *, int);
-
 static void print_frame_arg_vars (struct frame_info *, struct ui_file *);
 
 static void catch_info (char *, int);
@@ -98,10 +99,6 @@ static void print_frame (struct frame_info *fi,
                         int args, 
                         struct symtab_and_line sal);
 
-static void print_frame_info_base (struct frame_info *, int, int, int);
-
-static void print_stack_frame_base (struct frame_info *, int, int);
-
 static void backtrace_command (char *, int);
 
 struct frame_info *parse_frame_specification (char *);
@@ -127,21 +124,6 @@ struct print_stack_frame_args
     int args;
   };
 
-static int print_stack_frame_base_stub (char *);
-
-/* Show and print the frame arguments.
-   Pass the args the way catch_errors wants them.  */
-static int show_and_print_stack_frame_stub (void *args);
-static int
-show_and_print_stack_frame_stub (void *args)
-{
-  struct print_stack_frame_args *p = (struct print_stack_frame_args *) args;
-
-  print_frame_info (p->fi, p->level, p->source, p->args);
-
-  return 0;
-}
-
 /* Show or print the frame arguments.
    Pass the args the way catch_errors wants them.  */
 static int print_stack_frame_stub (void *args);
@@ -150,37 +132,11 @@ print_stack_frame_stub (void *args)
 {
   struct print_stack_frame_args *p = (struct print_stack_frame_args *) args;
 
-  print_frame_info_base (p->fi, p->level, p->source, p->args);
-  return 0;
-}
-
-/* Print a stack frame briefly.  FRAME_INFI should be the frame info
-   and LEVEL should be its level in the stack (or -1 for level not
-   defined). */
-
-/* Pass the args the way catch_errors wants them.  */
-static int
-print_stack_frame_base_stub (char *args)
-{
-  struct print_stack_frame_args *p = (struct print_stack_frame_args *) args;
-
-  print_frame_info_base (p->fi, p->level, p->source, p->args);
-  return 0;
-}
-
-/* print the frame arguments to the terminal.  
-   Pass the args the way catch_errors wants them.  */
-static int print_only_stack_frame_stub (void *);
-static int
-print_only_stack_frame_stub (void *args)
-{
-  struct print_stack_frame_args *p = (struct print_stack_frame_args *) args;
-
-  print_frame_info_base (p->fi, p->level, p->source, p->args);
+  print_frame_info (p->fi, p->level, p->source, p->args);
   return 0;
 }
 
-/* Print a stack frame briefly.  FRAME_INFI should be the frame info
+/* Show or print a stack frame briefly.  FRAME_INFI should be the frame info
    and LEVEL should be its level in the stack (or -1 for level not defined).
    This prints the level, the function executing, the arguments,
    and the file name and line number.
@@ -190,8 +146,8 @@ print_only_stack_frame_stub (void *args)
    If SOURCE is 1, print the source line as well.
    If SOURCE is -1, print ONLY the source line.  */
 
-static void
-print_stack_frame_base (struct frame_info *fi, int level, int source)
+void
+print_stack_frame (struct frame_info *fi, int level, int source)
 {
   struct print_stack_frame_args args;
 
@@ -200,97 +156,255 @@ print_stack_frame_base (struct frame_info *fi, int level, int source)
   args.source = source;
   args.args = 1;
 
-  catch_errors (print_stack_frame_stub, &args, "", RETURN_MASK_ALL);
+  catch_errors (print_stack_frame_stub, (char *) &args, "", RETURN_MASK_ALL);
+}  
+
+struct print_args_args
+{
+  struct symbol *func;
+  struct frame_info *fi;
+  struct ui_file *stream;
+};
+
+static int print_args_stub (void *);
+
+/* Print nameless args on STREAM.
+   FI is the frameinfo for this frame, START is the offset
+   of the first nameless arg, and NUM is the number of nameless args to
+   print.  FIRST is nonzero if this is the first argument (not just
+   the first nameless arg).  */
+
+static void
+print_frame_nameless_args (struct frame_info *fi, long start, int num,
+                          int first, struct ui_file *stream)
+{
+  int i;
+  CORE_ADDR argsaddr;
+  long arg_value;
+
+  for (i = 0; i < num; i++)
+    {
+      QUIT;
+      argsaddr = get_frame_args_address (fi);
+      if (!argsaddr)
+       return;
+      arg_value = read_memory_integer (argsaddr + start, sizeof (int));
+      if (!first)
+       fprintf_filtered (stream, ", ");
+      fprintf_filtered (stream, "%ld", arg_value);
+      first = 0;
+      start += sizeof (int);
+    }
 }
 
-/* Show and print a stack frame briefly.  FRAME_INFI should be the frame info
-   and LEVEL should be its level in the stack (or -1 for level not defined).
-   This prints the level, the function executing, the arguments,
-   and the file name and line number.
-   If the pc is not at the beginning of the source line,
-   the actual pc is printed at the beginning.
+/* Print the arguments of a stack frame, given the function FUNC
+   running in that frame (as a symbol), the info on the frame,
+   and the number of args according to the stack frame (or -1 if unknown).  */
 
-   If SOURCE is 1, print the source line as well.
-   If SOURCE is -1, print ONLY the source line.  */
+/* References here and elsewhere to "number of args according to the
+   stack frame" appear in all cases to refer to "number of ints of args
+   according to the stack frame".  At least for VAX, i386, isi.  */
 
-void
-show_and_print_stack_frame (struct frame_info *fi, int level, int source)
+static void
+print_frame_args (struct symbol *func, struct frame_info *fi, int num,
+                 struct ui_file *stream)
 {
-  struct print_stack_frame_args args;
+  struct block *b = NULL;
+  int first = 1;
+  register int i;
+  register struct symbol *sym;
+  struct value *val;
+  /* Offset of next stack argument beyond the one we have seen that is
+     at the highest offset.
+     -1 if we haven't come to a stack argument yet.  */
+  long highest_offset = -1;
+  int arg_size;
+  /* Number of ints of arguments that we have printed so far.  */
+  int args_printed = 0;
+  struct cleanup *old_chain, *list_chain;
+  struct ui_stream *stb;
 
-  args.fi = fi;
-  args.level = level;
-  args.source = source;
-  args.args = 1;
+  stb = ui_out_stream_new (uiout);
+  old_chain = make_cleanup_ui_out_stream_delete (stb);
 
-  catch_errors (show_and_print_stack_frame_stub, &args, "", RETURN_MASK_ALL);
-}
+  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;
 
-/* Show or print a stack frame briefly.  FRAME_INFI should be the frame info
-   and LEVEL should be its level in the stack (or -1 for level not defined).
-   This prints the level, the function executing, the arguments,
-   and the file name and line number.
-   If the pc is not at the beginning of the source line,
-   the actual pc is printed at the beginning.
+         /* Keep track of the highest stack argument offset seen, and
+            skip over any kinds of symbols we don't care about.  */
 
-   If SOURCE is 1, print the source line as well.
-   If SOURCE is -1, print ONLY the source line.  */
+         switch (SYMBOL_CLASS (sym))
+           {
+           case LOC_ARG:
+           case LOC_REF_ARG:
+             {
+               long current_offset = SYMBOL_VALUE (sym);
+               arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
+
+               /* Compute address of next argument by adding the size of
+                  this argument and rounding to an int boundary.  */
+               current_offset =
+                 ((current_offset + arg_size + sizeof (int) - 1)
+                  & ~(sizeof (int) - 1));
+
+               /* If this is the highest offset seen yet, set highest_offset.  */
+               if (highest_offset == -1
+                   || (current_offset > highest_offset))
+                 highest_offset = current_offset;
+
+               /* Add the number of ints we're about to print to args_printed.  */
+               args_printed += (arg_size + sizeof (int) - 1) / sizeof (int);
+             }
+
+             /* We care about types of symbols, but don't need to keep track of
+                stack offsets in them.  */
+           case LOC_REGPARM:
+           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.  */
+           default:
+             continue;
+           }
 
-void
-print_stack_frame (struct frame_info *fi, int level, int source)
-{
-  struct print_stack_frame_args args;
+         /* We have to look up the symbol because arguments can have
+            two entries (one a parameter, one a local) and the one we
+            want is the local, which lookup_symbol will find for us.
+            This includes gcc1 (not gcc2) on the sparc when passing a
+            small structure and gcc2 when the argument type is float
+            and it is passed as a double and converted to float by
+            the prologue (in the latter case the type of the LOC_ARG
+            symbol is double and the type of the LOC_LOCAL symbol is
+            float).  */
+         /* But if the parameter name is null, don't try it.
+            Null parameter names occur on the RS/6000, for traceback tables.
+            FIXME, should we even print them?  */
 
-  args.fi = fi;
-  args.level = level;
-  args.source = source;
-  args.args = 1;
+         if (*DEPRECATED_SYMBOL_NAME (sym))
+           {
+             struct symbol *nsym;
+             nsym = lookup_symbol
+               (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
+                    it was passed on the stack and loaded into a register,
+                    or passed in a register and stored in a stack slot.
+                    GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
+
+                    Reasons for using the LOC_ARG:
+                    (1) because find_saved_registers may be slow for remote
+                    debugging,
+                    (2) because registers are often re-used and stack slots
+                    rarely (never?) are.  Therefore using the stack slot is
+                    much less likely to print garbage.
+
+                    Reasons why we might want to use the LOC_REGISTER:
+                    (1) So that the backtrace prints the same value as
+                    "print foo".  I see no compelling reason why this needs
+                    to be the case; having the backtrace print the value which
+                    was passed in, and "print foo" print the value as modified
+                    within the called function, makes perfect sense to me.
+
+                    Additional note:  It might be nice if "info args" displayed
+                    both values.
+                    One more note:  There is a case with sparc structure passing
+                    where we need to use the LOC_REGISTER, but this is dealt with
+                    by creating a single LOC_REGPARM in symbol reading.  */
+
+                 /* Leave sym (the LOC_ARG) alone.  */
+                 ;
+               }
+             else
+               sym = nsym;
+           }
 
-  catch_errors (print_stack_frame_stub, (char *) &args, "", RETURN_MASK_ALL);
-}
+         /* Print the current arg.  */
+         if (!first)
+           ui_out_text (uiout, ", ");
+         ui_out_wrap_hint (uiout, "    ");
 
-/* Print a stack frame briefly.  FRAME_INFI should be the frame info
-   and LEVEL should be its level in the stack (or -1 for level not defined).
-   This prints the level, the function executing, the arguments,
-   and the file name and line number.
-   If the pc is not at the beginning of the source line,
-   the actual pc is printed at the beginning.
+         annotate_arg_begin ();
 
-   If SOURCE is 1, print the source line as well.
-   If SOURCE is -1, print ONLY the source line.  */
+         list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+         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 ();
+         ui_out_text (uiout, "=");
 
-void
-print_only_stack_frame (struct frame_info *fi, int level, int source)
-{
-  struct print_stack_frame_args args;
+         /* Avoid value_print because it will deref ref parameters.  We just
+            want to print their addresses.  Print ??? for args whose address
+            we do not know.  We pass 2 as "recurse" to val_print because our
+            standard indentation here is 4 spaces, and val_print indents
+            2 for each recurse.  */
+         val = read_var_value (sym, fi);
 
-  args.fi = fi;
-  args.level = level;
-  args.source = source;
-  args.args = 1;
+         annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
 
-  catch_errors (print_only_stack_frame_stub, &args, "", RETURN_MASK_ALL);
-}
+         if (val)
+           {
+             val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
+                        VALUE_ADDRESS (val),
+                        stb->stream, 0, 0, 2, Val_no_prettyprint);
+             ui_out_field_stream (uiout, "value", stb);
+           }
+         else
+           ui_out_text (uiout, "???");
 
-struct print_args_args
-{
-  struct symbol *func;
-  struct frame_info *fi;
-  struct ui_file *stream;
-};
+         /* Invoke ui_out_tuple_end.  */
+         do_cleanups (list_chain);
+
+         annotate_arg_end ();
+
+         first = 0;
+       }
+    }
+
+  /* Don't print nameless args in situations where we don't know
+     enough about the stack to find them.  */
+  if (num != -1)
+    {
+      long start;
 
-static int print_args_stub (PTR);
+      if (highest_offset == -1)
+       start = FRAME_ARGS_SKIP;
+      else
+       start = highest_offset;
+
+      print_frame_nameless_args (fi, start, num - args_printed,
+                                first, stream);
+    }
+  do_cleanups (old_chain);
+}
 
 /* Pass the args the way catch_errors wants them.  */
 
 static int
-print_args_stub (PTR args)
+print_args_stub (void *args)
 {
   int numargs;
   struct print_args_args *p = (struct print_args_args *) args;
 
-  numargs = FRAME_NUM_ARGS (p->fi);
+  if (FRAME_NUM_ARGS_P ())
+    {
+      numargs = FRAME_NUM_ARGS (p->fi);
+      gdb_assert (numargs >= 0);
+    }
+  else
+    numargs = -1;
   print_frame_args (p->func, p->fi, numargs, p->stream);
   return 0;
 }
@@ -305,15 +419,19 @@ print_args_stub (PTR args)
    LOCATION: Print only location 
    LOC_AND_SRC: Print location and source line.  */
 
-static void
-print_frame_info_base (struct frame_info *fi, int level, int source, int args)
+void
+print_frame_info (struct frame_info *fi, int level, int source, int args)
 {
   struct symtab_and_line sal;
   int source_print;
   int location_print;
 
-  if (get_frame_type (fi) == DUMMY_FRAME)
+  if (get_frame_type (fi) == DUMMY_FRAME
+      || get_frame_type (fi) == SIGTRAMP_FRAME)
     {
+      struct cleanup *uiout_cleanup
+       = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
+
       annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi));
 
       /* Do this regardless of SOURCE because we don't have any source
@@ -323,25 +441,27 @@ print_frame_info_base (struct frame_info *fi, int level, int source, int args)
           ui_out_text (uiout, "#");
           ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
         }
-      annotate_function_call ();
-      printf_filtered ("<function called from gdb>\n");
-      annotate_frame_end ();
-      return;
-    }
-  if ((get_frame_type (fi) == SIGTRAMP_FRAME))
-    {
-      annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi));
+      if (ui_out_is_mi_like_p (uiout))
+        {
+          annotate_frame_address ();
+          ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi));
+          annotate_frame_address_end ();
+        }
 
-      /* Do this regardless of SOURCE because we don't have any source
-         to list for this frame.  */
-      if (level >= 0)
+      if (get_frame_type (fi) == DUMMY_FRAME)
         {
-          ui_out_text (uiout, "#");
-          ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
+          annotate_function_call ();
+          ui_out_field_string (uiout, "func", "<function called from gdb>");
+       }
+      else if (get_frame_type (fi) == SIGTRAMP_FRAME)
+        {
+         annotate_signal_handler_caller ();
+          ui_out_field_string (uiout, "func", "<signal handler called>");
         }
-      annotate_signal_handler_caller ();
-      printf_filtered ("<signal handler called>\n");
+      ui_out_text (uiout, "\n");
       annotate_frame_end ();
+
+      do_cleanups (uiout_cleanup);
       return;
     }
 
@@ -464,12 +584,12 @@ print_frame (struct frame_info *fi,
          /* We also don't know anything about the function besides
             its address and name.  */
          func = 0;
-         funname = SYMBOL_NAME (msymbol);
+         funname = DEPRECATED_SYMBOL_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
       else
        {
-         /* I'd like to use SYMBOL_SOURCE_NAME() here, to display the
+         /* I'd like to use SYMBOL_PRINT_NAME() here, to display the
             demangled name that we already have stored in the symbol
             table, but we stored a version with DMGL_PARAMS turned
             on, and here we don't want to display parameters. So call
@@ -481,7 +601,7 @@ print_frame (struct frame_info *fi,
             here, while we still have our hands on the function
             symbol.) */
          char *demangled;
-         funname = SYMBOL_NAME (func);
+         funname = DEPRECATED_SYMBOL_NAME (func);
          funlang = SYMBOL_LANGUAGE (func);
          if (funlang == language_cplus)
            {
@@ -490,7 +610,7 @@ print_frame (struct frame_info *fi,
                /* If the demangler fails, try the demangled name from
                   the symbol table. This'll have parameters, but
                   that's preferable to diplaying a mangled name. */
-               funname = SYMBOL_SOURCE_NAME (func);
+               funname = SYMBOL_PRINT_NAME (func);
            }
        }
     }
@@ -499,7 +619,7 @@ print_frame (struct frame_info *fi,
       struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (frame_address_in_block (fi));
       if (msymbol != NULL)
        {
-         funname = SYMBOL_NAME (msymbol);
+         funname = DEPRECATED_SYMBOL_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
@@ -581,16 +701,6 @@ print_frame (struct frame_info *fi,
   do_cleanups (old_chain);
 }
 \f
-
-/* Show or print the frame info.  If this is the tui, it will be shown in 
-   the source display */
-void
-print_frame_info (struct frame_info *fi, register int level, int source,
-                 int args)
-{
-  print_frame_info_base (fi, level, source, args);
-}
-
 /* Show the frame info.  If this is the tui, it will be shown in 
    the source display otherwise, nothing is done */
 void
@@ -718,16 +828,6 @@ parse_frame_specification (char *frame_exp)
   /* NOTREACHED */
 }
 
-/* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
-   that if it is unsure about the answer, it returns 0
-   instead of guessing (this happens on the VAX and i960, for example).
-
-   On most machines, we never have to guess about the args address,
-   so FRAME_ARGS_ADDRESS{,_CORRECT} are the same.  */
-#if !defined (FRAME_ARGS_ADDRESS_CORRECT)
-#define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
-#endif
-
 /* Print verbosely the selected frame or the frame at address ADDR.
    This means absolutely all information in the frame is printed.  */
 
@@ -742,10 +842,25 @@ frame_info (char *addr_exp, int from_tty)
   int i, count, numregs;
   char *funname = 0;
   enum language funlang = language_unknown;
+  const char *pc_regname;
 
   if (!target_has_stack)
     error ("No stack.");
 
+  /* Name of the value returned by get_frame_pc().  Per comments, "pc"
+     is not a good name.  */
+  if (PC_REGNUM >= 0)
+    /* OK, this is weird.  The PC_REGNUM hardware register's value can
+       easily not match that of the internal value returned by
+       get_frame_pc().  */
+    pc_regname = REGISTER_NAME (PC_REGNUM);
+  else
+    /* But then, this is weird to.  Even without PC_REGNUM, an
+       architectures will often have a hardware register called "pc",
+       and that register's value, again, can easily not match
+       get_frame_pc().  */
+    pc_regname = "pc";
+
   fi = parse_frame_specification (addr_exp);
   if (fi == NULL)
     error ("Invalid frame specified.");
@@ -757,7 +872,7 @@ frame_info (char *addr_exp, int from_tty)
   s = find_pc_symtab (get_frame_pc (fi));
   if (func)
     {
-      /* I'd like to use SYMBOL_SOURCE_NAME() here, to display
+      /* I'd like to use SYMBOL_PRINT_NAME() here, to display
        * the demangled name that we already have stored in
        * the symbol table, but we stored a version with
        * DMGL_PARAMS turned on, and here we don't want
@@ -771,7 +886,7 @@ frame_info (char *addr_exp, int from_tty)
        * have our hands on the function symbol.)
        */
       char *demangled;
-      funname = SYMBOL_NAME (func);
+      funname = DEPRECATED_SYMBOL_NAME (func);
       funlang = SYMBOL_LANGUAGE (func);
       if (funlang == language_cplus)
        {
@@ -781,7 +896,7 @@ frame_info (char *addr_exp, int from_tty)
           * but that's preferable to diplaying a mangled name.
           */
          if (demangled == NULL)
-           funname = SYMBOL_SOURCE_NAME (func);
+           funname = SYMBOL_PRINT_NAME (func);
        }
     }
   else
@@ -789,7 +904,7 @@ frame_info (char *addr_exp, int from_tty)
       register struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
       if (msymbol != NULL)
        {
-         funname = SYMBOL_NAME (msymbol);
+         funname = DEPRECATED_SYMBOL_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
@@ -808,7 +923,7 @@ frame_info (char *addr_exp, int from_tty)
       print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
       printf_filtered (":\n");
     }
-  printf_filtered (" %s = ", REGISTER_NAME (PC_REGNUM));
+  printf_filtered (" %s = ", pc_regname);
   print_address_numeric (get_frame_pc (fi), 1, gdb_stdout);
 
   wrap_here ("   ");
@@ -823,7 +938,7 @@ frame_info (char *addr_exp, int from_tty)
     printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
   puts_filtered ("; ");
   wrap_here ("    ");
-  printf_filtered ("saved %s ", REGISTER_NAME (PC_REGNUM));
+  printf_filtered ("saved %s ", pc_regname);
   print_address_numeric (frame_pc_unwind (fi), 1, gdb_stdout);
   printf_filtered ("\n");
 
@@ -861,7 +976,7 @@ frame_info (char *addr_exp, int from_tty)
 
   {
     /* Address of the argument list for this frame, or 0.  */
-    CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);
+    CORE_ADDR arg_list = get_frame_args_address (fi);
     /* Number of args for this frame, or -1 if unknown.  */
     int numargs;
 
@@ -873,22 +988,29 @@ frame_info (char *addr_exp, int from_tty)
        print_address_numeric (arg_list, 1, gdb_stdout);
        printf_filtered (",");
 
-       numargs = FRAME_NUM_ARGS (fi);
-       if (numargs < 0)
-         puts_filtered (" args: ");
-       else if (numargs == 0)
-         puts_filtered (" no args.");
-       else if (numargs == 1)
-         puts_filtered (" 1 arg: ");
+       if (!FRAME_NUM_ARGS_P ())
+         {
+           numargs = -1;
+           puts_filtered (" args: ");
+         }
        else
-         printf_filtered (" %d args: ", numargs);
+         {
+           numargs = FRAME_NUM_ARGS (fi);
+           gdb_assert (numargs >= 0);
+           if (numargs == 0)
+             puts_filtered (" no args.");
+           else if (numargs == 1)
+             puts_filtered (" 1 arg: ");
+           else
+             printf_filtered (" %d args: ", numargs);
+         }
        print_frame_args (func, fi, numargs, gdb_stdout);
        puts_filtered ("\n");
       }
   }
   {
     /* Address of the local variables for this frame, or 0.  */
-    CORE_ADDR arg_list = FRAME_LOCALS_ADDRESS (fi);
+    CORE_ADDR arg_list = get_frame_locals_address (fi);
 
     if (arg_list == 0)
       printf_filtered (" Locals at unknown address,");
@@ -900,9 +1022,9 @@ frame_info (char *addr_exp, int from_tty)
       }
   }
 
-  if (FRAME_INIT_SAVED_REGS_P ()
+  if (DEPRECATED_FRAME_INIT_SAVED_REGS_P ()
       && get_frame_saved_regs (fi) == NULL)
-    FRAME_INIT_SAVED_REGS (fi);
+    DEPRECATED_FRAME_INIT_SAVED_REGS (fi);
   /* Print as much information as possible on the location of all the
      registers.  */
   {
@@ -927,11 +1049,14 @@ frame_info (char *addr_exp, int from_tty)
                               &realnum, NULL);
        if (!optimized && lval == not_lval)
          {
-           void *value = alloca (MAX_REGISTER_RAW_SIZE);
+           char value[MAX_REGISTER_SIZE];
            CORE_ADDR sp;
            frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr,
                                   &realnum, value);
-           sp = extract_address (value, REGISTER_RAW_SIZE (SP_REGNUM));
+           /* NOTE: cagney/2003-05-22: This is assuming that the
+               stack pointer was packed as an unsigned integer.  That
+               may or may not be valid.  */
+           sp = extract_unsigned_integer (value, REGISTER_RAW_SIZE (SP_REGNUM));
            printf_filtered (" Previous frame's sp is ");
            print_address_numeric (sp, 1, gdb_stdout);
            printf_filtered ("\n");
@@ -1099,7 +1224,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
          means further attempts to backtrace would fail (on the other
          hand, perhaps the code does or could be fixed to make sure
          the frame->prev field gets set to NULL in that case).  */
-      print_frame_info_base (fi, trailing_level + i, 0, 1);
+      print_frame_info (fi, trailing_level + i, 0, 1);
       if (show_locals)
        print_frame_local_vars (fi, 1, gdb_stdout);
     }
@@ -1201,10 +1326,11 @@ print_block_frame_locals (struct block *b, register struct frame_info *fi,
        case LOC_REGISTER:
        case LOC_STATIC:
        case LOC_BASEREG:
+       case LOC_COMPUTED:
          values_printed = 1;
          for (j = 0; j < num_tabs; j++)
            fputs_filtered ("\t", stream);
-         fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
+         fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
          fputs_filtered (" = ", stream);
          print_variable_value (sym, fi, stream);
          fprintf_filtered (stream, "\n");
@@ -1230,7 +1356,7 @@ print_block_frame_labels (struct block *b, int *have_default,
 
   ALL_BLOCK_SYMBOLS (b, i, sym)
     {
-      if (STREQ (SYMBOL_NAME (sym), "default"))
+      if (STREQ (DEPRECATED_SYMBOL_NAME (sym), "default"))
        {
          if (*have_default)
            continue;
@@ -1241,7 +1367,7 @@ print_block_frame_labels (struct block *b, int *have_default,
          struct symtab_and_line sal;
          sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
          values_printed = 1;
-         fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
+         fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
          if (addressprint)
            {
              fprintf_filtered (stream, " ");
@@ -1427,8 +1553,9 @@ print_frame_arg_vars (register struct frame_info *fi,
        case LOC_REGPARM:
        case LOC_REGPARM_ADDR:
        case LOC_BASEREG_ARG:
+       case LOC_COMPUTED_ARG:
          values_printed = 1;
-         fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
+         fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
          fputs_filtered (" = ", stream);
 
          /* We have to look up the symbol because arguments can have
@@ -1442,8 +1569,8 @@ print_frame_arg_vars (register struct frame_info *fi,
             float).  There are also LOC_ARG/LOC_REGISTER pairs which
             are not combined in symbol-reading.  */
 
-         sym2 = lookup_symbol (SYMBOL_NAME (sym),
-                  b, VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL);
+         sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
+                  b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL);
          print_variable_value (sym2, fi, stream);
          fprintf_filtered (stream, "\n");
          break;
@@ -1568,14 +1695,7 @@ find_relative_frame (register struct frame_info *frame,
    and select it.  See parse_frame_specification for more info on proper
    frame expressions. */
 
-/* ARGSUSED */
 void
-select_frame_command_wrapper (char *level_exp, int from_tty)
-{
-  select_frame_command (level_exp, from_tty);
-}
-
-static void
 select_frame_command (char *level_exp, int from_tty)
 {
   struct frame_info *frame;
@@ -1599,8 +1719,8 @@ void
 frame_command (char *level_exp, int from_tty)
 {
   select_frame_command (level_exp, from_tty);
-  show_and_print_stack_frame (deprecated_selected_frame,
-                             frame_relative_level (deprecated_selected_frame), 1);
+  print_stack_frame (deprecated_selected_frame,
+                    frame_relative_level (deprecated_selected_frame), 1);
 }
 
 /* The XDB Compatibility command to print the current frame. */
@@ -1610,7 +1730,7 @@ current_frame_command (char *level_exp, int from_tty)
 {
   if (target_has_stack == 0 || deprecated_selected_frame == 0)
     error ("No stack.");
-  print_only_stack_frame (deprecated_selected_frame,
+  print_stack_frame (deprecated_selected_frame,
                          frame_relative_level (deprecated_selected_frame), 1);
 }
 
@@ -1647,8 +1767,8 @@ static void
 up_command (char *count_exp, int from_tty)
 {
   up_silently_base (count_exp);
-  show_and_print_stack_frame (deprecated_selected_frame,
-                             frame_relative_level (deprecated_selected_frame), 1);
+  print_stack_frame (deprecated_selected_frame,
+                    frame_relative_level (deprecated_selected_frame), 1);
 }
 
 /* Select the frame down one or COUNT stack levels
@@ -1694,8 +1814,8 @@ static void
 down_command (char *count_exp, int from_tty)
 {
   down_silently_base (count_exp);
-  show_and_print_stack_frame (deprecated_selected_frame,
-                             frame_relative_level (deprecated_selected_frame), 1);
+  print_stack_frame (deprecated_selected_frame,
+                    frame_relative_level (deprecated_selected_frame), 1);
 }
 \f
 void
@@ -1740,7 +1860,7 @@ return_command (char *retval_exp, int from_tty)
     {
       if (thisfun != 0)
        {
-         if (!query ("Make %s return now? ", SYMBOL_SOURCE_NAME (thisfun)))
+         if (!query ("Make %s return now? ", SYMBOL_PRINT_NAME (thisfun)))
            {
              error ("Not confirmed.");
              /* NOTREACHED */
@@ -1750,18 +1870,26 @@ return_command (char *retval_exp, int from_tty)
        error ("Not confirmed.");
     }
 
+  /* FIXME: cagney/2003-01-18: Rather than pop each frame in turn,
+     this code should just go straight to the relevant frame and pop
+     that.  */
+
   /* Do the real work.  Pop until the specified frame is current.  We
-     use this method because the deprecated_selected_frame is not valid after
-     a POP_FRAME.  The pc comparison makes this work even if the
-     selected frame shares its fp with another frame.  */
+     use this method because the deprecated_selected_frame is not
+     valid after a frame_pop().  The pc comparison makes this work
+     even if the selected frame shares its fp with another frame.  */
+
+  /* FIXME: cagney/32003-03-12: This code should use frame_id_eq().
+     Unfortunatly, that function doesn't yet include the PC in any
+     frame ID comparison.  */
 
   while (selected_frame_addr != get_frame_base (frame = get_current_frame ())
         || selected_frame_pc != get_frame_pc (frame))
-    POP_FRAME;
+    frame_pop (get_current_frame ());
 
   /* Then pop that frame.  */
 
-  POP_FRAME;
+  frame_pop (get_current_frame ());
 
   /* Compute the return value (if any) and store in the place
      for return values.  */
@@ -1771,9 +1899,14 @@ return_command (char *retval_exp, int from_tty)
 
   /* If we are at the end of a call dummy now, pop the dummy frame too.  */
 
+  /* FIXME: cagney/2003-01-18: This is silly.  Instead of popping all
+     the frames except the dummy, and then, as an afterthought,
+     popping the dummy frame, this code should just pop through to the
+     dummy frame.  */
+  
   if (CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (),
                                get_frame_base (get_current_frame ())))
-    POP_FRAME;
+    frame_pop (get_current_frame ());
 
   /* If interactive, print the frame that is now current.  */
 
This page took 0.036862 seconds and 4 git commands to generate.