diff options
author | Tom Tromey <tom@tromey.com> | 2017-09-27 20:42:21 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-29 20:46:43 -0600 |
commit | 2003f3d839fa887811ff65380191e0beaeff719e (patch) | |
tree | 3cc8e2fcc9362b69a7760878ade9b1f015e21a37 /gdb/stack.c | |
parent | 8f8accb58078b1f249dc6865b8784a0a8e8881dd (diff) | |
download | binutils-gdb-2003f3d839fa887811ff65380191e0beaeff719e.tar.gz |
Remove some cleanups from stack.c
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.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r-- | gdb/stack.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/gdb/stack.c b/gdb/stack.c index a00e0c529da..53dc8296ff7 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -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 |