}
-/* Attempt to obtain the FUNNAME, FUNLANG and optionally FUNCP of the function
- corresponding to FRAME. FUNNAME needs to be freed by the caller. */
+/* Attempt to obtain the name, FUNLANG and optionally FUNCP of the function
+ corresponding to FRAME. */
-void
-find_frame_funname (struct frame_info *frame, char **funname,
- enum language *funlang, struct symbol **funcp)
+gdb::unique_xmalloc_ptr<char>
+find_frame_funname (struct frame_info *frame, enum language *funlang,
+ struct symbol **funcp)
{
struct symbol *func;
+ gdb::unique_xmalloc_ptr<char> funname;
- *funname = NULL;
*funlang = language_unknown;
if (funcp)
*funcp = NULL;
/* We also don't know anything about the function besides
its address and name. */
func = 0;
- *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym));
+ funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)));
*funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
}
else
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 = func_only;
+ funname = cp_remove_params (print_name);
}
- /* If we didn't hit the C++ case above, set *funname here.
- This approach is taken to avoid having to install a
- cleanup in case cp_remove_params can throw. */
- if (*funname == NULL)
- *funname = xstrdup (print_name);
+ /* If we didn't hit the C++ case above, set *funname
+ here. */
+ if (funname == NULL)
+ funname.reset (xstrdup (print_name));
}
}
else
CORE_ADDR pc;
if (!get_frame_address_in_block_if_available (frame, &pc))
- return;
+ return funname;
msymbol = lookup_minimal_symbol_by_pc (pc);
if (msymbol.minsym != NULL)
{
- *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym));
+ funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)));
*funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
}
}
+
+ return funname;
}
static void
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct ui_out *uiout = current_uiout;
- char *funname = NULL;
enum language funlang = language_unknown;
- struct cleanup *old_chain;
struct value_print_options opts;
struct symbol *func;
CORE_ADDR pc = 0;
pc_p = get_frame_pc_if_available (frame, &pc);
-
- find_frame_funname (frame, &funname, &funlang, &func);
- old_chain = make_cleanup (xfree, funname);
+ gdb::unique_xmalloc_ptr<char> funname
+ = find_frame_funname (frame, &funlang, &func);
annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
gdbarch, pc);
annotate_frame_function_name ();
string_file stb;
- fprintf_symbol_filtered (&stb, funname ? funname : "??",
+ fprintf_symbol_filtered (&stb, funname ? funname.get () : "??",
funlang, DMGL_ANSI);
uiout->field_stream ("func", stb);
uiout->wrap_hint (" ");
}
uiout->text ("\n");
- do_cleanups (old_chain);
}
\f
numargs = 0;
while (1)
{
- char *addr_string;
- struct cleanup *cleanup;
const char *p;
/* Skip leading white space, bail of EOL. */
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
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 ());
}
}
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. */
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);
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)
if (count || need_nl)
puts_filtered ("\n");
}
-
- do_cleanups (back_to);
}
/* Print briefly all stack frames or just the innermost COUNT_EXP