Use enum flags for flags passed to openp
[deliverable/binutils-gdb.git] / gdb / stack.c
index a00e0c529da1b6bcc6400597ed0b9854cec6e5d6..9993ae654ad592197b96af82a859734b7f4ec868 100644 (file)
@@ -1,6 +1,6 @@
 /* Print and select stack frames for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -616,8 +616,8 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
            {
              struct symbol *nsym;
 
-             nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
-                                   b, VAR_DOMAIN, NULL).symbol;
+             nsym = lookup_symbol_search_name (SYMBOL_SEARCH_NAME (sym),
+                                               b, VAR_DOMAIN).symbol;
              gdb_assert (nsym != NULL);
              if (SYMBOL_CLASS (nsym) == LOC_REGISTER
                  && !SYMBOL_IS_ARGUMENT (nsym))
@@ -1101,10 +1101,7 @@ find_frame_funname (struct frame_info *frame, enum language *funlang,
                 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 (print_name);
-
-             if (func_only)
-               funname.reset (func_only);
+             funname = cp_remove_params (print_name);
            }
 
          /* If we didn't hit the C++ case above, set *funname
@@ -1277,8 +1274,6 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p)
       numargs = 0;
       while (1)
        {
-         char *addr_string;
-         struct cleanup *cleanup;
          const char *p;
 
          /* Skip leading white space, bail of EOL.  */
@@ -1290,9 +1285,8 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p)
          for (p = frame_exp;
               *p && !ISSPACE (*p);
               p++);
-         addr_string = savestring (frame_exp, p - frame_exp);
+         std::string addr_string (frame_exp, p - frame_exp);
          frame_exp = p;
-         cleanup = make_cleanup (xfree, addr_string);
          
          /* NOTE: Parse and evaluate expression, but do not use
             functions such as parse_and_eval_long or
@@ -1302,9 +1296,7 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p)
             side-effects.  */
          if (numargs >= ARRAY_SIZE (args))
            error (_("Too many args in frame specification"));
-         args[numargs++] = parse_and_eval (addr_string);
-
-         do_cleanups (cleanup);
+         args[numargs++] = parse_and_eval (addr_string.c_str ());
        }
     }
 
@@ -1388,7 +1380,7 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p)
    ADDR_EXP.  Absolutely all information in the frame is printed.  */
 
 static void
-info_frame_command (char *addr_exp, int from_tty)
+info_frame_command (const char *addr_exp, int from_tty)
 {
   struct frame_info *fi;
   struct symbol *func;
@@ -1400,7 +1392,6 @@ info_frame_command (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);
   CORE_ADDR frame_pc;
   int frame_pc_p;
   /* Initialize it to avoid "may be used uninitialized" warning.  */
@@ -1428,6 +1419,7 @@ info_frame_command (char *addr_exp, int from_tty)
   func = get_frame_function (fi);
   symtab_and_line sal = find_frame_sal (fi);
   s = sal.symtab;
+  gdb::unique_xmalloc_ptr<char> func_only;
   if (func)
     {
       funname = SYMBOL_PRINT_NAME (func);
@@ -1439,13 +1431,10 @@ info_frame_command (char *addr_exp, int from_tty)
             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);
+         func_only = cp_remove_params (funname);
 
          if (func_only)
-           {
-             funname = func_only;
-             make_cleanup (xfree, func_only);
-           }
+           funname = func_only.get ();
        }
     }
   else if (frame_pc_p)
@@ -1697,15 +1686,13 @@ info_frame_command (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
    frames.  */
 
 static void
-backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
+backtrace_command_1 (const char *count_exp, int show_locals, int no_filters,
                     int from_tty)
 {
   struct frame_info *fi;
@@ -1857,12 +1844,12 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
 }
 
 static void
-backtrace_command (char *arg, int from_tty)
+backtrace_command (const char *arg, int from_tty)
 {
-  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
   int fulltrace_arg = -1, arglen = 0, argc = 0, no_filters  = -1;
   int user_arg = 0;
 
+  std::string reconstructed_arg;
   if (arg)
     {
       char **argv;
@@ -1897,17 +1884,15 @@ backtrace_command (char *arg, int from_tty)
        {
          if (arglen > 0)
            {
-             arg = (char *) xmalloc (arglen + 1);
-             make_cleanup (xfree, arg);
-             arg[0] = 0;
              for (i = 0; i < argc; i++)
                {
                  if (i != fulltrace_arg && i != no_filters)
                    {
-                     strcat (arg, argv[i]);
-                     strcat (arg, " ");
+                     reconstructed_arg += argv[i];
+                     reconstructed_arg += " ";
                    }
                }
+             arg = reconstructed_arg.c_str ();
            }
          else
            arg = NULL;
@@ -1916,8 +1901,6 @@ backtrace_command (char *arg, int from_tty)
 
   backtrace_command_1 (arg, fulltrace_arg >= 0 /* show_locals */,
                       no_filters >= 0 /* no frame-filters */, from_tty);
-
-  do_cleanups (old_chain);
 }
 
 /* Iterate over the local variables of a block B, calling CB with
@@ -1939,6 +1922,7 @@ iterate_over_block_locals (const struct block *b,
        case LOC_REGISTER:
        case LOC_STATIC:
        case LOC_COMPUTED:
+       case LOC_OPTIMIZED_OUT:
          if (SYMBOL_IS_ARGUMENT (sym))
            break;
          if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
@@ -2123,7 +2107,7 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
 }
 
 void
-info_locals_command (char *args, int from_tty)
+info_locals_command (const char *args, int from_tty)
 {
   print_frame_local_vars (get_selected_frame (_("No frame selected.")),
                          0, gdb_stdout);
@@ -2157,8 +2141,8 @@ iterate_over_block_arg_vars (const struct block *b,
             float).  There are also LOC_ARG/LOC_REGISTER pairs which
             are not combined in symbol-reading.  */
 
-         sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
-                               b, VAR_DOMAIN, NULL).symbol;
+         sym2 = lookup_symbol_search_name (SYMBOL_SEARCH_NAME (sym),
+                                           b, VAR_DOMAIN).symbol;
          (*cb) (SYMBOL_PRINT_NAME (sym), sym2, cb_data);
        }
     }
@@ -2205,7 +2189,7 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
 }
 
 void
-info_args_command (char *ignore, int from_tty)
+info_args_command (const char *ignore, int from_tty)
 {
   print_frame_arg_vars (get_selected_frame (_("No frame selected.")),
                        gdb_stdout);
@@ -2283,7 +2267,7 @@ find_relative_frame (struct frame_info *frame, int *level_offset_ptr)
    expressions.  */
 
 void
-select_frame_command (char *level_exp, int from_tty)
+select_frame_command (const char *level_exp, int from_tty)
 {
   struct frame_info *prev_frame = get_selected_frame_if_set ();
 
@@ -2297,7 +2281,7 @@ select_frame_command (char *level_exp, int from_tty)
    the selected frame.  */
 
 static void
-frame_command (char *level_exp, int from_tty)
+frame_command (const char *level_exp, int from_tty)
 {
   struct frame_info *prev_frame = get_selected_frame_if_set ();
 
@@ -2327,13 +2311,13 @@ up_silently_base (const char *count_exp)
 }
 
 static void
-up_silently_command (char *count_exp, int from_tty)
+up_silently_command (const char *count_exp, int from_tty)
 {
   up_silently_base (count_exp);
 }
 
 static void
-up_command (char *count_exp, int from_tty)
+up_command (const char *count_exp, int from_tty)
 {
   up_silently_base (count_exp);
   observer_notify_user_selected_context_changed (USER_SELECTED_FRAME);
@@ -2366,20 +2350,20 @@ down_silently_base (const char *count_exp)
 }
 
 static void
-down_silently_command (char *count_exp, int from_tty)
+down_silently_command (const char *count_exp, int from_tty)
 {
   down_silently_base (count_exp);
 }
 
 static void
-down_command (char *count_exp, int from_tty)
+down_command (const char *count_exp, int from_tty)
 {
   down_silently_base (count_exp);
   observer_notify_user_selected_context_changed (USER_SELECTED_FRAME);
 }
 
 void
-return_command (char *retval_exp, int from_tty)
+return_command (const char *retval_exp, int from_tty)
 {
   /* Initialize it just to avoid a GCC false warning.  */
   enum return_value_convention rv_conv = RETURN_VALUE_STRUCT_CONVENTION;
@@ -2485,7 +2469,7 @@ return_command (char *retval_exp, int from_tty)
   if (return_value != NULL)
     {
       struct type *return_type = value_type (return_value);
-      struct gdbarch *gdbarch = get_regcache_arch (get_current_regcache ());
+      struct gdbarch *gdbarch = get_current_regcache ()->arch ();
 
       gdb_assert (rv_conv != RETURN_VALUE_STRUCT_CONVENTION
                  && rv_conv != RETURN_VALUE_ABI_RETURNS_ADDRESS);
@@ -2514,7 +2498,7 @@ struct function_bounds
 };
 
 static void
-func_command (char *arg, int from_tty)
+func_command (const char *arg, int from_tty)
 {
   struct frame_info *frame;
   int found = 0;
This page took 0.028697 seconds and 4 git commands to generate.