aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-08-04 14:25:54 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-08-23 10:29:15 +0100
commit696b09bb2a1c9023a294096cfde085e395b4e5cc (patch)
treee75750df7d622519ca85c9ee9b963a7c448a8891 /gdb
parent9d7d58e7262eff313be6a1e66b8b026e3e7fed0d (diff)
downloadgdb-696b09bb2a1c9023a294096cfde085e395b4e5cc.zip
gdb-696b09bb2a1c9023a294096cfde085e395b4e5cc.tar.gz
gdb-696b09bb2a1c9023a294096cfde085e395b4e5cc.tar.bz2
gdb/testsuite: add mi_info_frame helper proc (and use it)
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/gdb.mi/mi-cmd-user-context.exp12
-rw-r--r--gdb/testsuite/gdb.mi/mi-stack.exp7
-rw-r--r--gdb/testsuite/lib/mi-support.exp51
3 files changed, 61 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
index 6abdb94..b6877b6 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
@@ -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.*" \
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index 777a425..592a3cf 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -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\",.*\}\\\]" \
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index c9af88b..872d93a 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2636,6 +2636,57 @@ proc mi_make_breakpoint_1 {attr_list thread inferior cond evaluated-by \
return $result
}
+# 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,