[1/2] gdb/testsuite: add mi_info_frame helper proc (and use it)
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
New helper proc mi_info_frame which takes care of running the MI
-stack-info-frame command and matching its output.
Like the breakpoint helper procs, this new proc takes a name/value
argument list and uses this to build the expected result regexp. This
means that we can now write something like:
mi_info_frame "test name here" \
-level 0 -func name -line 123
Instead of the current equivalent:
mi_gdb_test "235-stack-info-frame" \
"235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"name\",file=\".*\",fullname=\".*\",line=\"123\",arch=\".*\"\}" \
"test name here"
There's also a helper proc mi_make_info_frame_regexp which is
responsible for building the 'frame={...}' part of the pattern.
I've update the two existing tests that use -stack-info-frame and
expect the command to succeed. There is another test that runs
-stack-info-frame and expects the command to fail -- the helper proc
doesn't help with this case, so that test is not changed.
---
gdb/testsuite/gdb.mi/mi-cmd-user-context.exp | 12 ++---
gdb/testsuite/gdb.mi/mi-stack.exp | 7 +--
gdb/testsuite/lib/mi-support.exp | 52 ++++++++++++++++++++
3 files changed, 62 insertions(+), 9 deletions(-)
@@ -84,9 +84,9 @@ mi_gdb_test "frame" \
# Ask about a different frame in the current thread, the current frame
# should not change.
-mi_gdb_test "-stack-info-frame --thread 2 --frame 1" \
- "\\^done,frame=\{level=\"1\".*" \
- "-stack-info-frame 1"
+mi_info_frame "-stack-info-frame 1" \
+ -thread 2 -frame 1 \
+ -level 1
mi_gdb_test "thread" \
".*Current thread is 2.*" \
@@ -99,9 +99,9 @@ mi_gdb_test "frame" \
# Ask about a different frame in a different thread. After this the
# current thread and frame should not have changed.
-mi_gdb_test "-stack-info-frame --thread 3 --frame 1" \
- "\\^done,frame=\{level=\"1\".*" \
- "-stack-info-frame 2"
+mi_info_frame "-stack-info-frame 2" \
+ -thread 3 -frame 1 \
+ -level 1
mi_gdb_test "thread" \
".*Current thread is 2.*" \
@@ -65,9 +65,10 @@ proc test_stack_frame_listing {} {
"234\\^error,msg=\"-stack-list-frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \
"stack frame listing wrong"
- mi_gdb_test "235-stack-info-frame" \
- "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\",arch=\"$any\"\}" \
- "selected frame listing"
+ mi_info_frame "selected frame listing" \
+ -level 0 -addr $hex -func callee4 -file ".*${srcfile}" \
+ -fullname "${fullname_syntax}${srcfile}" -line $callee4_begin \
+ -arch $any
mi_gdb_test "236-stack-list-frames 1 300" \
"236\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \
@@ -2629,6 +2629,58 @@ proc mi_make_breakpoint_1 {attr_list thread cond evaluated-by times \
}
+# Construct a regexp to match against a frame description as returned by
+# -stack-info-frame. Take a list of name value pairs. Valid names are
+# -level, -addr, -func, -file, -fullname, line, and -arch, each takes a
+# regexp which is matched against the corresponding field in the
+# -stack-info-frame output.
+
+proc mi_make_info_frame_regexp {args} {
+ parse_args [list [list level "$::decimal"] [list addr "$::hex"] \
+ {func .*} {file .*} {fullname .*} \
+ [list line "$::decimal"] {arch .*}]
+
+ set attr_list {}
+ foreach attr {level addr func file fullname line arch} {
+ lappend attr_list $attr [set $attr]
+ }
+
+ set result "frame=\\\{"
+ append result [mi_build_kv_pairs $attr_list]
+ append result "\\\}"
+ return $result
+}
+
+# Run the -stack-info-frame command and match the result, return true if the
+# test passes, otherwise, return false.
+#
+# TEST is the name used for this test.
+#
+# ARGS is an optional list of name value pairs, the names -frame and -thread
+# if present, expect a decimal argument and control the frame and thread for
+# which -stack-info-frame is run. If -frame is not given then the
+# -stack-info-frame will operate on the current frame. If -thread is not
+# given then -stack-info-frame will operate on the current thread.
+#
+# The remaining arguments are passed to mi_make_frame_regexp and are used to
+# build the regexp for matching against the -stack-info-frame output.
+
+proc mi_info_frame { test args } {
+ parse_args {{frame ""} {thread ""}}
+
+ set re [eval mi_make_info_frame_regexp $args]
+
+ set cmd "235-stack-info-frame"
+ if {$frame ne ""} {
+ append cmd " --frame ${frame}"
+ }
+ if {$thread ne ""} {
+ append cmd " --thread ${thread}"
+ }
+
+ return [mi_gdb_test $cmd "235\\^done,$re" $test]
+}
+
# Construct a breakpoint regexp, for a breakpoint with multiple
# locations. This may be used to test the output of -break-insert,
# -dprintf-insert, or -break-info with breakpoints with multiple