From adc5f8b99a9d1ec96b5bf2492ad5516db580839a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 22 Aug 2023 18:11:11 +0100 Subject: [PATCH] gdb/testsuite: improve MI support for inferior specific breakpoints In this commit: commit b080fe54fb3414b488b8ef323c6c50def061f918 Date: Tue Nov 8 12:32:51 2022 +0000 gdb: add inferior-specific breakpoints limited support was added in lib/mi-support.exp to help with testing of inferior specific breakpoints. Though the changes that were added were not wrong, while working on a later patch, I realised that I had added the support in the wrong place -- I only added support to mi_make_breakpoint_multi, when really I should have added the support to mi_make_breakpoint_1, which is used by all of the MI procs that create breakpoints. This commit moves the support to mi_make_breakpoint_1, and updates all the procs that use mi_make_breakpoint_1 to accept, and then pass through, and (optional) inferior argument. This will make it much easier to write MI tests for inferior specific breakpoints. There's no change in what is tested after this commit. --- gdb/testsuite/lib/mi-support.exp | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 3cd94b03c15..c9af88b9b1b 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2578,8 +2578,8 @@ proc mi_make_breakpoint_loc {args} { # Bits shared between mi_make_breakpoint and mi_make_breakpoint_multi. -proc mi_make_breakpoint_1 {attr_list thread cond evaluated-by times \ - ignore script original-location} { +proc mi_make_breakpoint_1 {attr_list thread inferior cond evaluated-by \ + times ignore script original-location} { set result "bkpt=\\\{[mi_build_kv_pairs $attr_list]" # There are always exceptions. @@ -2590,6 +2590,12 @@ proc mi_make_breakpoint_1 {attr_list thread cond evaluated-by times \ append result [mi_build_kv_pairs [list "thread" $thread]] } + # If INFERIOR is not present, do not output it. + if {[string length $inferior] > 0} { + append result "," + append result [mi_build_kv_pairs [list "inferior" $inferior]] + } + # If COND is not present, do not output it. if {[string length $cond] > 0} { append result "," @@ -2667,15 +2673,9 @@ proc mi_make_breakpoint_multi {args} { lappend attr_list "addr" "" - # Only include the inferior field if it was set. This field is - # optional in the MI output. - if {$inferior ne ""} { - lappend attr_list "inferior" $inferior - } - set result [mi_make_breakpoint_1 \ - $attr_list $thread $cond ${evaluated-by} $times \ - $ignore $script ${original-location}] + $attr_list $thread $inferior $cond ${evaluated-by} \ + $times $ignore $script ${original-location}] append result "," append result [mi_build_kv_pairs [list "locations" $locations]] @@ -2703,8 +2703,8 @@ proc mi_make_breakpoint_multi {args} { proc mi_make_breakpoint_pending {args} { parse_args {{number .*} {type .*} {disp .*} {enabled .*} - {pending .*} {original-location .*} {thread ""} {cond ""} - {script ""} {times .*}} + {pending .*} {original-location .*} {thread ""} {inferior ""} + {cond ""} {script ""} {times .*}} set attr_list {} foreach attr [list number type disp enabled] { @@ -2721,8 +2721,8 @@ proc mi_make_breakpoint_pending {args} { set evaluated-by "" set result [mi_make_breakpoint_1 \ - $attr_list $thread $cond ${evaluated-by} $times \ - $ignore $script ${original-location}] + $attr_list $thread $inferior $cond ${evaluated-by} \ + $times $ignore $script ${original-location}] append result "\\\}" return $result @@ -2750,7 +2750,7 @@ proc mi_make_breakpoint {args} { {func .*} {file .*} {fullname .*} {line .*} {thread-groups \\\[.*\\\]} {times .*} {ignore 0} {script ""} {original-location .*} {cond ""} {evaluated-by ""} - {thread ""}} + {thread ""} {inferior ""}} set attr_list {} foreach attr [list number type disp enabled addr func file \ @@ -2759,8 +2759,8 @@ proc mi_make_breakpoint {args} { } set result [mi_make_breakpoint_1 \ - $attr_list $thread $cond ${evaluated-by} $times \ - $ignore $script ${original-location}] + $attr_list $thread $inferior $cond ${evaluated-by} \ + $times $ignore $script ${original-location}] append result "\\\}" return $result -- 2.30.2