diff options
Diffstat (limited to 'gdb/cp-support.c')
-rw-r--r-- | gdb/cp-support.c | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/gdb/cp-support.c b/gdb/cp-support.c index c71b8d9..7cfb545 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -35,7 +35,6 @@ #include "namespace.h" #include <signal.h> #include "gdbsupport/gdb_setjmp.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/selftest.h" #include "gdbsupport/gdb-sigmask.h" #include <atomic> @@ -105,7 +104,7 @@ static int cp_already_canonical (const char *string) { /* Identifier start character [a-zA-Z_]. */ - if (!ISIDST (string[0])) + if (!c_isalpha (string[0]) || string[0] == '_') return 0; /* These are the only two identifiers which canonicalize to other @@ -117,7 +116,7 @@ cp_already_canonical (const char *string) return 0; /* Identifier character [a-zA-Z0-9_]. */ - while (ISIDNUM (string[1])) + while (c_isalpha (string[1]) || c_isdigit (string[1]) || string[1] == '_') string++; if (string[1] == '\0') @@ -150,7 +149,8 @@ inspect_type (struct demangle_parse_info *info, try { - sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol; + sym = lookup_symbol (name, 0, (SEARCH_TYPE_DOMAIN + | SEARCH_STRUCT_DOMAIN), 0).symbol; } catch (const gdb_exception &except) { @@ -504,7 +504,8 @@ replace_typedefs (struct demangle_parse_info *info, try { sym = lookup_symbol (local_name.get (), 0, - SEARCH_VFT, 0).symbol; + (SEARCH_TYPE_DOMAIN + | SEARCH_STRUCT_DOMAIN), 0).symbol; } catch (const gdb_exception &except) { @@ -573,6 +574,17 @@ replace_typedefs (struct demangle_parse_info *info, } } +/* A helper to strip a trailing "()" from PTR. The string is modified + in place. */ + +static void +maybe_strip_parens (char *ptr) +{ + size_t len = strlen (ptr); + if (len > 2 && ptr[len - 2] == '(' && ptr[len - 1] == ')') + ptr[len - 2] = '\0'; +} + /* Parse STRING and convert it to canonical form, resolving any typedefs. If parsing fails, or if STRING is already canonical, return nullptr. Otherwise return the canonical form. If @@ -599,6 +611,9 @@ cp_canonicalize_string_full (const char *string, estimated_len); gdb_assert (us); + if (info->added_parens) + maybe_strip_parens (us.get ()); + /* Finally, compare the original string with the computed name, returning NULL if they are the same. */ if (strcmp (us.get (), string) == 0) @@ -647,6 +662,9 @@ cp_canonicalize_string (const char *string) return nullptr; } + if (info->added_parens) + maybe_strip_parens (us.get ()); + if (strcmp (us.get (), string) == 0) return nullptr; @@ -1118,7 +1136,7 @@ cp_find_first_component_aux (const char *name, int permissive) && startswith (name + index, CP_OPERATOR_STR)) { index += CP_OPERATOR_LEN; - while (ISSPACE(name[index])) + while (c_isspace(name[index])) ++index; switch (name[index]) { @@ -1455,17 +1473,14 @@ add_symbol_overload_list_qualified (const char *func_name, ? selected_block->objfile () : nullptr); - gdbarch_iterate_over_objfiles_in_search_order - (current_objfile ? current_objfile->arch () : current_inferior ()->arch (), - [func_name, surrounding_static_block, &overload_list] + lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL); + lookup_name_info lookup_name = base_lookup.make_ignore_params (); + + current_program_space->iterate_over_objfiles_in_search_order + ([func_name, surrounding_static_block, &overload_list, lookup_name] (struct objfile *obj) { - /* Look through the partial symtabs for all symbols which - begin by matching FUNC_NAME. Make sure we read that - symbol table in. */ - obj->expand_symtabs_for_function (func_name); - - for (compunit_symtab *cust : obj->compunits ()) + auto callback = [&] (compunit_symtab *cust) { QUIT; const struct block *b = cust->blockvector ()->global_block (); @@ -1473,11 +1488,17 @@ add_symbol_overload_list_qualified (const char *func_name, b = cust->blockvector ()->static_block (); /* Don't do this block twice. */ - if (b == surrounding_static_block) - continue; + if (b != surrounding_static_block) + add_symbol_overload_list_block (func_name, b, overload_list); + return true; + }; - add_symbol_overload_list_block (func_name, b, overload_list); - } + /* Look through the partial symtabs for all symbols which + begin by matching FUNC_NAME. Make sure we read that + symbol table in. */ + obj->search (nullptr, &lookup_name, nullptr, callback, + SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, + SEARCH_FUNCTION_DOMAIN); return 0; }, current_objfile); @@ -1501,7 +1522,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block) return NULL; } - if (rtti_sym->aclass () != LOC_TYPEDEF) + if (rtti_sym->loc_class () != LOC_TYPEDEF) { warning (_("RTTI symbol for class '%s' is not a type"), name); return NULL; @@ -2332,7 +2353,7 @@ find_toplevel_char (const char *s, char c) scan += CP_OPERATOR_LEN; if (*scan == c) return scan; - while (ISSPACE (*scan)) + while (c_isspace (*scan)) { ++scan; if (*scan == c) @@ -2370,9 +2391,7 @@ find_toplevel_char (const char *s, char c) return 0; } -void _initialize_cp_support (); -void -_initialize_cp_support () +INIT_GDB_FILE (cp_support) { cmd_list_element *maintenance_cplus = add_basic_prefix_cmd ("cplus", class_maintenance, |