From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id C9EF13858C2C for ; Tue, 29 Nov 2022 21:39:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C9EF13858C2C Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com X-ASG-Debug-ID: 1669757949-0c856e02a14c8f60001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id KEXyjnDg1tUBTHmR (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 29 Nov 2022 16:39:09 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 4BF2C441D64; Tue, 29 Nov 2022 16:39:09 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options Date: Tue, 29 Nov 2022 16:39:07 -0500 X-ASG-Orig-Subj: [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options Message-Id: <20221129213907.108082-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1669757949 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3422 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102490 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Simon Marchi Change gdb_breakpoint and runto to use options (parsed with parse_options) instead of simply looking up keywords in args. It is more robust what we generally prefer now, I believe. runto passes its extra args directly to gdb_breakpoint, so it's easier to change both at the same time. Change-Id: Id1017345786bdf5940953521e67b291f065b9966 --- gdb/testsuite/lib/gdb.exp | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e22d7f532f5..fb4f9981313 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -597,32 +597,38 @@ proc gdb_starti_cmd { {inferior_args {}} } { # Set a breakpoint using LINESPEC. # -# If there is an additional argument it is a list of options; the supported -# options are: +# OPTIONS may contain the following options, which take no argument: # -# - allow-pending -# - temporary -# - qualified +# - allow-pending: allow the breakpoint to be defined as pending +# - temporary: make the breakpoint temporary +# - qualified: pass -qualified to the break command # # The result is 1 for success, 0 for failure. -proc gdb_breakpoint { linespec args } { +proc gdb_breakpoint { linespec {options {}} } { global gdb_prompt global decimal - set pending_response n - if {[lsearch -exact $args allow-pending] != -1} { - set pending_response y + parse_options { + {allow-pending} + {temporary} + {qualified} + } + + if { ${allow-pending} } { + set pending_response y + } else { + set pending_response n } set break_command "break" set break_message "Breakpoint" - if {[lsearch -exact $args temporary] != -1} { + if { $temporary } { set break_command "tbreak" set break_message "Temporary breakpoint" } - if {[lsearch -exact $args qualified] != -1} { + if { $qualified } { append break_command " -qualified" } @@ -658,27 +664,24 @@ proc gdb_breakpoint { linespec args } { return 1 } -# Set breakpoint at function and run gdb until it breaks there. +# Delete existing breakpoints, set breakpoint at LINESPEC and run gdb until it +# break. +# # Since this is the only breakpoint that will be set, if it stops # at a breakpoint, we will assume it is the one we want. We can't # just compare to "function" because it might be a fully qualified, # single quoted C++ function specifier. # -# If there are additional arguments, pass them to gdb_breakpoint. +# OPTIONS is passed to gdb_breakpoint. -proc runto { linespec args } { +proc runto { linespec {options {}} } { global gdb_prompt global bkptno_numopt_re global decimal delete_breakpoints - # We need to use eval here to pass our varargs args to gdb_breakpoint - # which is also a varargs function. - # But we also have to be careful because $linespec may have multiple - # elements, and we don't want Tcl to move the remaining elements after - # the first to $args. That is why $linespec is wrapped in {}. - if ![eval gdb_breakpoint {$linespec} $args] { + if { ![gdb_breakpoint $linespec $options] } { return 0 } base-commit: 5def3e4501046380eedd7a2580f6d6e0c3b67466 -- 2.38.1