/* Convert symbols from GDB to GCC
- Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ Copyright (C) 2014-2018 Free Software Foundation, Inc.
This file is part of GDB.
{
struct symbol_error search;
struct symbol_error *err;
- char *message;
if (context->symbol_err_map == NULL)
return;
if (err == NULL || err->message == NULL)
return;
- message = err->message;
+ gdb::unique_xmalloc_ptr<char> message (err->message);
err->message = NULL;
- make_cleanup (xfree, message);
- error (_("%s"), message);
+ error (_("%s"), message.get ());
}
\f
/* Compute the name of the pointer representing a local symbol's
address. */
-static char *
+static gdb::unique_xmalloc_ptr<char>
symbol_substitution_name (struct symbol *sym)
{
- return concat ("__", SYMBOL_NATURAL_NAME (sym), "_ptr", (char *) NULL);
+ return gdb::unique_xmalloc_ptr<char>
+ (concat ("__", SYMBOL_NATURAL_NAME (sym), "_ptr", (char *) NULL));
}
/* Convert a given symbol, SYM, to the compiler's representation.
gcc_decl decl;
enum gcc_c_symbol_kind kind;
CORE_ADDR addr = 0;
- char *symbol_name = NULL;
+ gdb::unique_xmalloc_ptr<char> symbol_name;
switch (SYMBOL_CLASS (sym.symbol))
{
SYMBOL_NATURAL_NAME (sym.symbol),
kind,
sym_type,
- symbol_name, addr,
+ symbol_name.get (), addr,
filename, line);
C_CTX (context)->c_ops->bind (C_CTX (context), decl, is_global);
}
-
- xfree (symbol_name);
}
}
break;
case mst_text_gnu_ifunc:
- /* nodebug_text_gnu_ifunc_symbol would cause:
- function return type cannot be function */
- type = objfile_type (objfile)->nodebug_text_symbol;
+ type = objfile_type (objfile)->nodebug_text_gnu_ifunc_symbol;
kind = GCC_C_SYMBOL_FUNCTION;
addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
break;
{
type = check_typedef (type);
- if (TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_IS_REFERENCE (type))
type = check_typedef (TYPE_TARGET_TYPE (type));
switch (TYPE_CODE (type))
|| TYPE_HIGH_BOUND_KIND (type) == PROP_LOCLIST)
{
const struct dynamic_prop *prop = &TYPE_RANGE_DATA (type)->high;
- char *name = c_get_range_decl_name (prop);
- struct cleanup *cleanup = make_cleanup (xfree, name);
+ std::string name = c_get_range_decl_name (prop);
- dwarf2_compile_property_to_c (stream, name,
+ dwarf2_compile_property_to_c (stream, name.c_str (),
gdbarch, registers_used,
prop, pc, sym);
- do_cleanups (cleanup);
}
}
break;
if (SYMBOL_COMPUTED_OPS (sym) != NULL)
{
- char *generated_name = symbol_substitution_name (sym);
- struct cleanup *cleanup = make_cleanup (xfree, generated_name);
+ gdb::unique_xmalloc_ptr<char> generated_name
+ = symbol_substitution_name (sym);
/* We need to emit to a temporary buffer in case an error
occurs in the middle. */
string_file local_file;
SYMBOL_COMPUTED_OPS (sym)->generate_c_location (sym, local_file,
gdbarch,
registers_used,
- pc, generated_name);
+ pc,
+ generated_name.get ());
stream.write (local_file.c_str (), local_file.size ());
-
- do_cleanups (cleanup);
}
else
{