This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
MI varobj/testing tweaks
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Thu, 4 Jan 2007 16:57:25 -0500
- Subject: MI varobj/testing tweaks
Some things I found while testing a queued patch after Vlad's and
Nick's recent changes. It had a char[0], for which num_children
got left as -1. Which is bad, because (A) we don't document any
useful meaning for a negative number of children, and (B) integer
promotion turns that into an infinite loop.
This also fixes a race condition in mi_runto_helper. If it sees
"^running\r\n(gdb)\r\n" when it expects to be waiting for ^stopped,
it will issue a FAIL and get out of synch.
Tested x86_64-pc-linux-gnu, checked in.
--
Daniel Jacobowitz
CodeSourcery
2007-01-04 Daniel Jacobowitz <dan@codesourcery.com>
* varobj.c (varobj_list_children): Stop if the number of children is
unknown.
(c_number_of_children): Report no children for zero sized arrays.
2007-01-04 Daniel Jacobowitz <dan@codesourcery.com>
* lib/mi-support.exp (mi_runto_helper): Expect two prompts
when continuing.
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.71
diff -u -p -r1.71 varobj.c
--- varobj.c 4 Jan 2007 19:27:50 -0000 1.71
+++ varobj.c 4 Jan 2007 21:47:38 -0000
@@ -685,6 +685,10 @@ varobj_list_children (struct varobj *var
if (var->num_children == -1)
var->num_children = number_of_children (var);
+ /* If that failed, give up. */
+ if (var->num_children == -1)
+ return -1;
+
/* If we're called when the list of children is not yet initialized,
allocate enough elements in it. */
while (VEC_length (varobj_p, var->children) < var->num_children)
@@ -1711,7 +1715,9 @@ c_number_of_children (struct varobj *var
&& TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
else
- children = -1;
+ /* If we don't know how many elements there are, don't display
+ any. */
+ children = 0;
break;
case TYPE_CODE_STRUCT:
Index: testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.37
diff -u -p -r1.37 mi-support.exp
--- testsuite/lib/mi-support.exp 4 Jan 2007 20:12:15 -0000 1.37
+++ testsuite/lib/mi-support.exp 4 Jan 2007 21:49:54 -0000
@@ -880,8 +880,17 @@ proc mi_runto_helper {func run_or_contin
if {$run_or_continue == "run"} {
mi_run_cmd
} else {
- send_gdb "000-exec-continue\n"
+ send_gdb "000-exec-continue\n"
+ gdb_expect {
+ -re "000\\^running\r\n${mi_gdb_prompt}" {
+ }
+ timeout {
+ fail "$test"
+ return -1
+ }
+ }
}
+
gdb_expect {
-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"