+2017-10-09 Pedro Alves <palves@redhat.com>
+
+ * cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr.
+ Use bool.
+ (overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr.
+ * cp-support.h (cp_remove_params): Now returns a
+ gdb::unique_xmalloc_ptr.
+ * dwarf2read.c (find_slot_in_mapped_hash): Now returns bool.
+ Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
+ * psymtab.c (psymtab_search_name): Adjust to cp_remove_params
+ returning a gdb::unique_xmalloc_ptr.
+ (lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr.
+ * stack.c (find_frame_funname): Adjust to cp_remove_params
+ returning a gdb::unique_xmalloc_ptr.
+
2017-10-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_get_dwz_file): Use
(optionally) a return type. Return the name of the function without
parameters or return type, or NULL if we can not parse the name. */
-char *
+gdb::unique_xmalloc_ptr<char>
cp_remove_params (const char *demangled_name)
{
- int done = 0;
+ bool done = false;
struct demangle_component *ret_comp;
std::unique_ptr<demangle_parse_info> info;
gdb::unique_xmalloc_ptr<char> ret;
ret_comp = d_left (ret_comp);
break;
default:
- done = 1;
+ done = true;
break;
}
if (ret_comp->type == DEMANGLE_COMPONENT_TYPED_NAME)
ret = cp_comp_to_string (d_left (ret_comp), 10);
- return ret.release ();
+ return ret;
}
/* Here are some random pieces of trivia to keep in mind while trying
{
int newsize;
int i;
- char *sym_name;
+ gdb::unique_xmalloc_ptr<char> sym_name;
/* If there is no type information, we can't do anything, so
skip. */
return;
/* skip symbols that cannot match */
- if (strcmp (sym_name, oload_name) != 0)
- {
- xfree (sym_name);
- return;
- }
-
- xfree (sym_name);
+ if (strcmp (sym_name.get (), oload_name) != 0)
+ return;
/* We have a match for an overload instance, so add SYM to the
current list of overload instances */
extern char *cp_func_name (const char *full_name);
-extern char *cp_remove_params (const char *demangled_name);
+extern gdb::unique_xmalloc_ptr<char> cp_remove_params
+ (const char *demanged_name);
extern struct symbol **make_symbol_overload_list (const char *,
const char *);
/* Find a slot in the mapped index INDEX for the object named NAME.
If NAME is found, set *VEC_OUT to point to the CU vector in the
- constant pool and return 1. If NAME cannot be found, return 0. */
+ constant pool and return true. If NAME cannot be found, return
+ false. */
-static int
+static bool
find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
offset_type **vec_out)
{
if (strchr (name, '(') != NULL)
{
- without_params.reset (cp_remove_params (name));
+ without_params = cp_remove_params (name);
if (without_params != NULL)
name = without_params.get ();
offset_type i = 2 * slot;
const char *str;
if (index->symbol_table[i] == 0 && index->symbol_table[i + 1] == 0)
- return 0;
+ return false;
str = index->constant_pool + MAYBE_SWAP (index->symbol_table[i]);
if (!cmp (name, str))
{
*vec_out = (offset_type *) (index->constant_pool
+ MAYBE_SWAP (index->symbol_table[i + 1]));
- return 1;
+ return true;
}
slot = (slot + step) & (index->symbol_table_slots - 1);
not contain any method/function instance information (since this would
force reading type information while reading psymtabs). Therefore,
if NAME contains overload information, it must be stripped before searching
- psymtabs.
-
- The caller is responsible for freeing the return result. */
+ psymtabs. */
static gdb::unique_xmalloc_ptr<char>
psymtab_search_name (const char *name)
{
if (strchr (name, '('))
{
- char *ret = cp_remove_params (name);
+ gdb::unique_xmalloc_ptr<char> ret = cp_remove_params (name);
if (ret)
- return gdb::unique_xmalloc_ptr<char> (ret);
+ return ret;
}
}
break;
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
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. */
- func_only.reset (cp_remove_params (funname));
+ func_only = cp_remove_params (funname);
if (func_only)
funname = func_only.get ();