* 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.
+2012-01-12 Keith Seitz <keiths@redhat.com>
+
+ 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.
+
2012-01-12 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp: Expand comments about PATH_EXPR.
/*: END: path_expression :*/
}
+class Anonymous
+{
+public:
+ struct { /* index: 0 */
+ int b;
+ };
+ struct { /* index: 1 */
+ int c;
+ };
+ struct { /* index: 2 */
+ int d;
+ struct { /* index: 1 */
+ int e;
+ struct { /* index: 0 */
+ int f;
+ union { /* index: 0 */
+ int g;
+ char h;
+ };
+ };
+ union { /* index: 0 */
+ int i;
+ char j;
+ };
+ };
+ };
+};
+
+/* Test anonymous structs and unions. */
+int
+anonymous_structs_and_unions (void)
+{
+ Anonymous a;
+ a.b = 1;
+ a.c = 2;
+ a.d = 3;
+ a.e = 4;
+ a.f = 5;
+ a.g = 6;
+ a.h = '7';
+ a.i = 8;
+ a.j = '8';
+ return 0; /* anonymous_structs_and_unions */
+}
+
int main ()
{
reference_update_tests ();
reference_to_pointer ();
reference_to_struct ();
path_expression ();
+ anonymous_structs_and_unions ();
return 0;
}
mi_run_inline_test reference_to_struct
mi_run_inline_test path_expression
+set lineno [gdb_get_line_number "/* anonymous_structs_and_unions */"]
+mi_create_breakpoint \
+ "$srcfile:$lineno" {[0-9]+} keep {anonymous_structs_and_unions\(\)} \
+ ".*mi-var-cp.cc" $lineno $hex "break in anonymous_structs_and_unions"
+mi_execute_to "exec-continue" "breakpoint-hit" \
+ "anonymous_structs_and_unions" "" ".*" ".*" {"" "disp=\"keep\""} \
+ "continue to anonymous_structs breakpoint"
+
+set tree {
+ Anonymous a {
+ {} public {
+ anonymous struct {
+ {} public {
+ int b {}
+ }
+ }
+ anonymous struct {
+ {} public {
+ int c {}
+ }
+ }
+ anonymous struct {
+ {} public {
+ int d {}
+ anonymous struct {
+ {} public {
+ int e {}
+ anonymous struct {
+ {} public {
+ int f {}
+ anonymous union {
+ {} public {
+ int g {}
+ char h {}
+ }
+ }
+ }
+ }
+ anonymous union {
+ {} public {
+ int i {}
+ char j {}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+proc verify_everything {variable_name} {
+ # Test -var-list-children
+ mi_varobj_tree_test_children_callback $variable_name
+
+ # Bring the variable named by VARIABLE_NAME into the current scope
+ # in VAROBJ.
+ upvar #0 $variable_name varobj
+
+ # Test -var-info-path-expression
+ mi_gdb_test "-var-info-path-expression $varobj(obj_name)" \
+ "\\^done,path_expr=\"[string_to_regexp $varobj(path_expr)]\"" \
+ "path expression for $varobj(obj_name)"
+
+ # Test -var-info-expression
+ mi_gdb_test "-var-info-expression $varobj(obj_name)" \
+ "\\^done,lang=\"C\\+\\+\",exp=\"[string_to_regexp $varobj(display_name)]\"" \
+ "expression for $varobj(obj_name)"
+}
+
+mi_walk_varobj_tree c++ $tree verify_everything
+
mi_gdb_exit
return 0
"update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed"
+# Anonymous type tests
+proc verify_everything {variable_name} {
+ # Test -var-list-children
+ mi_varobj_tree_test_children_callback $variable_name
+
+ # Bring the variable named by VARIABLE_NAME into the current scope
+ # in VAROBJ.
+ upvar #0 $variable_name varobj
+
+ # Test -var-info-path-expression
+ mi_gdb_test "-var-info-path-expression $varobj(obj_name)" \
+ "\\^done,path_expr=\"[string_to_regexp $varobj(path_expr)]\"" \
+ "path expression for $varobj(obj_name)"
+
+ # Test -var-info-expression
+ mi_gdb_test "-var-info-expression $varobj(obj_name)" \
+ "\\^done,lang=\"C\",exp=\"[string_to_regexp $varobj(display_name)]\"" \
+ "expression for $varobj(obj_name)"
+}
+
+set lineno [gdb_get_line_number "anonymous type tests breakpoint"]
+mi_create_breakpoint \
+ "$srcfile:$lineno" {[0-9]+} keep {do_anonymous_type_tests} \
+ ".*var-cmd.c" $lineno $hex "break in do_anonymous_type_tests"
+mi_execute_to "exec-continue" "breakpoint-hit" "do_anonymous_type_tests" ""\
+ ".*" ".*" {"" "disp=\"keep\""} \
+ "continue to do_anonymous_type_tests breakpoint"
+
+# Run the varobj tree on variable "ptr".
+set tree {
+ {struct anonymous **} ptr {
+ {struct anonymous *} {*ptr} {
+ int a {}
+ anonymous struct {
+ int b {}
+ {char *} c {
+ char {*c} {}
+ }
+ anonymous union {
+ int d {}
+ {void *} e {}
+ char f {}
+ anonymous struct {
+ char g {}
+ {const char **} h {
+ {const char *} {*h} {
+ {const char} {**h} {}
+ }
+ }
+ {simpleton ***} simple {
+ {simpleton **} {*simple} {
+ {simpleton *} {**simple} {
+ int integer {}
+ {unsigned int} unsigned_integer {}
+ char character {}
+ {signed char} signed_character {}
+ {char *} char_ptr {
+ char {*char_ptr} {}
+ }
+ {int [10]} array_of_10 {
+ int 0 {}
+ int 1 {}
+ int 2 {}
+ int 3 {}
+ int 4 {}
+ int 5 {}
+ int 6 {}
+ int 7 {}
+ int 8 {}
+ int 9 {}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+mi_walk_varobj_tree c $tree verify_everything
+
+set tree {
+ {struct {...}} v {
+ int x {}
+ anonymous struct {
+ int a {}
+ }
+ anonymous struct {
+ int b {}
+ }
+ }
+}
+mi_walk_varobj_tree c $tree verify_everything
mi_gdb_exit
return 0
struct _struct_n_pointer *next;
};
+struct anonymous {
+ int a;
+ struct {
+ int b;
+ char *c;
+ union {
+ int d;
+ void *e;
+ char f;
+ struct {
+ char g;
+ const char **h;
+ simpleton ***simple;
+ };
+ };
+ };
+};
+
void do_locals_tests (void);
void do_block_tests (void);
void subroutine1 (int, long *);
/*: END: bitfield :*/
}
+void
+do_anonymous_type_tests (void)
+{
+ struct anonymous *anon;
+ struct anonymous **ptr;
+ struct
+ {
+ int x;
+ struct
+ {
+ int a;
+ };
+ struct
+ {
+ int b;
+ };
+ } v = {1, {2}, {3}};
+
+ anon = malloc (sizeof (struct anonymous));
+ anon->a = 1;
+ anon->b = 2;
+ anon->c = (char *) 3;
+ anon->d = 4;
+ anon->g = '5';
+ anon->h = (const char **) 6;
+ anon->simple = (simpleton ***) 7;
+
+ ptr = &anon;
+ free (anon);
+ return; /* anonymous type tests breakpoint */
+}
+
int
main (int argc, char *argv [])
{
do_frozen_tests ();
do_at_tests ();
do_bitfield_tests ();
+ do_anonymous_type_tests ();
exit (0);
}