libiberty/md5: fix strict alias warnings
[deliverable/binutils-gdb.git] / gdb / stack.c
index 2c2797e81b420d6b5a670af89c7cadd6a425bf9f..51747ead38e78028bd31962d5a77589d349c662c 100644 (file)
@@ -499,7 +499,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
   long highest_offset = -1;
   /* Number of ints of arguments that we have printed so far.  */
   int args_printed = 0;
-  struct cleanup *old_chain, *list_chain;
+  struct cleanup *old_chain;
   struct ui_file *stb;
   /* True if we should print arguments, false otherwise.  */
   int print_args = strcmp (print_frame_arguments, "none");
@@ -1727,7 +1727,20 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
          the frame->prev field gets set to NULL in that case).  */
       print_frame_info (fi, 1, LOCATION, 1);
       if (show_locals)
-       print_frame_local_vars (fi, 1, gdb_stdout);
+       {
+         struct frame_id frame_id = get_frame_id (fi);
+
+         print_frame_local_vars (fi, 1, gdb_stdout);
+
+         /* print_frame_local_vars invalidates FI.  */
+         fi = frame_find_by_id (frame_id);
+         if (fi == NULL)
+           {
+             trailing = NULL;
+             warning (_("Unable to restore previously selected frame."));
+             break;
+           }
+       }
 
       /* Save the last frame to check for error conditions.  */
       trailing = fi;
@@ -1919,7 +1932,7 @@ iterate_over_block_local_vars (struct block *block,
 
 struct print_variable_and_value_data
 {
-  struct frame_info *frame;
+  struct frame_id frame_id;
   int num_tabs;
   struct ui_file *stream;
   int values_printed;
@@ -1933,12 +1946,28 @@ do_print_variable_and_value (const char *print_name,
                             void *cb_data)
 {
   struct print_variable_and_value_data *p = cb_data;
+  struct frame_info *frame;
+
+  frame = frame_find_by_id (p->frame_id);
+  if (frame == NULL)
+    {
+      warning (_("Unable to restore previously selected frame."));
+      return;
+    }
+
+  print_variable_and_value (print_name, sym, frame, p->stream, p->num_tabs);
+
+  /* print_variable_and_value invalidates FRAME.  */
+  frame = NULL;
 
-  print_variable_and_value (print_name, sym,
-                           p->frame, p->stream, p->num_tabs);
   p->values_printed = 1;
 }
 
+/* Print all variables from the innermost up to the function block of FRAME.
+   Print them with values to STREAM indented by NUM_TABS.
+
+   This function will invalidate FRAME.  */
+
 static void
 print_frame_local_vars (struct frame_info *frame, int num_tabs,
                        struct ui_file *stream)
@@ -1961,7 +1990,7 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
       return;
     }
 
-  cb_data.frame = frame;
+  cb_data.frame_id = get_frame_id (frame);
   cb_data.num_tabs = 4 * num_tabs;
   cb_data.stream = stream;
   cb_data.values_printed = 0;
@@ -1970,6 +1999,9 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
                                 do_print_variable_and_value,
                                 &cb_data);
 
+  /* do_print_variable_and_value invalidates FRAME.  */
+  frame = NULL;
+
   if (!cb_data.values_printed)
     fprintf_filtered (stream, _("No locals.\n"));
 }
@@ -2016,6 +2048,11 @@ iterate_over_block_arg_vars (struct block *b,
     }
 }
 
+/* Print all argument variables of the function of FRAME.
+   Print them with values to STREAM.
+
+   This function will invalidate FRAME.  */
+
 static void
 print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
 {
@@ -2036,7 +2073,7 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
       return;
     }
 
-  cb_data.frame = frame;
+  cb_data.frame_id = get_frame_id (frame);
   cb_data.num_tabs = 0;
   cb_data.stream = gdb_stdout;
   cb_data.values_printed = 0;
@@ -2044,6 +2081,9 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
   iterate_over_block_arg_vars (SYMBOL_BLOCK_VALUE (func),
                               do_print_variable_and_value, &cb_data);
 
+  /* do_print_variable_and_value invalidates FRAME.  */
+  frame = NULL;
+
   if (!cb_data.values_printed)
     fprintf_filtered (stream, _("No arguments.\n"));
 }
@@ -2238,6 +2278,7 @@ return_command (char *retval_exp, int from_tty)
   struct gdbarch *gdbarch;
   struct symbol *thisfun;
   struct value *return_value = NULL;
+  struct value *function = NULL;
   const char *query_prefix = "";
 
   thisframe = get_selected_frame ("No selected frame.");
@@ -2267,7 +2308,8 @@ return_command (char *retval_exp, int from_tty)
        return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
       if (return_type == NULL)
        {
-         if (retval_expr->elts[0].opcode != UNOP_CAST)
+         if (retval_expr->elts[0].opcode != UNOP_CAST
+             && retval_expr->elts[0].opcode != UNOP_CAST_TYPE)
            error (_("Return value type not available for selected "
                     "stack frame.\n"
                     "Please use an explicit cast of the value to return."));
@@ -2282,6 +2324,9 @@ return_command (char *retval_exp, int from_tty)
       if (value_lazy (return_value))
        value_fetch_lazy (return_value);
 
+      if (thisfun != NULL)
+       function = read_var_value (thisfun, thisframe);
+
       if (TYPE_CODE (return_type) == TYPE_CODE_VOID)
        /* If the return-type is "void", don't try to find the
            return-value's location.  However, do still evaluate the
@@ -2290,8 +2335,7 @@ return_command (char *retval_exp, int from_tty)
            occur.  */
        return_value = NULL;
       else if (thisfun != NULL
-              && using_struct_return (gdbarch,
-                                      SYMBOL_TYPE (thisfun), return_type))
+              && using_struct_return (gdbarch, function, return_type))
        {
          query_prefix = "The location at which to store the "
            "function's return value is unknown.\n"
@@ -2326,12 +2370,11 @@ return_command (char *retval_exp, int from_tty)
     {
       struct type *return_type = value_type (return_value);
       struct gdbarch *gdbarch = get_regcache_arch (get_current_regcache ());
-      struct type *func_type = thisfun == NULL ? NULL : SYMBOL_TYPE (thisfun);
 
-      gdb_assert (gdbarch_return_value (gdbarch, func_type, return_type, NULL,
+      gdb_assert (gdbarch_return_value (gdbarch, function, return_type, NULL,
                                        NULL, NULL)
                  == RETURN_VALUE_REGISTER_CONVENTION);
-      gdbarch_return_value (gdbarch, func_type, return_type,
+      gdbarch_return_value (gdbarch, function, return_type,
                            get_current_regcache (), NULL /*read*/,
                            value_contents (return_value) /*write*/);
     }
@@ -2371,7 +2414,7 @@ func_command (char *arg, int from_tty)
     return;
 
   frame = parse_frame_specification ("0");
-  sals = decode_line_spec (arg, DECODE_LINE_FUNFIRSTLINE);
+  sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE);
   cleanups = make_cleanup (xfree, sals.sals);
   func_bounds = (struct function_bounds *) xmalloc (
                              sizeof (struct function_bounds) * sals.nelts);
This page took 0.027973 seconds and 4 git commands to generate.