This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA testsuite 3/5] Introduce mi_make_breakpoint
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Wed, 16 Apr 2014 11:52:09 -0700
- Subject: [RFA testsuite 3/5] Introduce mi_make_breakpoint
- Authentication-results: sourceware.org; auth=none
This next patch introduces mi_make_breakpoint. This function builds
breakpoint regexps, such as "bkpt={number=\".*\", [snip]}".
I've also taken this time to change mi_create_breakpoint to use the same
interface as this function and return the result.
Note that ONLY the options given to
mi_make_breakpoint/mi_create_breakpoint will actually be tested. So if
-number is omitted, the regexp will allow anything [number=\".*\"] It
gets a little tricky with optional arguments, like -script and -ignore,
but as far as I know, I've handled all those cases.
Examples:
# Create a breakpoint regexp which only looks for "number=\"3\""
mi_make_breakpoint -number 3
# Create a breakpoint in myfile.c:21
mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21
testsuite/ChangeLog
2014-04-15 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp (mi_create_breakpoint): Use mi_make_breakpoint
and return the result.
(mi_make_breakpoint): New procedure.
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index abbcd8d..fa778eb 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1232,12 +1232,14 @@ proc mi0_continue_to { bkptno func args file line test } {
"$func" "$args" "$file" "$line" "" "$test"
}
-# Creates a breakpoint and checks the reported fields are as expected
-proc mi_create_breakpoint { location number disp func file line address test } {
- verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",original-location=\".*\"\}"
- mi_gdb_test "222-break-insert $location" \
- "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",original-location=\".*\"\}" \
- $test
+# Creates a breakpoint and checks the reported fields are as expected.
+# This procedure takes the same options as mi_make_breakpoint and
+# returns the breakpoint regexp from that procedure.
+
+proc mi_create_breakpoint {location test args} {
+ set bp [eval mi_make_breakpoint $args]
+ mi_gdb_test "222-break-insert $location" "222\\^done,$bp" $test
+ return $bp
}
proc mi_list_breakpoints { expected test } {
@@ -2376,3 +2378,56 @@ proc mi_build_kv_pairs {attr_list {joiner ,}} {
}
return "[join $l $joiner]"
}
+
+# Construct a breakpoint regexp. This may be used to test the output of
+# -break-insert, -dprintf-insert, or -break-info.
+#
+# All arguments for the breakpoint may be specified using the options
+# number, type, disp, enabled, addr, func, file, fullanme, line,
+# thread-groups, times, ignore, script, and original-location.
+#
+# Only if -script and -ignore are given will they appear in the output.
+# Otherwise, this procedure will skip them using ".*".
+#
+# Example: mi_make_breakpoint -number 2 -file ".*/myfile.c" -line 3
+# will return the breakpoint:
+# bkpt={number="2",type=".*",disp=".*",enabled=".*",addr=".*",func=".*",
+# file=".*/myfile.c",fullname=".*",line="3",thread-groups=\[.*\],
+# times="0".*original-location=".*"}
+
+proc mi_make_breakpoint {args} {
+ parse_args {{number .*} {type .*} {disp .*} {enabled .*} {addr .*} \
+ {func .*} {file .*} {fullname .*} {line .*} \
+ {thread-groups \\\[.*\\\]} {times .*} {ignore 0} \
+ {script ""} {original-location .*}}
+
+ set attr_list {}
+ foreach attr [list number type disp enabled addr func file \
+ fullname line thread-groups times] {
+ lappend attr_list $attr [set $attr]
+ }
+
+ set result "bkpt={[mi_build_kv_pairs $attr_list]"
+
+ # There are always exceptions.
+ # If SCRIPT and IGNORE are not present, do not output them.
+ if {$ignore != 0} {
+ append result ","
+ append result [mi_build_kv_pairs [list "ignore" $ignore]]
+ append result ","
+ }
+ if {[string length $script] > 0} {
+ append result ","
+ append result [mi_build_kv_pairs [list "script" $script]]
+ append result ","
+ } else {
+ # Allow anything up until the next "official"/required attribute.
+ # This pattern skips over script/ignore if matches on those
+ # were not specifically required by the caller.
+ append result ".*"
+ }
+ append result [mi_build_kv_pairs \
+ [list "original-location" ${original-location}]]
+ append result "}"
+ return $result
+}