This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Thu, 21 Apr 2011 23:15:37 +0200, Keith Seitz wrote: [...]--- cp-support.c 26 Feb 2011 02:07:07 -0000 1.49 +++ cp-support.c 21 Apr 2011 17:03:35 -0000 @@ -117,6 +117,115 @@ cp_already_canonical (const char *string return 0; }
+/* Insepct the given RET_COMP for its type. If it is a typedef, + replace the name stored in the tree with the typedef's fully resolved + type. If no changes have been made to the tree, set CHANGED to 0; + otherwise set it to 1. FREE_LIST contains any temprorary storage
temporary
+ that was used to revise the tree. It should be freed by the caller. */
CHANGED/FREE_LIST I do not understand what they refer to at all.
+static void +inspect_type (struct demangle_component *ret_comp) +{ + char *name; + struct symbol *sym; + + name = (char *) alloca (ret_comp->u.s_name.len + 1); + strncpy (name, ret_comp->u.s_name.s, ret_comp->u.s_name.len); + name[ret_comp->u.s_name.len] = '\0'; + sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); + if (sym != NULL) + { + struct type *type = SYMBOL_TYPE (sym); + + if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) + { + char *canon; + struct ui_file *buf = mem_fileopen (); + + CHECK_TYPEDEF (type);
BUF should be make_cleanup protected against exceptions.
This table is incomplete, for example DEMANGLE_COMPONENT_ARRAY_TYPE is missing. C++ source / GDB input: f(CORE_ADDR (*)[10]) GDB output: f(CORE_ADDR (*) [10]) GCC output: f(unsigned long (*) [10]) _Z1fPA10_m
Also there should be an equivalent of the CLOSED-FIXED PR: Bug 12328 - Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
+ +/* Parse STRING and convert it to canonical form, resolving any typedefs. + If parsing fails, or if STRING is already canonical, return NULL. + Otherwise return the canonical form. The return value is allocated via + xmalloc. */ + +char * +cp_canonicalize_string_no_typedefs (const char *string) +{ + char *ret; + unsigned int estimated_len; + struct demangle_parse_info *info; + + ret = NULL; + estimated_len = strlen (string) * 2; + info = cp_demangled_name_to_comp (string, NULL); + if (info != NULL) + { + replace_typedefs (info->tree); + ret = cp_comp_to_string (info->tree, estimated_len); + cp_demangled_name_parse_free (info); + if (strcmp (string, ret) == 0)
cp_comp_to_string can return NULL, OK, it may not obviously happen but still some gdb_assert / internal_error would be appropriate IMO.
BTW already present in [patch 1/4].
Attachment:
cp_canonicalize_no_typedefs-2.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |