Remove some cleanups from stack.c
authorTom Tromey <tom@tromey.com>
Thu, 28 Sep 2017 02:42:21 +0000 (20:42 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 30 Sep 2017 02:46:43 +0000 (20:46 -0600)
This removes some cleanups from stack.c by using std::string or
gdb::unique_xmalloc_ptr.  One cleanup remains in this file; I did not
remove it here because it is handled in another patch series that has
yet to be resolved.

gdb/ChangeLog
2017-09-29  Tom Tromey  <tom@tromey.com>

* stack.c (parse_frame_specification): Use std::string
(info_frame_command): Use gdb::unique_xmalloc_ptr.

gdb/ChangeLog
gdb/stack.c

index 23384613ee6b245d45435c5cac3e739817edd866..896c9fe24c710d65ac16c94cc92eb0b8dac353c0 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-29  Tom Tromey  <tom@tromey.com>
+
+       * stack.c (parse_frame_specification): Use std::string
+       (info_frame_command): Use gdb::unique_xmalloc_ptr.
+
 2017-09-29  Tom Tromey  <tom@tromey.com>
 
        * tilegx-tdep.c (tilegx_push_dummy_call): Use gdb::byte_vector.
index a00e0c529da1b6bcc6400597ed0b9854cec6e5d6..53dc8296ff72b4ee7ece077484bcf43f646445b5 100644 (file)
@@ -1277,8 +1277,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 +1288,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 +1299,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 ());
        }
     }
 
@@ -1400,7 +1395,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 +1422,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 +1434,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.reset (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,8 +1689,6 @@ 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
This page took 0.066653 seconds and 4 git commands to generate.