]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/stack.c
2005-02-11 Andrew Cagney <cagney@gnu.org>
[thirdparty/binutils-gdb.git] / gdb / stack.c
index cceb1c1f2c3403d74dc5138c86d78663078b94d0..3dae3a39f9deca6f0b363cc8a8c9eaefccf2564a 100644 (file)
@@ -1,8 +1,8 @@
 /* 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, 2003, 2004 Free
-   Software Foundation, Inc.
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -43,6 +43,7 @@
 #include "stack.h"
 #include "gdb_assert.h"
 #include "dictionary.h"
+#include "exceptions.h"
 #include "reggroups.h"
 #include "regcache.h"
 
@@ -349,11 +350,11 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
             2 for each recurse.  */
          val = read_var_value (sym, fi);
 
-         annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
+         annotate_arg_value (val == NULL ? NULL : value_type (val));
 
          if (val)
            {
-             val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
+             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);
@@ -512,7 +513,9 @@ print_frame_info (struct frame_info *fi, int print_level,
       if (!done)
        {
          if (deprecated_print_frame_info_listing_hook)
-           deprecated_print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0);
+           deprecated_print_frame_info_listing_hook (sal.symtab, 
+                                                     sal.line, 
+                                                     sal.line + 1, 0);
          else
            {
              /* We used to do this earlier, but that is clearly
@@ -522,7 +525,7 @@ print_frame_info (struct frame_info *fi, int print_level,
                 when we stepi/nexti into the middle of a source
                 line. Only the command line really wants this
                 behavior. Other UIs probably would like the
-                ability to decide for themselves if it is desired. */
+                ability to decide for themselves if it is desired.  */
              if (addressprint && mid_statement)
                {
                  ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi));
@@ -761,7 +764,7 @@ parse_frame_specification_1 (const char *frame_exp, const char *message,
             This avoids problems with expressions that contain
             side-effects.  */
          if (numargs >= ARRAY_SIZE (args))
-           error ("Too many args in frame specification");
+           error (_("Too many args in frame specification"));
          args[numargs++] = parse_and_eval (addr_string);
 
          do_cleanups (cleanup);
@@ -778,7 +781,7 @@ parse_frame_specification_1 (const char *frame_exp, const char *message,
 
   /* None of the remaining use the selected frame.  */
   if (selected_frame_p != NULL)
-    (*selected_frame_p) = 1;
+    (*selected_frame_p) = 0;
 
   /* Assume the single arg[0] is an integer, and try using that to
      select a frame relative to current.  */
@@ -821,7 +824,7 @@ parse_frame_specification_1 (const char *frame_exp, const char *message,
         really should be used instead of spaces to delimit; using
         spaces normally works in an expression).  */
 #ifdef SETUP_ARBITRARY_FRAME
-      error ("No frame %s", paddr_d (addrs[0]));
+      error (_("No frame %s"), paddr_d (addrs[0]));
 #endif
       /* If (s)he specifies the frame with an address, he deserves
         what (s)he gets.  Still, give the highest one that matches.
@@ -847,7 +850,7 @@ parse_frame_specification_1 (const char *frame_exp, const char *message,
   else if (numargs == 2)
     return create_new_frame (addrs[0], addrs[1]);
   else
-    error ("Too many args in frame specification");
+    error (_("Too many args in frame specification"));
 }
 
 struct frame_info *
@@ -936,14 +939,14 @@ frame_info (char *addr_exp, int from_tty)
 
   if (selected_frame_p && frame_relative_level (fi) >= 0)
     {
-      printf_filtered ("Stack level %d, frame at ",
+      printf_filtered (_("Stack level %d, frame at "),
                       frame_relative_level (fi));
       print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
       printf_filtered (":\n");
     }
   else
     {
-      printf_filtered ("Stack frame at ");
+      printf_filtered (_("Stack frame at "));
       print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
       printf_filtered (":\n");
     }
@@ -1131,7 +1134,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
   int trailing_level;
 
   if (!target_has_stack)
-    error ("No stack.");
+    error (_("No stack."));
 
   /* The following code must do two things.  First, it must
      set the variable TRAILING to the frame from which we should start
@@ -1142,7 +1145,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
   /* The target can be in a state where there is no valid frames
      (e.g., just connected). */
   if (trailing == NULL)
-    error ("No stack.");
+    error (_("No stack."));
 
   trailing_level = 0;
   if (count_exp)
@@ -1215,7 +1218,23 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
 
   /* If we've stopped before the end, mention that.  */
   if (fi && from_tty)
-    printf_filtered ("(More stack frames follow...)\n");
+    printf_filtered (_("(More stack frames follow...)\n"));
+}
+
+struct backtrace_command_args
+  {
+    char *count_exp;
+    int show_locals;
+    int from_tty;
+  };
+
+/* Stub to call backtrace_command_1 by way of an error catcher.  */
+static int
+backtrace_command_stub (void *data)
+{
+  struct backtrace_command_args *args = (struct backtrace_command_args *)data;
+  backtrace_command_1 (args->count_exp, args->show_locals, args->from_tty);
+  return 0;
 }
 
 static void
@@ -1225,6 +1244,7 @@ backtrace_command (char *arg, int from_tty)
   char **argv = (char **) NULL;
   int argIndicatingFullTrace = (-1), totArgLen = 0, argc = 0;
   char *argPtr = arg;
+  struct backtrace_command_args btargs;
 
   if (arg != (char *) NULL)
     {
@@ -1274,7 +1294,10 @@ backtrace_command (char *arg, int from_tty)
        }
     }
 
-  backtrace_command_1 (argPtr, (argIndicatingFullTrace >= 0), from_tty);
+  btargs.count_exp = argPtr;
+  btargs.show_locals = (argIndicatingFullTrace >= 0);
+  btargs.from_tty = from_tty;
+  catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR);
 
   if (argIndicatingFullTrace >= 0 && totArgLen > 0)
     xfree (argPtr);
@@ -1287,7 +1310,11 @@ static void backtrace_full_command (char *arg, int from_tty);
 static void
 backtrace_full_command (char *arg, int from_tty)
 {
-  backtrace_command_1 (arg, 1, from_tty);
+  struct backtrace_command_args btargs;
+  btargs.count_exp = arg;
+  btargs.show_locals = 1;
+  btargs.from_tty = from_tty;
+  catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR);
 }
 \f
 
@@ -1433,9 +1460,9 @@ print_frame_label_vars (struct frame_info *fi, int this_level_only,
       int last_index;
 
       if (bl != blockvector_for_pc (end, &index))
-       error ("blockvector blotch");
+       error (_("blockvector blotch"));
       if (BLOCKVECTOR_BLOCK (bl, index) != block)
-       error ("blockvector botch");
+       error (_("blockvector botch"));
       last_index = BLOCKVECTOR_NBLOCKS (bl);
       index += 1;
 
@@ -1708,7 +1735,7 @@ up_silently_base (char *count_exp)
 
   fi = find_relative_frame (get_selected_frame ("No stack."), &count1);
   if (count1 != 0 && count_exp == 0)
-    error ("Initial frame selected; you cannot go up.");
+    error (_("Initial frame selected; you cannot go up."));
   select_frame (fi);
 }
 
@@ -1746,7 +1773,7 @@ down_silently_base (char *count_exp)
          impossible), but "down 9999" can be used to mean go all the way
          down without getting an error.  */
 
-      error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
+      error (_("Bottom (i.e., innermost) frame selected; you cannot go down."));
     }
 
   select_frame (frame);
@@ -1797,7 +1824,7 @@ return_command (char *retval_exp, int from_tty)
 
       /* Make sure the value is fully evaluated.  It may live in the
          stack frame we're about to pop.  */
-      if (VALUE_LAZY (return_value))
+      if (value_lazy (return_value))
        value_fetch_lazy (return_value);
 
       if (TYPE_CODE (return_type) == TYPE_CODE_VOID)
@@ -1839,13 +1866,13 @@ If you continue, the return value that you specified will be ignored.\n";
     {
       int confirmed;
       if (thisfun == NULL)
-       confirmed = query ("%sMake selected stack frame return now? ",
+       confirmed = query (_("%sMake selected stack frame return now? "),
                           query_prefix);
       else
-       confirmed = query ("%sMake %s return now? ", query_prefix,
+       confirmed = query (_("%sMake %s return now? "), query_prefix,
                           SYMBOL_PRINT_NAME (thisfun));
       if (!confirmed)
-       error ("Not confirmed");
+       error (_("Not confirmed"));
     }
 
   /* NOTE: cagney/2003-01-18: Is this silly?  Rather than pop each
@@ -1861,7 +1888,7 @@ If you continue, the return value that you specified will be ignored.\n";
        if (frame_id_inner (selected_id, get_frame_id (get_current_frame ())))
          /* Caught in the safety net, oops!  We've gone way past the
              selected frame.  */
-         error ("Problem while popping stack frames (corrupt stack?)");
+         error (_("Problem while popping stack frames (corrupt stack?)"));
        frame_pop (get_current_frame ());
       }
   }
@@ -1873,13 +1900,13 @@ If you continue, the return value that you specified will be ignored.\n";
   /* Store RETURN_VAUE in the just-returned register set.  */
   if (return_value != NULL)
     {
-      struct type *return_type = VALUE_TYPE (return_value);
+      struct type *return_type = value_type (return_value);
       gdb_assert (gdbarch_return_value (current_gdbarch, return_type,
                                        NULL, NULL, NULL)
                  == RETURN_VALUE_REGISTER_CONVENTION);
       gdbarch_return_value (current_gdbarch, return_type,
                            current_regcache, NULL /*read*/,
-                           VALUE_CONTENTS (return_value) /*write*/);
+                           value_contents (return_value) /*write*/);
     }
 
   /* If we are at the end of a call dummy now, pop the dummy frame
@@ -1950,7 +1977,7 @@ func_command (char *arg, int from_tty)
     xfree (func_bounds);
 
   if (!found)
-    printf_filtered ("'%s' not within current stack frame.\n", arg);
+    printf_filtered (_("'%s' not within current stack frame.\n"), arg);
   else if (fp != deprecated_selected_frame)
     select_and_print_frame (fp);
 }