aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2014-04-23 12:17:31 -0700
committerKeith Seitz <keiths@redhat.com>2014-04-23 12:17:31 -0700
commit4b48d43901e9864f9fc1c135ec75c80bde226cb8 (patch)
treebae6f5bdfc934ed5e0145da5e92e1c1d8046eb9b
parent51aa91f97976e0b4d6103d5c6e6a60bbd09be2fb (diff)
downloadgdb-4b48d43901e9864f9fc1c135ec75c80bde226cb8.zip
gdb-4b48d43901e9864f9fc1c135ec75c80bde226cb8.tar.gz
gdb-4b48d43901e9864f9fc1c135ec75c80bde226cb8.tar.bz2
Introduce some new MI test suite cleanups for breakpoint and
breakpoint table handling. This is a patch in five parts (all committed here in one commit). ----- 1/5: parse_args parse_args is a very useful utility function which allows you to do getopt-y kinds of things in Tcl. Example: proc myproc {foo args} { parse_args {{bar} {baz "abc"} {qux}} # ... } myproc ABC -bar -baz DEF peanut butter will define the following variables in myproc: foo (=ABC), bar (=1), baz (=DEF), and qux (=0) args will be the list {peanut butter} ----- 2/5: mi_build_kv_pairs build_kv_pairs simply does what it says: given the input list and an option join string, it combines list elements into kv-pairs for MI handling. It knows how to handle tuples and other special MI types. Example: mi_build_kv_pairs {a b c d e f g \[.*\]} returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\] ----- 3/5: mi_make_breakpoint This function builds breakpoint regexps, such as "bkpt={number=\".*\", [snip]}". 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=\".*\"] Examples: mi_make_breakpoint -number 3 mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21 ----- 4/5: mi_make_breakpoint_table This function builds MI breakpoint table regexps. Example: set bps {} lappend bps [mi_make_breakpoint -number 1 -func "main" \ -file ".*/myfile.c" -line 42 lappend bps [mi_make_breakpoint -number 2 -func "marker" \ -file ".*myfile.c" -line 21 gdb_test "-break-info" "\\^done,[mi_make_breakpoint_table $bps]" \ "breakpoint list" ----- 5/5: Update all callers Self-explanatory testsuite/ChangeLog 2014-04-23 Keith Seitz <keiths@redhat.com> * lib/mi-support.exp (mi_list_breakpoints): Delete. (mi_make_breakpoint_table): New procedure. (mi_create_breakpoint): Use mi_make_breakpoint and return the result. (mi_make_breakpoint): New procedure. (mi_build_kv_pairs): New procedure. * gdb.mi/mi-break.exp: Remove unused globals, update mi_create_breakpoint usage, and use mi_make_breakpoint_table. All callers updated. * gdb.mi/mi-dprintf.exp: Use variable to track command number. Update all callers of mi_create_breakpoint and use mi_make_breakpoint_table. Remove any unused global variables. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.mi/mi-nsmoribund.exp: Likewise. * gdb.mi/mi-nsthrexec.exp: Likewise. * gdb.mi/mi-reverse.exp: Likewise. * gdb.mi/mi-simplerun.exp: Likewise. * gdb.mi/mi-stepn.exp: Likewise. * gdb.mi/mi-syn-frame.exp: Likewise. * gdb.mi/mi-until.exp: Likewise. * gdb.mi/mi-var-cp.exp: Likewise. * gdb.mi/mi-var-display.exp: Likewise. * gdb.mi/mi2-amd64-entry-value.exp: Likewise. * gdb.mi/mi2-var-child.exp: Likewise. * gdb.mi/mi-vla-c99.exp: Likewise. * lib/mi-support.exp: Likewise. From Ian Lance Taylor <iant@cygnus.com>: * lib/gdb.exp (parse_args): New procedure.
-rw-r--r--gdb/testsuite/ChangeLog36
-rw-r--r--gdb/testsuite/gdb.mi/mi-break.exp122
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf.exp41
-rw-r--r--gdb/testsuite/gdb.mi/mi-nonstop.exp3
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsintrall.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsmoribund.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsthrexec.exp11
-rw-r--r--gdb/testsuite/gdb.mi/mi-reverse.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-simplerun.exp36
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepn.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-until.exp11
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cp.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-display.exp12
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-c99.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi2-var-child.exp5
-rw-r--r--gdb/testsuite/lib/gdb.exp63
-rw-r--r--gdb/testsuite/lib/mi-support.exp165
19 files changed, 405 insertions, 146 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ecf2147..bdf2a52 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,39 @@
+2014-04-23 Keith Seitz <keiths@redhat.com>
+
+ * lib/mi-support.exp (mi_list_breakpoints): Delete.
+ (mi_make_breakpoint_table): New procedure.
+ (mi_create_breakpoint): Use mi_make_breakpoint
+ and return the result.
+ (mi_make_breakpoint): New procedure.
+ (mi_build_kv_pairs): New procedure.
+
+ * gdb.mi/mi-break.exp: Remove unused globals,
+ update mi_create_breakpoint usage, and use mi_make_breakpoint_table.
+ All callers updated.
+ * gdb.mi/mi-dprintf.exp: Use variable to track command
+ number.
+ Update all callers of mi_create_breakpoint and use
+ mi_make_breakpoint_table.
+ Remove any unused global variables.
+ * gdb.mi/mi-nonstop.exp: Likewise.
+ * gdb.mi/mi-nsintrall.exp: Likewise.
+ * gdb.mi/mi-nsmoribund.exp: Likewise.
+ * gdb.mi/mi-nsthrexec.exp: Likewise.
+ * gdb.mi/mi-reverse.exp: Likewise.
+ * gdb.mi/mi-simplerun.exp: Likewise.
+ * gdb.mi/mi-stepn.exp: Likewise.
+ * gdb.mi/mi-syn-frame.exp: Likewise.
+ * gdb.mi/mi-until.exp: Likewise.
+ * gdb.mi/mi-var-cp.exp: Likewise.
+ * gdb.mi/mi-var-display.exp: Likewise.
+ * gdb.mi/mi2-amd64-entry-value.exp: Likewise.
+ * gdb.mi/mi2-var-child.exp: Likewise.
+ * gdb.mi/mi-vla-c99.exp: Likewise.
+ * lib/mi-support.exp: Likewise.
+
+ From Ian Lance Taylor <iant@cygnus.com>:
+ * lib/gdb.exp (parse_args): New procedure.
+
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/break-unload-file.c: New file.
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 04dd932..d9ab757 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -57,12 +57,10 @@ set fullname "fullname=\"${fullname_syntax}${srcfile}\""
proc test_tbreak_creation_and_listing {} {
global srcfile
- global hex
global line_callee4_head
global line_callee3_head
global line_callee2_body
global line_main_body
- global fullname
# Insert some breakpoints and list them
# Also, disable some so they do not interfere with other tests
@@ -73,22 +71,32 @@ proc test_tbreak_creation_and_listing {} {
# -break-insert -t srcfile:$line_callee4_head
# -break-list
- mi_create_breakpoint "-t main" 1 del main ".*basics.c" $line_main_body $hex \
- "break-insert -t operation"
-
- mi_create_breakpoint "-t basics.c:callee2" 2 del callee2 ".*basics.c" $line_callee2_body $hex \
- "insert temp breakpoint at basics.c:callee2"
-
- mi_create_breakpoint "-t basics.c:$line_callee3_head" 3 del callee3 ".*basics.c" $line_callee3_head $hex \
- "insert temp breakpoint at basics.c:\$line_callee3_head"
-
- # Getting the quoting right is tricky. That is "\"<file>\":$line_callee4_head"
- mi_create_breakpoint "-t \"\\\"${srcfile}\\\":$line_callee4_head\"" 4 del callee4 ".*basics.c" $line_callee4_head $hex \
- "insert temp breakpoint at \"<fullfilename>\":\$line_callee4_head"
+ set bps {}
+ lappend bps [mi_create_breakpoint "-t main" "break-insert -t operation" \
+ -number 1 -disp del -func main -file ".*basics.c" \
+ -line $line_main_body]
+
+ lappend bps [mi_create_breakpoint "-t basics.c:callee2" \
+ "insert temp breakpoint at basics.c:callee2" \
+ -number 2 -disp del -func callee2 -file ".*basics.c" \
+ -line $line_callee2_body]
+
+ lappend bps [mi_create_breakpoint "-t basics.c:$line_callee3_head" \
+ "insert temp breakpoint at basics.c:\$line_callee3_head" \
+ -number 3 -disp del -func callee3 -file ".*basics.c" \
+ -line $line_callee3_head]
+
+ # Getting the quoting right is tricky.
+ # That is "\"<file>\":$line_callee4_head"
+ lappend bps [mi_create_breakpoint \
+ "-t \"\\\"${srcfile}\\\":$line_callee4_head\"" \
+ "insert temp breakpoint at \"<fullfilename>\":\$line_callee4_head" \
+ -number 4 -disp del -func callee4 -file ".*basics.c" \
+ -line $line_callee4_head]
mi_gdb_test "666-break-list" \
- "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",${fullname},line=\"$line_main_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\}.*\\\]\}" \
- "list of breakpoints"
+ "666\\\^done,[mi_make_breakpoint_table $bps]" \
+ "list of breakpoints"
mi_gdb_test "777-break-delete" \
"777\\^done" \
@@ -96,7 +104,6 @@ proc test_tbreak_creation_and_listing {} {
}
proc test_rbreak_creation_and_listing {} {
- global hex
global line_callee4_body
global line_callee3_body
global line_callee2_body
@@ -113,29 +120,52 @@ proc test_rbreak_creation_and_listing {} {
# -break-list
setup_kfail "*-*-*" mi/14270
+ set bps {}
+ lappend bps [mi_make_breakpoint -number 5 -file ".*basics.c" \
+ -line $line_main_body]
mi_gdb_test "122-break-insert -r main" \
- "122\\^done,bkpt=\{number=\"5\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \
- "break-insert -r operation"
+ "122\\^done,[lindex $bps end]" \
+ "break-insert -r operation"
setup_kfail "*-*-*" mi/14270
+ lappend bps [mi_make_breakpoint -number 6 -file ".*basics.c" \
+ -line $line_callee2_body]
mi_gdb_test "133-break-insert -r callee2" \
- "133\\^done,bkpt=\{number=\"6\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee2_body\"\}" \
- "insert breakpoint with regexp callee2"
+ "133\\^done,[lindex $bps end]" \
+ "insert breakpoint with regexp callee2"
setup_kfail "*-*-*" mi/14270
+ set start [llength $bps]
+ lappend bps [mi_make_breakpoint -number 7 -file ".*basics.c" \
+ -line $line_callee1_body]
+ lappend bps [mi_make_breakpoint -number 8 -file ".*basics.c" \
+ -line $line_callee2_body]
+ lappend bps [mi_make_breakpoint -number 9 -file ".*basics.c" \
+ -line $line_callee3_body]
+ lappend bps [mi_make_breakpoint -number 10 -file ".*basics.c" \
+ -line $line_callee4_body]
mi_gdb_test "144-break-insert -r callee" \
- "144\\^done,bkpt=\{number=\"7\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee1_body\"\},bkpt=\{number=\"8\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee2_body\"\},bkpt=\{number=\"9\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee3_body\"\},bkpt=\{number=\"10\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee4_body\"\}" \
- "insert breakpoint with regexp callee"
+ "144\\^done,[join [lrange $bps $start end] ,]" \
+ "insert breakpoint with regexp callee"
setup_kfail "*-*-*" mi/14270
+ set start [llength $bps]
+ lappend bps [mi_make_breakpoint -number 11 -file ".*basics.c" \
+ -line $line_callee1_body]
+ lappend bps [mi_make_breakpoint -number 12 -file ".*basics.c" \
+ -line $line_callee2_body]
+ lappend bps [mi_make_breakpoint -number 13 -file ".*basics.c" \
+ -line $line_callee3_body]
+ lappend bps [mi_make_breakpoint -number 14 -file ".*basics.c" \
+ -line $line_callee4_body]
mi_gdb_test "155-break-insert -r \.\*llee" \
- "155\\^done,bkpt=\{number=\"11\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee1_body\"\},bkpt=\{number=\"12\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee2_body\"\},bkpt=\{number=\"13\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee3_body\"\},bkpt=\{number=\"14\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee4_body\"\}" \
- "insert breakpoint with regexp .*llee"
+ "155\\^done,[join [lrange $bps $start end] ,]" \
+ "insert breakpoint with regexp .*llee"
setup_kfail "*-*-*" mi/14270
mi_gdb_test "166-break-list" \
- "1\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\"\},.*\}\\\]\}" \
- "list of breakpoints"
+ "166\\^done,[mi_make_breakpoint_table $bps]" \
+ "list of breakpoints"
mi_gdb_test "177-break-delete" \
"177\\^done" \
@@ -149,7 +179,7 @@ proc test_abreak_creation {} {
"521\\^done,value=\"void\"" "eval tpnum before tracepoint"
mi_gdb_test "522-break-insert -a main" \
- "522\\^done,bkpt=\{number=\"10\",type=\"tracepoint\".*\"\}" \
+ "522\\^done,[mi_make_breakpoint -number 10 -type tracepoint]" \
"break-insert -a operation"
mi_gdb_test "523-var-update tpnum" \
@@ -164,7 +194,7 @@ proc test_ignore_count {} {
global line_callme_body
mi_gdb_test "-break-insert -i 1 callme" \
- "\\^done.*ignore=\"1\".*" \
+ "\\^done,[mi_make_breakpoint -ignore 1]" \
"insert breakpoint with ignore count at callme"
mi_run_cmd
@@ -204,12 +234,14 @@ proc test_error {} {
}
proc test_disabled_creation {} {
- global hex
global line_callee2_body
+ set bp [mi_make_breakpoint -number 6 -type breakpoint -disp keep \
+ -enabled n -func callee2 -file ".*basics.c" \
+ -line $line_callee2_body]
mi_gdb_test "-break-insert -d basics.c:callee2" \
- "\\^done,bkpt=\{number=\"6\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",fullname=\".*\",line=\"$line_callee2_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\}" \
- "test disabled creation"
+ "\\^done,$bp" \
+ "test disabled creation"
mi_gdb_test "-break-delete" \
"\\^done" \
@@ -218,31 +250,41 @@ proc test_disabled_creation {} {
proc test_breakpoint_commands {} {
global line_callee2_body
- global hex
- global fullname
- mi_create_breakpoint "basics.c:callee2" 7 keep callee2 ".*basics.c" $line_callee2_body $hex \
- "breakpoint commands: insert breakpoint at basics.c:callee2"
+ set bp_no_script \
+ [mi_create_breakpoint "basics.c:callee2" \
+ "breakpoint commands: insert breakpoint at basics.c:callee2" \
+ -number 7 -disp keep -func callee2 -file ".*basics.c" \
+ -line $line_callee2_body]
mi_gdb_test "-break-commands 7 \"print 10\" \"continue\"" \
"\\^done" \
"breakpoint commands: set commands"
+ # Rebuild the breakpoint regexp instead of using the one returned
+ # by mi_create_breakpoint. Only in -break-info is the actual script
+ # seen.
+ set bp_script [mi_make_breakpoint -number 7 -disp keep -func callee2 \
+ -file ".*basics.c" -line $line_callee2_body \
+ -script {\{"print 10","continue"\}}]
mi_gdb_test "-break-info 7" \
- "\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"7\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",${fullname},line=\"$line_callee2_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\",script=\{\"print 10\",\"continue\"\},original-location=\".*\"\}.*\\\]\}" \
+ "\\^done,[mi_make_breakpoint_table [list $bp_script]]" \
"breakpoint commands: check that commands are set"
mi_gdb_test "-break-commands 7" \
"\\^done" \
"breakpoint commands: clear commands"
- mi_list_breakpoints [list [list 7 "keep" "callee2" "basics.c" "$line_callee2_body" $hex]] \
+ mi_gdb_test "-break-info" \
+ "\\^done,[mi_make_breakpoint_table [list $bp_no_script]]" \
"breakpoint commands: check that commands are cleared"
mi_run_to_main
- mi_create_breakpoint "basics.c:callee2" 9 keep callee2 ".*basics.c" $line_callee2_body $hex \
- "breakpoint commands: insert breakpoint at basics.c:callee2, again"
+ mi_create_breakpoint "basics.c:callee2" \
+ "breakpoint commands: insert breakpoint at basics.c:callee2, again" \
+ -number 9 -disp keep -func callee2 -file ".*basics.c" \
+ -line $line_callee2_body
mi_gdb_test "-break-commands 9 \"set \$i=0\" \"while \$i<10\" \"print \$i\" \"set \$i=\$i+1\" \"end\" \"continue\" " \
"\\^done" \
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index 983acce..d60d66c 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -36,27 +36,38 @@ set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
mi_run_to_main
-mi_gdb_test "1-dprintf-insert" \
- "1\\^error,msg=\"-dprintf-insert: Missing <location>\"" "mi insert without location"
+set i 0
+mi_gdb_test "[incr i]-dprintf-insert" \
+ "$i\\^error,msg=\"-dprintf-insert: Missing <location>\"" "mi insert without location"
-mi_gdb_test "2-dprintf-insert foo" \
- "2\\^error,msg=\"-dprintf-insert: Missing <format>\"" "mi insert breakpoint without format string"
+mi_gdb_test "[incr i]-dprintf-insert foo" \
+ "$i\\^error,msg=\"-dprintf-insert: Missing <format>\"" "mi insert breakpoint without format string"
-mi_gdb_test "3-dprintf-insert 29" \
- "3\\^error,msg=\"-dprintf-insert: Missing <format>\"" "mi insert second breakpoint without format string"
+mi_gdb_test "[incr i]-dprintf-insert 29" \
+ "$i\\^error,msg=\"-dprintf-insert: Missing <format>\"" "mi insert second breakpoint without format string"
mi_gdb_test "-break-insert main" ".*" "mi insert breakpoint main"
mi_delete_breakpoints
-mi_gdb_test "4-dprintf-insert foo \"\\\"foobarbazqux\\\" At foo entry\\n\"" \
- "4\\^done,bkpt=\{number=\".*\",type=\"dprintf\".*func=\"foo\",file=\".*mi-dprintf.c\",fullname=\".*mi-dprintf.c\",line=\".*\".*" "mi insert dprintf foo"
-
-mi_gdb_test "5-dprintf-insert $dp_location1 \"arg=%d, g=%d\\n\" arg g" \
- "5\\^done,bkpt=\{number=\".*\",type=\"dprintf\".*func=\"foo\",file=\".*mi-dprintf.c\",fullname=\".*mi-dprintf.c\",line=\"$dp_location1\".*" \
- "mi insert dprintf dp_location1"
-
-mi_gdb_test "6-break-info" \
- "6\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\},\{width=\".*\",alignment=\".*\",col_name=\"type\",colhdr=\"Type\"\},\{width=\".*\",alignment=\".*\",col_name=\"disp\",colhdr=\"Disp\"\},\{width=\".*\",alignment=\".*\",col_name=\"enabled\",colhdr=\"Enb\"\},\{width=\".*\",alignment=\".*\",col_name=\"addr\",colhdr=\"Address\"\},\{width=\".*\",alignment=\".*\",col_name=\"what\",colhdr=\"What\"\}\\\],body=\\\[bkpt=\{number=\"3\",type=\"dprintf\".*func=\"foo\",file=\".*mi-dprintf.c\",fullname=\".*mi-dprintf.c\",line=\".*\".*,bkpt=\{number=\".*\",type=\"dprintf\".*func=\"foo\",file=\".*mi-dprintf.c\",fullname=\".*mi-dprintf.c\",line=\"$dp_location1\".*" \
+set bps [mi_make_breakpoint -type dprintf -func foo -file ".*mi-dprintf.c" \
+ -fullname ".*mi-dprintf.c"]
+mi_gdb_test "[incr i]-dprintf-insert foo \"\\\"foobarbazqux\\\" At foo entry\\n\"" \
+ "$i\\^done,$bps" "mi insert dprintf foo"
+
+set bps [mi_make_breakpoint -type dprintf -func foo \
+ -file ".*mi-dprintf.c" -fullname ".*mi-dprintf.c" \
+ -line $dp_location1]
+mi_gdb_test "[incr i]-dprintf-insert $dp_location1 \"arg=%d, g=%d\\n\" arg g" \
+ "$i\\^done,$bps" "mi insert dprintf dp_location1"
+
+set bps {}
+lappend bps [mi_make_breakpoint -number 3 -type dprintf -func foo \
+ -file ".*mi-dprintf.c" -fullname ".*mi-dprintf.c"]
+lappend bps [mi_make_breakpoint -type dprintf -func foo \
+ -file ".*mi-dprintf.c" -fullname ".*mi-dprintf.c" \
+ -line $dp_location1]
+mi_gdb_test "[incr i]-break-info" \
+ "$i\\^done,[mi_make_breakpoint_table $bps]" \
"mi info dprintf"
mi_gdb_test "-break-insert $bp_location1" ".*" "mi insert breakpoint bp_location1"
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp
index 03e9798..5ef74ed 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp
@@ -57,7 +57,8 @@ if { [mi_run_to_main] < 0 } {
continue
}
-mi_create_breakpoint break_at_me 2 keep break_at_me .* .* .* "breakpoint at marker"
+mi_create_breakpoint break_at_me "breakpoint at marker" \
+ -number 2 -func break_at_me
mi_nonstop_resume "exec-continue" "resume 1"
mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w0,i0 stop"
diff --git a/gdb/testsuite/gdb.mi/mi-nsintrall.exp b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
index 1d2a61f..f613e7f 100644
--- a/gdb/testsuite/gdb.mi/mi-nsintrall.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
@@ -47,8 +47,9 @@ if { [mi_run_to_main] < 0 } {
continue
}
-mi_create_breakpoint thread_function 2 keep thread_function .* .* .* \
- "breakpoint at thread_function"
+mi_create_breakpoint thread_function \
+ "breakpoint at thread_function" \
+ -number 2 -func thread_function
mi_send_resuming_command "exec-continue --all" "resume all"
for {set i 0} {$i < 6} {incr i} {
diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
index f03aaf1..350c060 100644
--- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
@@ -55,8 +55,9 @@ set nthreads 10
set bkpt_line [gdb_get_line_number "set breakpoint here"]
-mi_create_breakpoint "$srcfile:$bkpt_line" 2 keep thread_function .* .* .* \
- "breakpoint at thread_function"
+mi_create_breakpoint "$srcfile:$bkpt_line" \
+ "breakpoint at thread_function" \
+ -number 2 -function thread_function
mi_send_resuming_command "exec-continue --all" "resume all"
for {set i 0} {$i < $nthreads} {incr i} {
diff --git a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
index 03764ea..85617d0 100644
--- a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
@@ -57,8 +57,9 @@ if { [mi_run_to_main] < 0 } {
continue
}
-mi_create_breakpoint thread_execler 2 keep thread_execler .* .* .* \
- "breakpoint at thread_execler"
+mi_create_breakpoint thread_execler \
+ "breakpoint at thread_execler" \
+ -number 2 -function thread_execler
# All threads should stop, except the main thread.
mi_send_resuming_command "exec-continue --all" "resume all"
@@ -77,8 +78,10 @@ mi_check_thread_states {"stopped" "stopped"} "thread state, all stopped"
# now that we know about all the threads, we can get rid of the breakpoints
mi_delete_breakpoints
-mi_create_breakpoint main 3 keep main .* .* .* \
- "breakpoint at main"
+mi_create_breakpoint main \
+ "breakpoint at main" \
+ -number 3 -func main
+
# Now resume the execler thread. Eventually, it execs.
mi_send_resuming_command "exec-continue --thread 2" "resume execler thread"
diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp
index 20a84e4..a8c26c4 100644
--- a/gdb/testsuite/gdb.mi/mi-reverse.exp
+++ b/gdb/testsuite/gdb.mi/mi-reverse.exp
@@ -151,8 +151,9 @@ proc test_controlled_execution_reverse {} {
# Test exec-reverse-continue
mi_create_breakpoint "-t basics.c:$line_callee3_head" \
- 3 del callee3 ".*basics.c" $line_callee3_head $hex \
- "insert temp breakpoint at basics.c:$line_callee3_head"
+ "insert temp breakpoint at basics.c:$line_callee3_head" \
+ -number 3 -disp del -func callee3 -file ".*basics.c" \
+ -line $line_callee3_head
mi_execute_to "exec-continue --reverse" \
"breakpoint-hit" "callee3" \
diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp
index 7d5baa6..5e57d9b 100644
--- a/gdb/testsuite/gdb.mi/mi-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp
@@ -46,7 +46,6 @@ mi_gdb_load ${binfile}
proc test_breakpoints_creation_and_listing {} {
global srcfile
- global hex
set line_callee4_head [gdb_get_line_number "callee4 ("]
set line_callee4_body [expr $line_callee4_head + 2]
@@ -65,29 +64,40 @@ proc test_breakpoints_creation_and_listing {} {
# -break-disable
# -break-info
- mi_create_breakpoint "main" 1 keep main ".*basics.c" $line_main_body $hex \
- "break-insert operation"
+ set bps {}
+ lappend bps [mi_create_breakpoint "main" \
+ "break-insert operation" \
+ -number 1 -func main -file ".*basics.c" \
+ -line $line_main_body]
- mi_create_breakpoint "basics.c:callee2" 2 keep callee2 ".*basics.c" $line_callee2_body $hex \
- "insert breakpoint at basics.c:callee2"
+ lappend bps [mi_create_breakpoint "basics.c:callee2" \
+ "insert breakpoint at basics.c:callee2" \
+ -number 2 -func callee2 -file ".*basics.c" \
+ -line $line_callee2_body]
- mi_create_breakpoint "basics.c:$line_callee3_head" 3 keep callee3 ".*basics.c" $line_callee3_head $hex \
- "insert breakpoint at basics.c:\$line_callee3_head"
+ lappend bps [mi_create_breakpoint "basics.c:$line_callee3_head" \
+ "insert breakpoint at basics.c:\$line_callee3_head" \
+ -number 3 -func callee3 -file ".*basics.c" \
+ -line $line_callee3_head]
- mi_create_breakpoint "\"\\\"${srcfile}\\\":$line_callee4_head\"" 4 keep callee4 ".*basics.c" $line_callee4_head $hex \
- "insert breakpoint at \"<fullfilename>\":\$line_callee4_head"
+ lappend bps [mi_create_breakpoint \
+ "\"\\\"${srcfile}\\\":$line_callee4_head\"" \
+ "insert breakpoint at \"<fullfilename>\":\$line_callee4_head" \
+ -number 4 -func callee4 -file ".*basics.c" \
+ -line $line_callee4_head]
mi_gdb_test "204-break-list" \
- "204\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\},.*\}\\\]\}" \
- "list of breakpoints"
+ "204\\^done,[mi_make_breakpoint_table $bps]" \
+ "list of breakpoints"
mi_gdb_test "205-break-disable 2 3 4" \
"205\\^done.*" \
"disabling of breakpoints"
+ set bp2 [mi_make_breakpoint -number 2 -enabled n]
mi_gdb_test "206-break-info 2" \
- "206\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"2\",.*,enabled=\"n\",.*\}\\\]\}" \
- "list of breakpoints, 16 disabled"
+ "206\\^done,[mi_make_breakpoint_table [list $bp2]]"\
+ "list of breakpoints, 16 disabled"
}
proc test_running_the_program {} {
diff --git a/gdb/testsuite/gdb.mi/mi-stepn.exp b/gdb/testsuite/gdb.mi/mi-stepn.exp
index 17b682c..050bb50 100644
--- a/gdb/testsuite/gdb.mi/mi-stepn.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepn.exp
@@ -35,8 +35,9 @@ if {[mi_run_to_main] < 0} {
return -1
}
-mi_create_breakpoint do_nothing 2 keep do_nothing .* .* .* \
- "breakpoint at do_nothing"
+mi_create_breakpoint do_nothing \
+ "breakpoint at do_nothing" \
+ -number 2 -func do_nothing
mi_send_resuming_command "exec-step 3" ""
mi_expect_stop "breakpoint-hit" "do_nothing" "\[^\n\]*" "$srcfile" \
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index 08193ec..2db7f52 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -35,8 +35,9 @@ mi_gdb_exit
mi_gdb_start
mi_run_to_main
-mi_create_breakpoint "foo" 2 keep foo ".*mi-syn-frame.c" $decimal $hex \
- "insert breakpoint foo"
+mi_create_breakpoint "foo" \
+ "insert breakpoint foo" \
+ -number 2 -func foo -file ".*mi-syn-frame.c"
#
# Call foo() by hand, where we'll hit a breakpoint.
@@ -64,8 +65,9 @@ mi_gdb_test "404-stack-list-frames 0 0" \
# Call have_a_very_merry_interrupt() which will eventually raise a signal
# that's caught by handler() which calls subroutine().
-mi_create_breakpoint "subroutine" 3 keep subroutine ".*mi-syn-frame.c" $decimal $hex \
- "insert breakpoint subroutine"
+mi_create_breakpoint "subroutine" \
+ "insert breakpoint subroutine" \
+ -number 3 -func subroutine -file ".*mi-syn-frame.c"
mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
".*406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nEvaluation of the expression containing the function\\\\n\\(have_a_very_merry_interrupt\\) will be abandoned.\\\\nWhen the function is done executing, GDB will silently stop.\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-until.exp b/gdb/testsuite/gdb.mi/mi-until.exp
index 4705474..3fabcd2 100644
--- a/gdb/testsuite/gdb.mi/mi-until.exp
+++ b/gdb/testsuite/gdb.mi/mi-until.exp
@@ -42,11 +42,9 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_running_to_foo {} {
- global mi_gdb_prompt
- global hex
-
- mi_create_breakpoint "10" 1 "keep" foo ".*until.c" 10 ".*" \
- "break-insert operation"
+ mi_create_breakpoint "10" \
+ "break-insert operation" \
+ -number 1 -func foo -file ".*until.c" -line 10
mi_run_cmd
mi_expect_stop "breakpoint-hit" "foo" "" ".*until.c" 10 \
@@ -57,9 +55,6 @@ proc test_running_to_foo {} {
}
proc test_until {} {
- global mi_gdb_prompt
- global hex fullname_syntax srcfile
-
setup_kfail gdb/2104 "*-*-*"
mi_execute_to "exec-until" "end-stepping-range" "foo" "" ".*until.c" "12" "" \
"until after while loop"
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp
index 713cce9..a201156 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp
@@ -45,9 +45,10 @@ mi_run_inline_test reference_to_struct
mi_run_inline_test path_expression
set lineno [gdb_get_line_number "/* anonymous_structs_and_unions */"]
-mi_create_breakpoint \
- "$srcfile:$lineno" {[0-9]+} keep {anonymous_structs_and_unions\(\)} \
- ".*mi-var-cp.cc" $lineno $hex "break in anonymous_structs_and_unions"
+mi_create_breakpoint "$srcfile:$lineno" \
+ "break in anonymous_structs_and_unions" \
+ -func {anonymous_structs_and_unions\(\)} -file ".*mi-var-cp.cc" \
+ -line $lineno
mi_execute_to "exec-continue" "breakpoint-hit" \
"anonymous_structs_and_unions" "" ".*" ".*" {"" "disp=\"keep\""} \
"continue to anonymous_structs breakpoint"
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index c809d85..d20c6f0 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -40,8 +40,10 @@ mi_gdb_load ${binfile}
set line_dct_end [gdb_get_line_number "{int a = 0;}"]
-mi_create_breakpoint "$srcfile:$line_dct_end" 1 keep do_children_tests ".*var-cmd.c" $line_dct_end $hex \
- "break-insert operation"
+mi_create_breakpoint "$srcfile:$line_dct_end" \
+ "break-insert operation" \
+ -number 1 -func do_children_tests -file ".*var-cmd.c" \
+ -line $line_dct_end
mi_run_cmd
mi_expect_stop "breakpoint-hit" "do_children_tests" "" ".*var-cmd.c" \
@@ -368,8 +370,10 @@ mi_gdb_test "-var-delete weird" \
set line_dst_incr_a_2 [gdb_get_line_number "incr_a(2);"]
-mi_create_breakpoint "$line_dst_incr_a_2" 2 keep do_special_tests ".*var-cmd.c" $line_dst_incr_a_2 $hex \
- "break-insert operation 2"
+mi_create_breakpoint "$line_dst_incr_a_2" \
+ "break-insert operation 2" \
+ -number 2 -func do_special_tests -file ".*var-cmd.c" \
+ -line $line_dst_incr_a_2
mi_execute_to "exec-continue" "breakpoint-hit" "do_special_tests" "" \
".*var-cmd.c" $line_dst_incr_a_2 { "" "disp=\"keep\"" } \
diff --git a/gdb/testsuite/gdb.mi/mi-vla-c99.exp b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
index 618e8ab..ee78700 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-c99.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
@@ -40,9 +40,10 @@ mi_gdb_load ${binfile}
set bp_lineno [gdb_get_line_number "vla-filled"]
-mi_create_breakpoint "-t vla.c:$bp_lineno" 1 "del" "func" \
- ".*vla.c" $bp_lineno $hex \
- "insert breakpoint at line $bp_lineno after vla is filled"
+mi_create_breakpoint "-t vla.c:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno after vla is filled" \
+ -function func -line $bp_lineno -file ".*vla.c" -disp del
+
mi_run_cmd
mi_expect_stop "breakpoint-hit" "func" "\{name=\"n\",value=\"5\"\}" \
".*vla.c" "$bp_lineno" { "" "disp=\"del\"" } \
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 0d2976a..acb2aba 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -43,7 +43,7 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
foreach name {different breakhere_different breakhere_validity breakhere_invalid} {
- mi_create_breakpoint $name .* .* .* .* .* .* "break $name"
+ mi_create_breakpoint $name "break $name"
}
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
index d2f65c5..f992a63 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp
@@ -1160,8 +1160,9 @@ proc verify_everything {variable_name} {
set lineno [gdb_get_line_number "anonymous type tests breakpoint"]
mi_create_breakpoint \
- "$srcfile:$lineno" {[0-9]+} keep {do_anonymous_type_tests} \
- ".*var-cmd.c" $lineno $hex "break in do_anonymous_type_tests"
+ "$srcfile:$lineno" "break in do_anonymous_type_tests" \
+ -disp keep -func do_anonymous_type_tests \
+ -file ".*var-cmd.c" -line $lineno
mi_execute_to "exec-continue" "breakpoint-hit" "do_anonymous_type_tests" ""\
".*" ".*" {"" "disp=\"keep\""} \
"continue to do_anonymous_type_tests breakpoint"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a9fdc99..07249c6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4705,5 +4705,68 @@ proc using_fission { } {
return [regexp -- "-gsplit-dwarf" $debug_flags]
}
+# Search the caller's ARGS list and set variables according to the list of
+# valid options described by ARGSET.
+#
+# The first member of each one- or two-element list in ARGSET defines the
+# name of a variable that will be added to the caller's scope.
+#
+# If only one element is given to describe an option, it the value is
+# 0 if the option is not present in (the caller's) ARGS or 1 if
+# it is.
+#
+# If two elements are given, the second element is the default value of
+# the variable. This is then overwritten if the option exists in ARGS.
+#
+# Any parse_args elements in (the caller's) ARGS will be removed, leaving
+# any optional components.
+
+# Example:
+# proc myproc {foo args} {
+# parse_args {{bar} {baz "abc"} {qux}}
+# # ...
+# }
+# myproc ABC -bar -baz DEF peanut butter
+# will define the following variables in myproc:
+# foo (=ABC), bar (=1), baz (=DEF), and qux (=0)
+# args will be the list {peanut butter}
+
+proc parse_args { argset } {
+ upvar args args
+
+ foreach argument $argset {
+ if {[llength $argument] == 1} {
+ # No default specified, so we assume that we should set
+ # the value to 1 if the arg is present and 0 if it's not.
+ # It is assumed that no value is given with the argument.
+ set result [lsearch -exact $args "-$argument"]
+ if {$result != -1} then {
+ uplevel 1 [list set $argument 1]
+ set args [lreplace $args $result $result]
+ } else {
+ uplevel 1 [list set $argument 0]
+ }
+ } elseif {[llength $argument] == 2} {
+ # There are two items in the argument. The second is a
+ # default value to use if the item is not present.
+ # Otherwise, the variable is set to whatever is provided
+ # after the item in the args.
+ set arg [lindex $argument 0]
+ set result [lsearch -exact $args "-[lindex $arg 0]"]
+ if {$result != -1} then {
+ uplevel 1 [list set $arg [lindex $args [expr $result+1]]]
+ set args [lreplace $args $result [expr $result+1]]
+ } else {
+ uplevel 1 [list set $arg [lindex $argument 1]]
+ }
+ } else {
+ error "Badly formatted argument \"$argument\" in argument set"
+ }
+ }
+
+ # The remaining args should be checked to see that they match the
+ # number of items expected to be passed into the procedure...
+}
+
# Always load compatibility stuff.
load_lib future.exp
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 7c234c0..ad58775 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -937,14 +937,10 @@ proc mi_runto_helper {func run_or_continue} {
global hex decimal fullname_syntax
set test "mi runto $func"
- mi_gdb_test "200-break-insert -t $func" \
- "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\]*\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\}" \
- "breakpoint at $func"
-
- if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
- || ![scan $str {number="%d"} bkptno]} {
- set bkptno {[0-9]+}
- }
+ set bp [mi_make_breakpoint -type breakpoint -disp del \
+ -func $func\(\\\(.*\\\)\)?]
+ mi_gdb_test "200-break-insert -t $func" "200\\^done,$bp" \
+ "breakpoint at $func"
if {$run_or_continue == "run"} {
if { [mi_run_cmd] < 0 } {
@@ -1232,39 +1228,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
-}
-
-proc mi_list_breakpoints { expected test } {
- set fullname ".*"
+# 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.
- set body ""
- set first 1
-
- foreach item $expected {
- if {$first == 0} {
- set body "$body,"
- set first 0
- }
- set number [lindex $item 0]
- set disp [lindex $item 1]
- set func [lindex $item 2]
- set file [lindex $item 3]
- set line [lindex $item 4]
- set address [lindex $item 5]
- set body "${body}bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\".*$file\",${fullname},line=\"$line\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\}"
- set first 0
- }
-
- verbose -log "Expecting: 666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[$body\\\]\}"
- mi_gdb_test "666-break-list" \
- "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[$body\\\]\}" \
- $test
+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
}
# Creates varobj named NAME for EXPRESSION.
@@ -2354,3 +2325,117 @@ proc mi_walk_varobj_tree {language tree \
mi_varobj_tree_test_children_callback}} {
::varobj_tree::walk_tree $language $tree $callback
}
+
+# Build a list of key-value pairs given by the list ATTR_LIST. Flatten
+# this list using the optional JOINER, a comma by default.
+#
+# The list must contain an even number of elements, which are the key-value
+# pairs. Each value will be surrounded by quotes, according to the grammar,
+# except if the value starts with \[ or \{, when the quotes will be omitted.
+#
+# Example: mi_build_kv_pairs {a b c d e f g \[.*\]}
+# returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\]
+proc mi_build_kv_pairs {attr_list {joiner ,}} {
+ set l {}
+ foreach {var value} $attr_list {
+ if {[string range $value 0 1] == "\\\["
+ || [string range $value 0 1] == "\\\{"} {
+ lappend l "$var=$value"
+ } else {
+ lappend l "$var=\"$value\""
+ }
+ }
+ 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
+}
+
+# Build a breakpoint table regexp given the list of breakpoints in `bp_list',
+# constructed by mi_make_breakpoint.
+#
+# Example: Construct a breakpoint table where the only attributes we
+# test for are the existence of three breakpoints numbered 1, 2, and 3.
+#
+# set bps {}
+# lappend bps [mi_make_breakpoint -number 1]
+# lappend bps [mi_make_breakpoint -number 2]
+# lappned bps [mi_make_breakpoint -number 3]
+# mi_make_breakpoint_table $bps
+# will return (abbreviated for clarity):
+# BreakpointTable={nr_rows="3",nr_cols="6",hdr=[{width=".*",...} ...],
+# body=[bkpt={number="1",...},bkpt={number="2",...},bkpt={number="3",...}]}
+
+proc mi_make_breakpoint_table {bp_list} {
+ # Build header -- assume a standard header for all breakpoint tables.
+ set hl {}
+ foreach {nm hdr} [list number Num type Type disp Disp enabled Enb \
+ addr Address what What] {
+ # The elements here are the MI table headers, which have the
+ # format:
+ # {width="7",alignment="-1",col_name="number",colhdr="Num"}
+ lappend hl "{[mi_build_kv_pairs [list width .* alignment .* \
+ col_name $nm colhdr $hdr]]}"
+ }
+ set header "hdr=\\\[[join $hl ,]\\\]"
+
+ # The caller has implicitly supplied the number of columns and rows.
+ set nc [llength $hl]
+ set nr [llength $bp_list]
+
+ # Build body -- mi_make_breakpoint has done most of the work.
+ set body "body=\\\[[join $bp_list ,]\\\]"
+
+ # Assemble the final regexp.
+ return "BreakpointTable={nr_rows=\"$nr\",nr_cols=\"$nc\",$header,$body}"
+}