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]

[PATCH 10/12] Match dynamic="1" in the output of -var-list-children


When I play with pretty-printer and available-children-only, I get the
following output,

-var-list-children  ss1
^done,numchild="2",children=[child={name="ss1.a",exp="a",numchild="0",type="struct s",thread-id="1",dynamic="1"},child={name="ss1.b",exp="b",numchild="0",type="struct s",thread-id="1",dynamic="1"}],has_more="0"

existing proc mi_child_regexp doesn't append "dynamic=1" to the pattern,
so it doesn't match output.  This patch adds "dynamic=1" to the pattern.

I am not satisfied with the regexp construction for each child in
mi_child_regexp.  In each list, there are three mandatory fields,
"name", "exp", and "numchild".  There are also some optional fields,
"value", "type" and "dynamic".  The current regexp construction code
is hard to be extended (add for "dynamic").  I suggest that we can
pass the list to mi_list_varobj_children like this,

 { name exp numchild optional }

the list has four elements, and OPTIONAL is an array, which index can
be "value", "type" or "dynamic".  The existing usage of
mi_list_varobj_children like:

mi_list_varobj_children "struct_declarations" {
    {struct_declarations.integer integer 0 int}
} "test"

will be rewritten to:

mi_list_varobj_children "struct_declarations" {
    {struct_declarations.integer integer 0 {type int}}
} "test"

if we want to match "dynamic" attribute, we can write:

mi_list_varobj_children "struct_declarations" {
    {struct_declarations.integer integer 0 {type int dynamic 1}}
} "test"

Since mi_list_varobj_children has been widely used in test suite, I'd
like to defer the change after this patch series.

 V2:
 - Remove empty 'else' block.

gdb/testsuite:

2014-02-14  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_child_regexp): Append 'dynamic="1"' to
	children_exp.
---
 gdb/testsuite/lib/mi-support.exp |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 1e8fee6..df68bd2 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1410,21 +1410,24 @@ proc mi_child_regexp {children add_child} {
 	set name [lindex $item 0]
 	set exp [lindex $item  1]
 	set numchild [lindex $item 2]
+
+	set line "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\""
+
 	if {[llength $item] == 5} {
 	    set type [lindex $item 3]
 	    set value [lindex $item 4]
 
-	    lappend children_exp\
-		"$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\"$value\",type=\"$type\"(,thread-id=\"\[0-9\]+\")?}"
+	    append line ",value=\"$value\",type=\"$type\""
 	} elseif {[llength $item] == 4} {
 	    set type [lindex $item 3]
 
-	    lappend children_exp\
-		"$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"(,thread-id=\"\[0-9\]+\")?}"
-	} else {
-	    lappend children_exp\
-		"$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
+	    append line ",type=\"$type\""
 	}
+
+	append line \
+	    "(,thread-id=\"\[0-9\]+\")?(,dynamic=\"1\")?}"
+
+	lappend children_exp $line
     }
     return [join $children_exp ","]
 }
-- 
1.7.7.6


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