* cli/cli-script.c (do_fclose_cleanup): Remove.
[deliverable/binutils-gdb.git] / gdb / stack.c
index 3d78f74089367040b426bb0489426552e8908b78..2c3c0bbe37618b2eab52aee79a5575d306b9cd37 100644 (file)
@@ -43,6 +43,8 @@
 #include "regcache.h"
 #include "solib.h"
 #include "valprint.h"
+#include "gdbthread.h"
+#include "cp-support.h"
 
 #include "gdb_assert.h"
 #include <ctype.h>
@@ -200,9 +202,9 @@ print_this_frame_argument_p (struct symbol *sym)
    of arguments according to the stack frame (or -1 if the number of
    arguments is unknown).  */
 
-/* Note that currently the "number of argumentss according to the
+/* Note that currently the "number of arguments according to the
    stack frame" is only known on VAX where i refers to the "number of
-   ints of argumentss according to the stack frame".  */
+   ints of arguments according to the stack frame".  */
 
 static void
 print_frame_args (struct symbol *func, struct frame_info *frame,
@@ -286,10 +288,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
             parameter names occur on the RS/6000, for traceback
             tables.  FIXME, should we even print them?  */
 
-         if (*DEPRECATED_SYMBOL_NAME (sym))
+         if (*SYMBOL_LINKAGE_NAME (sym))
            {
              struct symbol *nsym;
-             nsym = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
+             nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
                                    b, VAR_DOMAIN, NULL);
              gdb_assert (nsym != NULL);
              if (SYMBOL_CLASS (nsym) == LOC_REGISTER
@@ -617,12 +619,12 @@ print_frame (struct frame_info *frame, int print_level,
          /* We also don't know anything about the function besides
             its address and name.  */
          func = 0;
-         funname = DEPRECATED_SYMBOL_NAME (msymbol);
+         funname = SYMBOL_PRINT_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
       else
        {
-         funname = DEPRECATED_SYMBOL_NAME (func);
+         funname = SYMBOL_PRINT_NAME (func);
          funlang = SYMBOL_LANGUAGE (func);
          if (funlang == language_cplus)
            {
@@ -630,23 +632,13 @@ print_frame (struct frame_info *frame, int print_level,
                 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 the demangler again, with
-                DMGL_ANSI only.
-
-                Yes, printf_symbol_filtered() will again try to
-                demangle the name on the fly, but the issue is that
-                if cplus_demangle() fails here, it will fail there
-                too. So we want to catch the failure (where DEMANGLED
-                is NULL below) here, while we still have our hands on
-                the function symbol.)  */
-             char *demangled = cplus_demangle (funname, DMGL_ANSI);
-             if (demangled == NULL)
-               /* If the demangler fails, try the demangled name from
-                  the symbol table. That'll have parameters, but
-                  that's preferable to displaying a mangled name.  */
-               funname = SYMBOL_PRINT_NAME (func);
-             else
-               xfree (demangled);
+                display parameters.  So remove the parameters.  */
+             char *func_only = cp_remove_params (funname);
+             if (func_only)
+               {
+                 funname = func_only;
+                 make_cleanup (xfree, func_only);
+               }
            }
        }
     }
@@ -657,7 +649,7 @@ print_frame (struct frame_info *frame, int print_level,
 
       if (msymbol != NULL)
        {
-         funname = DEPRECATED_SYMBOL_NAME (msymbol);
+         funname = SYMBOL_PRINT_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
@@ -894,6 +886,7 @@ frame_info (char *addr_exp, int from_tty)
   const char *pc_regname;
   int selected_frame_p;
   struct gdbarch *gdbarch;
+  struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
 
   fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p);
   gdbarch = get_frame_arch (fi);
@@ -919,29 +912,21 @@ frame_info (char *addr_exp, int from_tty)
   s = find_pc_symtab (get_frame_pc (fi));
   if (func)
     {
-      /* It seems appropriate 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 the
-        demangler again, with DMGL_ANSI only.
-
-        Yes, printf_symbol_filtered() will again try to demangle the
-        name on the fly, but the issue is that if cplus_demangle()
-        fails here, it will fail there too. So we want to catch the
-        failure (where DEMANGLED is NULL below) here, while we still
-        have our hands on the function symbol.)  */
-      funname = DEPRECATED_SYMBOL_NAME (func);
+      funname = SYMBOL_PRINT_NAME (func);
       funlang = SYMBOL_LANGUAGE (func);
       if (funlang == language_cplus)
        {
-         char *demangled = cplus_demangle (funname, DMGL_ANSI);
-         /* If the demangler fails, try the demangled name from the
-            symbol table. That'll have parameters, but that's
-            preferable to displaying a mangled name.  */
-         if (demangled == NULL)
-           funname = SYMBOL_PRINT_NAME (func);
-         else
-           xfree (demangled);
+         /* It seems appropriate 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 remove the parameters.  */
+         char *func_only = cp_remove_params (funname);
+         if (func_only)
+           {
+             funname = func_only;
+             make_cleanup (xfree, func_only);
+           }
        }
     }
   else
@@ -951,7 +936,7 @@ frame_info (char *addr_exp, int from_tty)
       msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
       if (msymbol != NULL)
        {
-         funname = DEPRECATED_SYMBOL_NAME (msymbol);
+         funname = SYMBOL_PRINT_NAME (msymbol);
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
@@ -1153,6 +1138,8 @@ frame_info (char *addr_exp, int from_tty)
     if (count || need_nl)
       puts_filtered ("\n");
   }
+
+  do_cleanups (back_to);
 }
 
 /* Print briefly all stack frames or just the innermost COUNT_EXP
@@ -1295,7 +1282,7 @@ backtrace_command (char *arg, int from_tty)
       char **argv;
       int i;
 
-      argv = buildargv (arg);
+      argv = gdb_buildargv (arg);
       old_chain = make_cleanup_freeargv (argv);
       argc = 0;
       for (i = 0; argv[i]; i++)
@@ -1409,7 +1396,7 @@ print_block_frame_labels (struct block *b, int *have_default,
 
   ALL_BLOCK_SYMBOLS (b, iter, sym)
     {
-      if (strcmp (DEPRECATED_SYMBOL_NAME (sym), "default") == 0)
+      if (strcmp (SYMBOL_LINKAGE_NAME (sym), "default") == 0)
        {
          if (*have_default)
            continue;
@@ -1593,7 +1580,7 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
             float).  There are also LOC_ARG/LOC_REGISTER pairs which
             are not combined in symbol-reading.  */
 
-         sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
+         sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
                                b, VAR_DOMAIN, NULL);
          print_variable_value (sym2, frame, stream);
          fprintf_filtered (stream, "\n");
@@ -1643,6 +1630,12 @@ get_selected_block (CORE_ADDR *addr_in_block)
   if (!target_has_stack)
     return 0;
 
+  if (is_exited (inferior_ptid))
+    return 0;
+
+  if (is_executing (inferior_ptid))
+    return 0;
+
   return get_frame_block (get_selected_frame (NULL), addr_in_block);
 }
 
@@ -1787,11 +1780,13 @@ down_command (char *count_exp, int from_tty)
 void
 return_command (char *retval_exp, int from_tty)
 {
+  struct frame_info *thisframe;
   struct symbol *thisfun;
   struct value *return_value = NULL;
   const char *query_prefix = "";
 
-  thisfun = get_frame_function (get_selected_frame ("No selected frame."));
+  thisframe = get_selected_frame ("No selected frame.");
+  thisfun = get_frame_function (thisframe);
 
   /* Compute the return value.  If the computation triggers an error,
      let it bail.  If the return type can't be handled, set
@@ -1810,7 +1805,7 @@ return_command (char *retval_exp, int from_tty)
       if (thisfun != NULL)
        return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
       if (return_type == NULL)
-       return_type = builtin_type_int;
+       return_type = builtin_type (get_frame_arch (thisframe))->builtin_int;
       CHECK_TYPEDEF (return_type);
       return_value = value_cast (return_type, return_value);
 
@@ -1851,29 +1846,8 @@ If you continue, the return value that you specified will be ignored.\n";
        error (_("Not confirmed"));
     }
 
-  /* NOTE: cagney/2003-01-18: Is this silly?  Rather than pop each
-     frame in turn, should this code just go straight to the relevant
-     frame and pop that?  */
-
-  /* First discard all frames inner-to the selected frame (making the
-     selected frame current).  */
-  {
-    struct frame_id selected_id = get_frame_id (get_selected_frame (NULL));
-    while (!frame_id_eq (selected_id, get_frame_id (get_current_frame ())))
-      {
-       struct frame_info *frame = get_current_frame ();
-       if (frame_id_inner (get_frame_arch (frame), selected_id,
-                           get_frame_id (frame)))
-         /* Caught in the safety net, oops!  We've gone way past the
-             selected frame.  */
-         error (_("Problem while popping stack frames (corrupt stack?)"));
-       frame_pop (get_current_frame ());
-      }
-  }
-
-  /* Second discard the selected frame (which is now also the current
-     frame).  */
-  frame_pop (get_current_frame ());
+  /* Discard the selected frame and all frames inner-to it.  */
+  frame_pop (get_selected_frame (NULL));
 
   /* Store RETURN_VALUE in the just-returned register set.  */
   if (return_value != NULL)
This page took 0.029214 seconds and 4 git commands to generate.