gdb/testsuite: accept script argument for mi_make_breakpoint_pending
authorAndrew Burgess <aburgess@redhat.com>
Tue, 4 Apr 2023 17:10:48 +0000 (18:10 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 14 Apr 2023 21:16:17 +0000 (22:16 +0100)
This commit changes mi_make_breakpoint_pending to accept the 'script'
and 'times' arguments.

I've then added a new test that makes use of 'scripts' in
gdb.mi/mi-pending.exp and gdb.mi/mi-dprintf-pending.exp.

There is already a test in gdb.mi/mi-pending.exp that uses the 'times'
argument -- previously this argument was being ignored, but is now
used.

Reviewed-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
gdb/testsuite/gdb.mi/mi-pending.exp
gdb/testsuite/lib/mi-support.exp

index 358d929f1bbc7c7a27f2a9af522cd4777a22c132..28f52938aebd7ee17e64aa024f1716c3842a5d18 100644 (file)
@@ -48,9 +48,11 @@ mi_load_shlibs $lib_sl1
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
 
 # Set pending dprintf via MI.
+set bp [mi_make_breakpoint_pending -number "1" -type "dprintf" \
+           -disp "keep" -enabled "y" -pending "pendfunc1" \
+           -original-location "pendfunc1"]
 mi_gdb_test "-dprintf-insert -f pendfunc1 \"hello\"" \
-    ".*\\^done,bkpt={number=\"1\",type=\"dprintf\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc1\",times=\"0\",original-location=\"pendfunc1\"}" \
-    "mi set dprintf"
+    ".*\\^done,$bp" "mi set dprintf"
 
 mi_create_breakpoint $bp_location1 "mi insert breakpoint bp_location1" \
     -type "breakpoint" -line $bp_location1 -file ".*$srcfile"
index 71c3d45fe44273484f880ec33611898146e8d7b9..79f0db8e35ed0bdbac34c4503314378fd1330570 100644 (file)
@@ -61,6 +61,21 @@ mi_create_breakpoint_pending "-f pendfunc1" \
     -pending "pendfunc1" \
     -original-location "pendfunc1"
 
+# Add some commands to the pending breakpoint, use -break-info to
+# check that the commands show up, then clear the commands again.
+mi_gdb_test "-break-commands 1 \"print 1\" \"print 2\" \"print 3\""\
+    "\\^done" \
+    "set breakpoint commands on pending breakpoint"
+set bp [mi_make_breakpoint_pending -number 1 -disp keep -func pendfunc1 \
+           -disp keep -enabled y -original-location pendfunc1 \
+           -script {\["print 1","print 2","print 3"\]}]
+mi_gdb_test "-break-info 1" \
+    "\\^done,[mi_make_breakpoint_table [list $bp]]" \
+    "breakpoint commands: check that commands are set"
+mi_gdb_test "-break-commands 1"\
+    "\\^done" \
+    "clear breakpoint commands on pending breakpoint"
+
 # Set pending breakpoint with a condition via MI.
 mi_create_breakpoint_pending "-f -c x==4 ${libfile1}.c:pendfunc2" \
     "MI pending breakpoint on ${libfile1}.c:pendfunc2 if x==4" \
index 52c188df49d5164d7952431810bc27232680cb67..0d830d8e4ae504114e146cc042b43c215679133f 100644 (file)
@@ -2685,7 +2685,8 @@ proc mi_make_breakpoint_multi {args} {
 
 proc mi_make_breakpoint_pending {args} {
     parse_args {{number .*} {type .*} {disp .*} {enabled .*}
-       {pending .*} {original-location .*} {thread ""} {cond ""}}
+       {pending .*} {original-location .*} {thread ""} {cond ""}
+       {script ""} {times .*}}
 
     set attr_list {}
     foreach attr [list number type disp enabled] {
@@ -2699,8 +2700,6 @@ proc mi_make_breakpoint_pending {args} {
     }
 
     set ignore 0
-    set times 0
-    set script ""
     set evaluated-by ""
 
     set result [mi_make_breakpoint_1 \