From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options
Date: Tue, 29 Nov 2022 16:39:07 -0500 [thread overview]
Message-ID: <20221129213907.108082-1-simon.marchi@efficios.com> (raw)
From: Simon Marchi <simon.marchi@polymtl.ca>
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
next reply other threads:[~2022-11-29 21:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 21:39 Simon Marchi [this message]
2022-11-29 21:41 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221129213907.108082-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).