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]

Test for base-in-references bug


This patch adds testcase for base-in-references bug that was recently fixed.
I've verified that the new testcase fails with my patches reverted, and passes
when they are put back. OK?

- Volodya

	Test for base in references.
	* gdb.mi/mi-var-cp.cc: Add test code.
	* gdb.mi/mi-var-cp.exp: Test for bases in references.
	* gdb.mi/mi-watch.exp: Adjust to mi_runto changes.
	* gdb.mi/mi2-watch.exp: Likewise.
	* lib/mi-support.exp (mi_runto): Use temporary breakpoint.
	(mi_list_varobj_children): New function.
Index: gdb.mi/mi-var-cp.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cp.cc,v
retrieving revision 1.1
diff -u -p -r1.1 mi-var-cp.cc
--- gdb.mi/mi-var-cp.cc	8 Dec 2006 12:44:11 -0000	1.1
+++ gdb.mi/mi-var-cp.cc	8 Dec 2006 14:06:44 -0000
@@ -23,8 +23,26 @@ void reference_update_tests ()
   x = 567;
 }
 
+struct S { int i; int j; };
+struct S2 : S {};
+        
+int base_in_reference_test (S2& s2)
+{
+  return s2.i;
+}
+        
+void base_in_reference_test_main ()
+{
+  S2 s;
+  s.i = 67;
+  s.j = 89;
+  base_in_reference_test (s);
+}
+
+
 int main ()
 {
   reference_update_tests ();
+  base_in_reference_test_main ();
   return 0;
 }
Index: gdb.mi/mi-var-cp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cp.exp,v
retrieving revision 1.1
diff -u -p -r1.1 mi-var-cp.exp
--- gdb.mi/mi-var-cp.exp	8 Dec 2006 12:44:11 -0000	1.1
+++ gdb.mi/mi-var-cp.exp	8 Dec 2006 14:06:44 -0000
@@ -41,7 +41,6 @@ mi_gdb_load ${binfile}
 
 # Test that children of classes are properly reported
 
-# Run to main
 mi_runto reference_update_tests
 
 mi_create_varobj "RX" "rx" "create varobj for rx"
@@ -69,5 +68,24 @@ mi_next_to "reference_update_tests" {} "
 
 mi_varobj_update RX {} "update RX (3)"
 
+mi_runto base_in_reference_test
+
+mi_create_varobj "S2" "s2" "create varobj for s2"
+
+mi_list_varobj_children "S2" {{"S2.S" "S" "1" "S"}} "list children of s2"
+
+mi_list_varobj_children "S2.S" {{"S2.S.public" "public" "2"}} \
+    "list children of s2.s"
+
+mi_list_varobj_children "S2.S.public"\
+{
+    {"S2.S.public.i" "i" "0" "int"}
+    {"S2.S.public.j" "j" "0" "int"}
+} "list children of s2.s.public"
+
+mi_check_varobj_value "S2.S.public.i" "67" "check S2.S.public.i"
+mi_check_varobj_value "S2.S.public.j" "89" "check S2.S.public.j"
+
+
 mi_gdb_exit
 return 0
Index: gdb.mi/mi-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-watch.exp,v
retrieving revision 1.13
diff -u -p -r1.13 mi-watch.exp
--- gdb.mi/mi-watch.exp	10 Aug 2006 05:27:21 -0000	1.13
+++ gdb.mi/mi-watch.exp	8 Dec 2006 14:06:44 -0000
@@ -64,7 +64,7 @@ proc test_watchpoint_creation_and_listin
              "break-watch operation"
 
     mi_gdb_test "222-break-list" \
-	    "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_callee4_body\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
+	    "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
                 "list of watchpoints"
 
 }
Index: gdb.mi/mi2-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-watch.exp,v
retrieving revision 1.4
diff -u -p -r1.4 mi2-watch.exp
--- gdb.mi/mi2-watch.exp	10 Aug 2006 05:27:21 -0000	1.4
+++ gdb.mi/mi2-watch.exp	8 Dec 2006 14:06:44 -0000
@@ -63,7 +63,7 @@ proc test_watchpoint_creation_and_listin
              "break-watch operation"
 
     mi_gdb_test "222-break-list" \
-	    "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_callee4_body\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
+	    "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
                 "list of watchpoints"
 
 }
Index: lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.34
diff -u -p -r1.34 mi-support.exp
--- lib/mi-support.exp	8 Dec 2006 12:44:11 -0000	1.34
+++ lib/mi-support.exp	8 Dec 2006 14:06:45 -0000
@@ -868,8 +868,8 @@ proc mi_runto {func} {
   global hex decimal fullname_syntax
 
   set test "mi runto $func"
-  mi_gdb_test "200-break-insert $func" \
-    "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" \
+  mi_gdb_test "200-break-insert -t $func" \
+    "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" \
     "breakpoint at $func"
 
   if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
@@ -879,7 +879,7 @@ proc mi_runto {func} {
 
   mi_run_cmd
   gdb_expect {
-    -re ".*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"$bkptno\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" {
+    -re ".*000\\*stopped,thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" {
       pass "$test"
       return 0
     }
@@ -1034,3 +1034,49 @@ proc mi_check_varobj_value { name value 
 	"\\^done,value=\"$value\"" \
 	$testname
 }
+
+# Check the results of the:
+#
+#   -var-list-children VARNAME
+#
+# command.  The CHILDREN parement should be a list of lists.
+# Each inner list can have either 3 or 4 elements, describing
+# fields that gdb is expected to report for child variable object,
+# in the following order
+#
+#   - Name
+#   - Expression
+#   - Number of children
+#   - Type
+#
+# If inner list has 3 elements, the gdb is expected to output no
+# type for a child.
+#
+proc mi_list_varobj_children { varname children testname } {
+
+    set numchildren [llength $children]
+    set children_exp {}
+    set whatever "\"\[^\"\]+\""
+
+    foreach item $children {
+
+        set name [lindex $item 0]
+        set exp [lindex $item  1]
+        set numchild [lindex $item 2]
+        if {[llength $item] == 4} {
+            set type [lindex $item 3]
+
+            lappend children_exp\
+                "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"}"
+        } else {
+            lappend children_exp\
+                "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"}"
+        }
+    }
+    set children_exp_j [join $children_exp ","]
+    set expected "\\^done,numchild=\"$numchildren\",children=\\\[$children_exp_j\\\]"
+
+    verbose -log "Expecting: $expected"
+
+    mi_gdb_test "-var-list-children $varname" $expected $testname
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]