On 12/13/2011 11:39 AM, Tom Tromey wrote: > I didn't see 'is_name_anonymous_type' anywhere in the tree or in the patch. > I guess it needs an update. I hate it when that happens! Comment updated. > Keith> +static int > Keith> +is_path_expr_parent (struct varobj *var) > [...] > Keith> + type = get_value_type (var); > > Extra space. Fixed. > Keith> + return strncmp (child->name, ANONYMOUS_STRUCT_NAME, 11) == 0; > > I think this is wrong since the macros have _() in their expansion. > I think you have to use strlen. Yeah, very wrong indeed! I've fixed that test. > Keith> + field_name = TYPE_FIELD_NAME (type, index); > Keith> + if (*field_name == '\0') > > Can field_name == NULL? > It is not clear to me. There is some code in gdb that checks this, but > I don't know whether that is defensive programming or checking a > condition that is truly possible. Comments in gdbtypes.h seem to indicate that name could be NULL, but I've not seen that. To be defensive, I've treated name == NULL and name == "" the same. On 12/13/2011 11:58 AM, Jan Kratochvil wrote: > Program received signal SIGSEGV, Segmentation fault. > 0x00000000007ab58b in get_value_type (var=0x0) at varobj.c:2397 > 2397 if (var->value) > (gdb) bt > #0 in get_value_type (var=0x0) at varobj.c:2397 > #1 in is_path_expr_parent (var=0x0) at varobj.c:1310 > #2 in get_path_expr_parent (var=0x2cbbd80) at varobj.c:1325 > #3 in c_describe_child (parent=0x2cbbd80, index=0, cname=0x0, cvalue=0x0, ctype=0x0, cfull_expression=0x2cbf5f8) at varobj.c:3015 > #4 in c_path_expr_of_child (child=0x2cbf5f0) at varobj.c:3140 [snip] I've fixed this, too, and added a test for that. A very simple omission: get_path_expr_parent was attempting to walk the parent chain past the root variable. Whoops. Keith ChangeLog 2011-12-16 Keith Seitz PR mi/10586 * varobj.c (ANONYMOUS_STRUCT_NAME): Define. (ANONYMOUS_UNION_NAME): Define. (is_path_expr_parent): New function. (get_path_expr_parent): New function. (is_anonymous_child): New function. (create_child_with_value): If the child is anonymous and without a name, assign an object name to it. (c_describe_child): Use get_path_expr_parent to determine the parent expression. If there field represents an anonymous struct or union and has no name, set an appropriate display name and expression. (cplus_describe_child): Likewise. testsuite/ChangeLog 2011-12-16 Keith Seitz PR mi/10586 * gdb.mi/var-cmd.c (struct anonymous): New structure. (do_anonymous_type_tests): New function. (main): Call do_anonymous_type_tests. * gdb.mi/mi2-var-child.exp: Add anonymous type tests. (verify_everything): New procedure. * gdb.mi/mi-var-cp.cc (class A): New class. (anonymous_structs_and_unions): New function. (main): Call anonymous_structs_and_unions. * gdb.mi/mi-var-cp.exp: Add anonymous type tests. (verify_everything): New procedure.