diff options
Diffstat (limited to 'gdb/cp-support.c')
-rw-r--r-- | gdb/cp-support.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 3621d68..cab7110 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1,5 +1,5 @@ /* Helper routines for C++ support in GDB. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. Contributed by MontaVista Software. @@ -573,6 +573,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 +610,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 +661,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; @@ -2267,7 +2284,7 @@ test_cp_remove_params () #undef CHECK_INCOMPL } -} // namespace selftests +} /* namespace selftests */ #endif /* GDB_SELF_CHECK */ @@ -2370,9 +2387,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, |