public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options
@ 2022-11-29 21:39 Simon Marchi
  2022-11-29 21:41 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2022-11-29 21:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options
  2022-11-29 21:39 [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options Simon Marchi
@ 2022-11-29 21:41 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2022-11-29 21:41 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 11/29/22 16:39, Simon Marchi wrote:
> 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

Please disregard this one.  I sent the wrong patch, this one is part of a series
that isn't ready yet.

Simon


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-29 21:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 21:39 [PATCH] gdb/testsuite: make gdb_breakpoint and runto use options Simon Marchi
2022-11-29 21:41 ` Simon Marchi

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).