aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2009-09-15 18:51:26 +0000
committerTom Tromey <tromey@redhat.com>2009-09-15 18:51:26 +0000
commit0cc7d26fe4e30614f7ca3d3abd607d938b56dbf0 (patch)
treedd150a090dac11d841608d5b437e7f04c6733593 /gdb/testsuite/lib
parent1acf546ea5a0a65be516aefe252bcf7f2daaccb3 (diff)
downloadgdb-0cc7d26fe4e30614f7ca3d3abd607d938b56dbf0.zip
gdb-0cc7d26fe4e30614f7ca3d3abd607d938b56dbf0.tar.gz
gdb-0cc7d26fe4e30614f7ca3d3abd607d938b56dbf0.tar.bz2
gdb
* varobj.h (varobj_update_result_t) <new>: New field. (varobj_get_child_range, varobj_set_child_range): Declare. (varobj_list_children): Update. (varobj_enable_pretty_printing, varobj_has_more) (varobj_pretty_printed_p): Declare. * varobj.c (pretty_printing): New global. (varobj_enable_pretty_printing): New function. (struct varobj_root) <from, to, constructor, child_iter, saved_item>: New fields. (varobj_create): Don't call install_default_visualizer. (instantiate_pretty_printer): Don't use value_copy. (varobj_has_more): New function. (restrict_range): New function. (install_dynamic_child): Likewise. (dynamic_varobj_has_child_method): Likewise. (update_dynamic_varobj_children): Remove 'new_and_unchanged' argument; add 'new', 'unchanged', 'from', and 'to' arguments. Rewrite. (varobj_get_num_children): Call update_dynamic_varobj_children. (varobj_list_children): Add 'from' and 'to' arguments. Ignore result of update_dynamic_varobj_children. Don't call install_default_visualizer. Restrict result range. (varobj_add_child): Don't call install_default_visualizer. (varobj_pretty_printed_p): New function. (install_visualizer): Rewrite. Move earlier in file. (install_default_visualizer): Likewise. (construct_visualizer): New function. (install_new_value_visualizer): Likewise. (install_new_value): Don't call release_value. Special case pretty-printed objects. Use value_incref. Rearrange "changed" logic. (varobj_get_child_range): New function. (varobj_set_child_range): Likewise. (varobj_set_visualizer): Rewrite. (varobj_update): Rewrite pretty-printing logic. (new_variable): Initialize new fields. (free_variable): Destroy new fields. (value_of_root): Copy 'from' and 'to'. (my_value_of_variable): Handle pretty-printers. (value_get_print_value): Rework pretty-printing logic. (cplus_describe_child): Don't use release_value. * mi/mi-cmds.h (mi_cmd_enable_pretty_printing) (mi_cmd_var_set_update_range): Declare. * mi/mi-cmds.c (mi_cmds): Add enable-pretty-printing and var-set-update-range. * mi/mi-cmd-var.c (print_varobj): Update. Emit "dynamic" attribute. (mi_cmd_var_create): Emit "has_more" attribute. (mi_cmd_var_set_format): Plug memory leak. (mi_print_value_p): Replace 'type' argument with 'var'. Handle pretty-printed varobjs. (mi_cmd_var_list_children): Accept 'from' and 'to' arguments. Emit "has_more" attribute. (mi_cmd_var_evaluate_expression): Plug memory leak. (mi_cmd_var_assign): Likewise. (varobj_update_one): Likewise. Emit "dynamic", "has_more", and "new_children" attributes. (mi_cmd_enable_pretty_printing): New function. (mi_cmd_var_set_update_range): Likewise. gdb/doc * gdb.texinfo (GDB/MI Variable Objects): Document -enable-pretty-printing, -var-set-update-range, dynamic varobjs. Expand -var-update documentation. gdb/testsuite * lib/mi-support.exp (mi_create_varobj): Update. (mi_create_floating_varobj): Likewise. (mi_create_dynamic_varobj): New proc. (mi_varobj_update): Update. (mi_varobj_update_with_type_change): Likewise. (mi_varobj_update_kv_helper): New proc. (mi_varobj_update_dynamic_helper): Rewrite. (mi_varobj_update_dynamic): New proc. (mi_list_varobj_children): Update. (mi_list_varobj_children_range): Add 'from' and 'to' arguments. * gdb.python/python-prettyprint.py (pp_outer): New class. (pp_nullstr): Likewise. (lookup_function): Register new printers. * gdb.python/python-prettyprint.c (struct substruct): New type. (struct outerstruct): Likewise. (substruct_test): New function. (struct nullstr): New type. (string_1, string_2): New globals. (main): Add new tests. * gdb.python/python-mi.exp: Added regression tests. * gdb.mi/mi2-var-display.exp: Update. * gdb.mi/mi2-var-cmd.exp: Update. * gdb.mi/mi2-var-child.exp: Update. * gdb.mi/mi2-var-block.exp: Update. * gdb.mi/mi-var-invalidate.exp: Update. * gdb.mi/mi-var-display.exp: Update. * gdb.mi/mi-var-cmd.exp: Update. * gdb.mi/mi-var-child.exp: Update. * gdb.mi/mi-var-block.exp: Update. * gdb.mi/mi-break.exp: Update. * gdb.mi/gdb701.exp: Update.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/mi-support.exp100
1 files changed, 82 insertions, 18 deletions
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index e691232..167a02c 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1195,13 +1195,13 @@ proc mi_list_breakpoints { expected test } {
# Name cannot be "-".
proc mi_create_varobj { name expression testname } {
mi_gdb_test "-var-create $name * $expression" \
- "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*" \
+ "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*,has_more=\"0\"" \
$testname
}
proc mi_create_floating_varobj { name expression testname } {
mi_gdb_test "-var-create $name @ $expression" \
- "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*" \
+ "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type=.*" \
$testname
}
@@ -1214,6 +1214,14 @@ proc mi_create_varobj_checked { name expression type testname } {
$testname
}
+# Same as mi_create_floating_varobj, but assumes the test is creating
+# a dynamic varobj that has children, so the value must be "{...}".
+proc mi_create_dynamic_varobj {name expression testname} {
+ mi_gdb_test "-var-create $name @ $expression" \
+ "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\"{\\.\\.\\.}\",type=.*" \
+ $testname
+}
+
# Deletes the specified NAME.
proc mi_delete_varobj { name testname } {
mi_gdb_test "-var-delete $name" \
@@ -1229,7 +1237,7 @@ proc mi_varobj_update { name expected testname } {
set er "\\^done,changelist=\\\["
set first 1
foreach item $expected {
- set v "{name=\"$item\",in_scope=\"true\",type_changed=\"false\"}"
+ set v "{name=\"$item\",in_scope=\"true\",type_changed=\"false\",has_more=\".\"}"
if {$first == 1} {
set er "$er$v"
set first 0
@@ -1244,22 +1252,70 @@ proc mi_varobj_update { name expected testname } {
}
proc mi_varobj_update_with_type_change { name new_type new_children testname } {
- set v "{name=\"$name\",in_scope=\"true\",type_changed=\"true\",new_type=\"$new_type\",new_num_children=\"$new_children\"}"
+ set v "{name=\"$name\",in_scope=\"true\",type_changed=\"true\",new_type=\"$new_type\",new_num_children=\"$new_children\",has_more=\".\"}"
set er "\\^done,changelist=\\\[$v\\\]"
verbose -log "Expecting: $er"
mi_gdb_test "-var-update $name" $er $testname
}
-# Update a dynamic varobj named NAME. CHILDREN is a list of children,
-# in the same form as mi_list_varobj_children. TESTNAME is the name
-# of the test.
-proc mi_varobj_update_dynamic {name children testname} {
- set children_exp_j [mi_child_regexp $children 0]
+# A helper that turns a key/value list into a regular expression
+# matching some MI output.
+proc mi_varobj_update_kv_helper {list} {
+ set first 1
+ set rx ""
+ foreach {key value} $list {
+ if {!$first} {
+ append rx ,
+ }
+ set first 0
+ if {$key == "new_children"} {
+ append rx "$key=\\\[$value\\\]"
+ } else {
+ append rx "$key=\"$value\""
+ }
+ }
+ return $rx
+}
- set er "\\^done,changelist=\\\["
+# A helper for mi_varobj_update_dynamic that computes a match
+# expression given a child list.
+proc mi_varobj_update_dynamic_helper {children} {
+ set crx ""
- append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\""
- append er ",children=\\\[$children_exp_j.*\\\]}\\\]"
+ set first 1
+ foreach child $children {
+ if {!$first} {
+ append crx ,
+ }
+ set first 0
+ append crx "{"
+ append crx [mi_varobj_update_kv_helper $child]
+ append crx "}"
+ }
+
+ return $crx
+}
+
+# Update a dynamic varobj named NAME. CHILDREN is a list of children
+# that have been updated; NEW_CHILDREN is a list of children that were
+# added to the primary varobj. Each child is a list of key/value
+# pairs that are expected. SELF is a key/value list holding
+# information about the varobj itself. TESTNAME is the name of the
+# test.
+proc mi_varobj_update_dynamic {name testname self children new_children} {
+ if {[llength $new_children]} {
+ set newrx [mi_varobj_update_dynamic_helper $new_children]
+ lappend self new_children $newrx
+ }
+ set selfrx [mi_varobj_update_kv_helper $self]
+ set crx [mi_varobj_update_dynamic_helper $children]
+
+ set er "\\^done,changelist=\\\[\{name=\"$name\",in_scope=\"true\""
+ append er ",$selfrx\}"
+ if {"$crx" != ""} {
+ append er ",$crx"
+ }
+ append er "\\\]"
verbose -log "Expecting: $er"
mi_gdb_test "-var-update $name" $er $testname
@@ -1329,14 +1385,13 @@ proc mi_child_regexp {children add_child} {
# have no value.
#
proc mi_list_varobj_children { varname children testname } {
- mi_list_varobj_children_range $varname [llength $children] $children \
+ mi_list_varobj_children_range $varname "" "" [llength $children] $children \
$testname
}
-# Like mi_list_varobj_children, but assumes that a subrange has been
-# selected with -var-set-child-range. NUMCHILDREN is the total number
-# of children.
-proc mi_list_varobj_children_range {varname numchildren children testname} {
+# Like mi_list_varobj_children, but sets a subrange. NUMCHILDREN is
+# the total number of children.
+proc mi_list_varobj_children_range {varname from to numchildren children testname} {
set options ""
if {[llength $varname] == 2} {
set options [lindex $varname 1]
@@ -1352,9 +1407,18 @@ proc mi_list_varobj_children_range {varname numchildren children testname} {
set expected "\\^done,numchild=\"0\""
}
+ if {"$to" == ""} {
+ append expected ",has_more=\"0\""
+ } elseif {$to >= 0 && $numchildren > $to} {
+ append expected ",has_more=\"1\""
+ } else {
+ append expected ",has_more=\"0\""
+ }
+
verbose -log "Expecting: $expected"
- mi_gdb_test "-var-list-children $options $varname" $expected $testname
+ mi_gdb_test "-var-list-children $options $varname $from $to" \
+ $expected $testname
}
# Verifies that variable object VARNAME has NUMBER children,