[RFA,testsuite,3/5] Introduce mi_make_breakpoint

Message ID 53580CF1.5090208@redhat.com
State Committed
Headers

Commit Message

Keith Seitz April 23, 2014, 6:56 p.m. UTC
  On 04/17/2014 01:40 PM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>
> Keith> 2014-04-15  Keith Seitz  <keiths@redhat.com>
> Keith> 	* lib/mi-support.exp (mi_create_breakpoint): Use mi_make_breakpoint
> Keith> 	and return the result.
> Keith> 	(mi_make_breakpoint): New procedure.
>
> One nit below.
>
> Keith> +    parse_args {{number .*} {type .*} {disp .*} {enabled .*} {addr .*} \
> Keith> +		    {func .*} {file .*} {fullname .*} {line .*} \
> Keith> +		    {thread-groups \\\[.*\\\]} {times .*} {ignore 0} \
> Keith> +		    {script ""} {original-location .*}}
>
> I don't think the backslashes are needed at the ends of lines here.
> The outer braces ought to be sufficient.

For the record, here is what I will be pushing in a few moments.

Keith

V2 changes:
* Remove trailing '\'

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.
  

Patch

diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index abbcd8d..a497208 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
+}