Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: gdb/testsuite/lib/mi-support.exp

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/lib/go.exp ('k') | gdb/testsuite/lib/trace-support.exp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 1999-2000, 2002-2005, 2007-2012 Free Software Foundation, 1 # Copyright 1999-2000, 2002-2005, 2007-2012 Free Software Foundation,
2 # Inc. 2 # Inc.
3 3
4 # This program is free software; you can redistribute it and/or modify 4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by 5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or 6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version. 7 # (at your option) any later version.
8 # 8 #
9 # This program is distributed in the hope that it will be useful, 9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 13 matching lines...) Expand all
24 if ![info exists mi_gdb_prompt] then { 24 if ![info exists mi_gdb_prompt] then {
25 set mi_gdb_prompt "\[(\]gdb\[)\] \r\n" 25 set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
26 } 26 }
27 27
28 global mi_inferior_spawn_id 28 global mi_inferior_spawn_id
29 global mi_inferior_tty_name 29 global mi_inferior_tty_name
30 30
31 set MIFLAGS "-i=mi" 31 set MIFLAGS "-i=mi"
32 32
33 set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r\n" 33 set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r\n"
34 set library_loaded_re "=library-loaded\[^\n\]+\"\r\n" 34 set gdbindex_warning_re "&\"warning: Skipping \[^\r\n\]+ \.gdb_index section in \[^\r\n\]+\"\r\n(?:&\"\\\\n\"\r\n)?"
35 set library_loaded_re "=library-loaded\[^\n\]+\"\r\n(?:$gdbindex_warning_re)?"
35 set breakpoint_re "=(?:breakpoint-created|breakpoint-deleted)\[^\n\]+\"\r\n" 36 set breakpoint_re "=(?:breakpoint-created|breakpoint-deleted)\[^\n\]+\"\r\n"
36 37
37 # 38 #
38 # mi_gdb_exit -- exit the GDB, killing the target program if necessary 39 # mi_gdb_exit -- exit the GDB, killing the target program if necessary
39 # 40 #
40 proc mi_gdb_exit {} { 41 proc mi_gdb_exit {} {
41 catch mi_uncatched_gdb_exit 42 catch mi_uncatched_gdb_exit
42 } 43 }
43 44
44 proc mi_uncatched_gdb_exit {} { 45 proc mi_uncatched_gdb_exit {} {
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } 1054 }
1054 } 1055 }
1055 return 1056 return
1056 } 1057 }
1057 1058
1058 set args "\\\[$args\\\]" 1059 set args "\\\[$args\\\]"
1059 1060
1060 set bn "" 1061 set bn ""
1061 if { $reason == "breakpoint-hit" } { 1062 if { $reason == "breakpoint-hit" } {
1062 set bn {bkptno="[0-9]+",} 1063 set bn {bkptno="[0-9]+",}
1064 } elseif { $reason == "solib-event" } {
1065 set bn ".*"
1063 } 1066 }
1064 1067
1065 set r "" 1068 set r ""
1066 if { $reason != "" } { 1069 if { $reason != "" } {
1067 set r "reason=\"$reason\"," 1070 set r "reason=\"$reason\","
1068 } 1071 }
1069 1072
1070 1073
1071 set a $after_reason 1074 set a $after_reason
1072 1075
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 } else { 1291 } else {
1289 set er "$er,$v" 1292 set er "$er,$v"
1290 } 1293 }
1291 } 1294 }
1292 set er "$er\\\]" 1295 set er "$er\\\]"
1293 1296
1294 verbose -log "Expecting: $er" 2 1297 verbose -log "Expecting: $er" 2
1295 mi_gdb_test "-var-update $name" $er $testname 1298 mi_gdb_test "-var-update $name" $er $testname
1296 } 1299 }
1297 1300
1298 proc mi_varobj_update_with_type_change { name new_type new_children testname } { 1301 proc mi_varobj_update_with_child_type_change { name child_name new_type new_chil dren testname } {
1299 set v "{name=\"$name\",in_scope=\"true\",type_changed=\"true\",new_type=\"$n ew_type\",new_num_children=\"$new_children\",has_more=\".\"}" 1302 set v "{name=\"$child_name\",in_scope=\"true\",type_changed=\"true\",new_typ e=\"$new_type\",new_num_children=\"$new_children\",has_more=\".\"}"
1300 set er "\\^done,changelist=\\\[$v\\\]" 1303 set er "\\^done,changelist=\\\[$v\\\]"
1301 verbose -log "Expecting: $er" 1304 verbose -log "Expecting: $er"
1302 mi_gdb_test "-var-update $name" $er $testname 1305 mi_gdb_test "-var-update $name" $er $testname
1303 } 1306 }
1304 1307
1308 proc mi_varobj_update_with_type_change { name new_type new_children testname } {
1309 mi_varobj_update_with_child_type_change $name $name $new_type $new_children $testname
1310 }
1311
1305 # A helper that turns a key/value list into a regular expression 1312 # A helper that turns a key/value list into a regular expression
1306 # matching some MI output. 1313 # matching some MI output.
1307 proc mi_varobj_update_kv_helper {list} { 1314 proc mi_varobj_update_kv_helper {list} {
1308 set first 1 1315 set first 1
1309 set rx "" 1316 set rx ""
1310 foreach {key value} $list { 1317 foreach {key value} $list {
1311 if {!$first} { 1318 if {!$first} {
1312 append rx , 1319 append rx ,
1313 } 1320 }
1314 set first 0 1321 set first 0
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 # {const int} {*iPtr} {} 2012 # {const int} {*iPtr} {}
2006 # } 2013 # }
2007 # } 2014 # }
2008 # } 2015 # }
2009 # } 2016 # }
2010 # } 2017 # }
2011 # } 2018 # }
2012 # } 2019 # }
2013 # } 2020 # }
2014 # 2021 #
2015 # mi_walk_varobj_tree $tree 2022 # mi_walk_varobj_tree c++ $tree
2016 # 2023 #
2017 # If you'd prefer to walk the tree using your own callback, 2024 # If you'd prefer to walk the tree using your own callback,
2018 # simply pass the name of the callback to mi_walk_varobj_tree. 2025 # simply pass the name of the callback to mi_walk_varobj_tree.
2019 # 2026 #
2020 # This callback should take one argument, the name of the variable 2027 # This callback should take one argument, the name of the variable
2021 # to process. This name is the name of a global array holding the 2028 # to process. This name is the name of a global array holding the
2022 # variable's properties (object name, type, etc). 2029 # variable's properties (object name, type, etc).
2023 # 2030 #
2024 # An example callback: 2031 # An example callback:
2025 # 2032 #
2026 # proc my_callback {var} { 2033 # proc my_callback {var} {
2027 # upvar #0 $var varobj 2034 # upvar #0 $var varobj
2028 # 2035 #
2029 # puts "my_callback: called on varobj $varobj(obj_name)" 2036 # puts "my_callback: called on varobj $varobj(obj_name)"
2030 # } 2037 # }
2031 # 2038 #
2032 # The arrays created for each variable object contain the following 2039 # The arrays created for each variable object contain the following
2033 # members: 2040 # members:
2034 # 2041 #
2035 # obj_name - the object name for accessing this variable via MI 2042 # obj_name - the object name for accessing this variable via MI
2036 # display_name - the display name for this variable (exp="display_name" in 2043 # display_name - the display name for this variable (exp="display_name" in
2037 # the output of -var-list-children) 2044 # the output of -var-list-children)
2038 # type - the type of this variable (type="type" in the output 2045 # type - the type of this variable (type="type" in the output
2039 # of -var-list-children, or the special tag "anonymous" 2046 # of -var-list-children, or the special tag "anonymous"
2040 # path_expr - the "-var-info-path-expression" for this variable 2047 # path_expr - the "-var-info-path-expression" for this variable
2048 # NOTE: This member cannot be used reliably with typedefs.
2049 # Use with caution!
2050 # See notes inside get_path_expr for more.
2041 # parent - the variable name of the parent varobj 2051 # parent - the variable name of the parent varobj
2042 # children - a list of children variable names (which are the 2052 # children - a list of children variable names (which are the
2043 # names Tcl arrays, not object names) 2053 # names Tcl arrays, not object names)
2044 # 2054 #
2045 # For each variable object, an array containing the above fields will 2055 # For each variable object, an array containing the above fields will
2046 # be created under the root node (conveniently called, "root"). For example, 2056 # be created under the root node (conveniently called, "root"). For example,
2047 # a variable object with handle "OBJ.public.0_anonymous.a" will have 2057 # a variable object with handle "OBJ.public.0_anonymous.a" will have
2048 # a corresponding global Tcl variable named "root.OBJ.public.0_anonymous.a". 2058 # a corresponding global Tcl variable named "root.OBJ.public.0_anonymous.a".
2049 # 2059 #
2050 # Note that right now, this mechanism cannot be used for recursive data 2060 # Note that right now, this mechanism cannot be used for recursive data
(...skipping 26 matching lines...) Expand all
2077 2087
2078 # Output children 2088 # Output children
2079 set num [llength $varobj(children)] 2089 set num [llength $varobj(children)]
2080 eval "$cmd \"\tnum_children = $num$term\"" 2090 eval "$cmd \"\tnum_children = $num$term\""
2081 if {$num > 0} { 2091 if {$num > 0} {
2082 eval "$cmd \"\tchildren = $varobj(children)$term\"" 2092 eval "$cmd \"\tchildren = $varobj(children)$term\""
2083 } 2093 }
2084 } 2094 }
2085 2095
2086 # The default callback used by mi_walk_varobj_tree. This callback 2096 # The default callback used by mi_walk_varobj_tree. This callback
2087 # simply checks all of VAR's children. 2097 # simply checks all of VAR's children. It specifically does not test
2098 # path expressions, since that is very problematic.
2088 # 2099 #
2089 # This procedure may be used in custom callbacks. 2100 # This procedure may be used in custom callbacks.
2090 proc test_children_callback {variable_name} { 2101 proc test_children_callback {variable_name} {
2091 upvar #0 $variable_name varobj 2102 upvar #0 $variable_name varobj
2092 2103
2093 if {[llength $varobj(children)] > 0} { 2104 if {[llength $varobj(children)] > 0} {
2094 # Construct the list of children the way mi_list_varobj_children 2105 # Construct the list of children the way mi_list_varobj_children
2095 # expects to get it: 2106 # expects to get it:
2096 # { {obj_name display_name num_children type} ... } 2107 # { {obj_name display_name num_children type} ... }
2097 set children_list {} 2108 set children_list {}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 return false 2158 return false
2148 } 2159 }
2149 2160
2150 return true 2161 return true
2151 } 2162 }
2152 2163
2153 # Return the path expression for the variable named NAME in 2164 # Return the path expression for the variable named NAME in
2154 # parent varobj whose variable name is given by PARENT_VARIABLE. 2165 # parent varobj whose variable name is given by PARENT_VARIABLE.
2155 proc get_path_expr {parent_variable name type} { 2166 proc get_path_expr {parent_variable name type} {
2156 upvar #0 $parent_variable parent 2167 upvar #0 $parent_variable parent
2168 upvar #0 $parent_variable path_parent
2157 2169
2158 # If TYPE is "", this is one of the CPLUS_FAKE_CHILD varobjs, 2170 # If TYPE is "", this is one of the CPLUS_FAKE_CHILD varobjs,
2159 # which has no path expression 2171 # which has no path expression. Likewsise for anonymous structs
2160 if {[string length $type] == 0} { 2172 # and unions.
2173 if {[string length $type] == 0 \
2174 » || [string compare $type "anonymous"] == 0} {
2161 return "" 2175 return ""
2162 } 2176 }
2163 2177
2164 # Find the path parent variable. 2178 # Find the path parent variable.
2165 while {![is_path_expr_parent $parent_variable]} { 2179 while {![is_path_expr_parent $parent_variable]} {
2166 set parent_variable $parent(parent) 2180 set parent_variable $path_parent(parent)
2167 upvar #0 $parent_variable parent 2181 upvar #0 $parent_variable path_parent
2168 } 2182 }
2169 2183
2170 return "(($parent(path_expr)).$name)" 2184 # This is where things get difficult. We do not actually know
2185 # the real type for variables defined via typedefs, so we don't actually
2186 # know whether the parent is a structure/union or not.
2187 #
2188 # So we assume everything that isn't a simple type is a compound type.
2189 set stars ""
2190 regexp {\*+} $parent(type) stars
2191 set is_compound 1
2192 if {[string index $name 0] == "*"} {
2193 set is_compound 0
2194 }
2195
2196 if {[string index $parent(type) end] == "\]"} {
2197 # Parent is an array.
2198 return "($path_parent(path_expr))\[$name\]"
2199 } elseif {$is_compound} {
2200 # Parent is a structure or union or a pointer to one.
2201 if {[string length $stars]} {
2202 » set join "->"
2203 } else {
2204 » set join "."
2205 }
2206
2207 global root
2208
2209 # To make matters even more hideous, varobj.c has slightly different
2210 # path expressions for C and C++.
2211 set path_expr "($path_parent(path_expr))$join$name"
2212 if {[string compare -nocase $root(language) "c"] == 0} {
2213 » return $path_expr
2214 } else {
2215 » return "($path_expr)"
2216 }
2217 } else {
2218 # Parent is a pointer.
2219 return "*($path_parent(path_expr))"
2220 }
2171 } 2221 }
2172 2222
2173 # Process the CHILDREN (a list of varobj_tree elements) of the variable 2223 # Process the CHILDREN (a list of varobj_tree elements) of the variable
2174 # given by PARENT_VARIABLE. Returns a list of children variables. 2224 # given by PARENT_VARIABLE. Returns a list of children variables.
2175 proc get_tree_children {parent_variable children} { 2225 proc get_tree_children {parent_variable children} {
2176 upvar #0 $parent_variable parent 2226 upvar #0 $parent_variable parent
2177 2227
2178 set field_idx 0 2228 set field_idx 0
2179 set children_list {} 2229 set children_list {}
2180 foreach {type name children} $children { 2230 foreach {type name children} $children {
(...skipping 20 matching lines...) Expand all
2201 lappend children_list [create_varobj $parent_variable $objname \ 2251 lappend children_list [create_varobj $parent_variable $objname \
2202 $disp_name $type $path_expr $children] 2252 $disp_name $type $path_expr $children]
2203 incr field_idx 2253 incr field_idx
2204 } 2254 }
2205 2255
2206 return $children_list 2256 return $children_list
2207 } 2257 }
2208 2258
2209 # The main procedure to call the given CALLBACK on the elements of the 2259 # The main procedure to call the given CALLBACK on the elements of the
2210 # given varobj TREE. See detailed explanation above. 2260 # given varobj TREE. See detailed explanation above.
2211 proc walk_tree {tree callback} { 2261 proc walk_tree {language tree callback} {
2212 global root 2262 global root
2213 2263
2214 if {[llength $tree] < 3} { 2264 if {[llength $tree] < 3} {
2215 error "tree does not contain enough elements" 2265 error "tree does not contain enough elements"
2216 } 2266 }
2217 2267
2218 # Create root node and process the tree. 2268 # Create root node and process the tree.
2269 array set root [list language $language]
2219 array set root [list obj_name "root"] 2270 array set root [list obj_name "root"]
2220 array set root [list display_name "root"] 2271 array set root [list display_name "root"]
2221 array set root [list type "root"] 2272 array set root [list type "root"]
2222 array set root [list path_expr "root"] 2273 array set root [list path_expr "root"]
2223 array set root [list parent "root"] 2274 array set root [list parent "root"]
2224 array set root [list children [get_tree_children root $tree]] 2275 array set root [list children [get_tree_children root $tree]]
2225 2276
2226 # Walk the tree 2277 # Walk the tree
2227 set all_nodes $root(children); # a stack of nodes 2278 set all_nodes $root(children); # a stack of nodes
2228 while {[llength $all_nodes] > 0} { 2279 while {[llength $all_nodes] > 0} {
(...skipping 23 matching lines...) Expand all
2252 } 2303 }
2253 } 2304 }
2254 2305
2255 # The default varobj tree callback, which simply tests -var-list-children. 2306 # The default varobj tree callback, which simply tests -var-list-children.
2256 proc mi_varobj_tree_test_children_callback {variable} { 2307 proc mi_varobj_tree_test_children_callback {variable} {
2257 ::varobj_tree::test_children_callback $variable 2308 ::varobj_tree::test_children_callback $variable
2258 } 2309 }
2259 2310
2260 # Walk the variable object tree given by TREE, calling the specified 2311 # Walk the variable object tree given by TREE, calling the specified
2261 # CALLBACK. By default this uses mi_varobj_tree_test_children_callback. 2312 # CALLBACK. By default this uses mi_varobj_tree_test_children_callback.
2262 proc mi_walk_varobj_tree {tree {callback \ 2313 proc mi_walk_varobj_tree {language tree \
2263 » » » » mi_varobj_tree_test_children_callback}} { 2314 » » » {callback \
2264 ::varobj_tree::walk_tree $tree $callback 2315 » » » » mi_varobj_tree_test_children_callback}} {
2316 ::varobj_tree::walk_tree $language $tree $callback
2265 } 2317 }
OLDNEW
« no previous file with comments | « gdb/testsuite/lib/go.exp ('k') | gdb/testsuite/lib/trace-support.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698