Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFC] Support temporary breakpoints in runto_main.
Date: Wed, 22 May 2013 07:34:00 -0000	[thread overview]
Message-ID: <20892.29958.954822.19459@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <yjt2obc3c06n.fsf@ruffy2.mtv.corp.google.com>

Doug Evans writes:
 > Hi.
 > 
 > If I imagine I'm new to gdb and see the name runto_main I can well
 > imagine not expecting the implementation of that command to leave the
 > breakpoint behind.
 > Leaving the breakpoint behind is not something I would expect from that name.
 > 
 > Thus to me I think the default for runto_main should be to use
 > a temporary breakpoint.  However, there are several tests that
 > have been written that assume it does.
 > 
 > And, there is one test that assumed it didn't: wp-replication.exp.
 > But that I fixed differently:
 > http://sourceware.org/ml/gdb-patches/2013-05/msg00797.html
 > 
 > This patch adds the ability to use temporary breakpoints,
 > and makes the default "permanent".  Thought it would be easy
 > to switch the default once all the various tests are updated.
 > 
 > This is only RFC as I'm happy to check it in, but it's not something
 > that "fixes" a bug or is currently useful.
 > 
 > 2013-05-21  Doug Evans  <dje@google.com>
 > 
 > 	* lib/gdb.exp (gdb_breakpoint): New option "permanent".
 > 	(runto): Ditto.
 > 	(runto_main): New argument "args".

Blech.  Gotta love tcl varargs.
Here's a revised patch.

2013-05-21  Doug Evans  <dje@google.com>

	* lib/gdb.exp (gdb_breakpoint): New option "permanent".
	(runto): Ditto.
	(runto_main): New argument "args".

Index: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.231
diff -u -p -r1.231 gdb.exp
--- testsuite/lib/gdb.exp	6 May 2013 22:11:15 -0000	1.231
+++ testsuite/lib/gdb.exp	22 May 2013 07:18:52 -0000
@@ -336,14 +336,19 @@ proc gdb_start_cmd {args} {
 
 # Set a breakpoint at FUNCTION.  If there is an additional argument it is
 # a list of options; the supported options are allow-pending, temporary,
-# message, no-message, and passfail.
+# permanent, message, no-message, and passfail.
 # The result is 1 for success, 0 for failure.
 #
+# By default a permanent breakpoint is created.
+#
 # Note: The handling of message vs no-message is messed up, but it's based
 # on historical usage.  By default this function does not print passes,
 # only fails.
 # no-message: turns off printing of fails (and passes, but they're already off)
 # message: turns on printing of passes (and fails, but they're already on)
+#
+# If both temporary/permanent or message/no-message are specified,
+# the last one wins.
 
 proc gdb_breakpoint { function args } {
     global gdb_prompt
@@ -354,18 +359,20 @@ proc gdb_breakpoint { function args } {
 	set pending_response y
     }
 
-    set break_command "break"
-    set break_message "Breakpoint"
-    if {[lsearch -exact $args temporary] != -1} {
+    set temporary_loc [lsearch -exact $args temporary]
+    set permanent_loc [lsearch -exact $args permanent]
+    if { $temporary_loc > $permanent_loc } {
 	set break_command "tbreak"
 	set break_message "Temporary breakpoint"
+    } else {
+	set break_command "break"
+	set break_message "Breakpoint"
     }
 
     set print_pass 0
     set print_fail 1
     set no_message_loc [lsearch -exact $args no-message]
     set message_loc [lsearch -exact $args message]
-    # The last one to appear in args wins.
     if { $no_message_loc > $message_loc } {
 	set print_fail 0
     } elseif { $message_loc > $no_message_loc } {
@@ -430,6 +437,9 @@ proc gdb_breakpoint { function args } {
 # just compare to "function" because it might be a fully qualified,
 # single quoted C++ function specifier.
 #
+# By default a permanent breakpoint is used.
+# Override this by passing "temporary" in args.
+#
 # If there are additional arguments, pass them to gdb_breakpoint.
 # We recognize no-message/message ourselves.
 # The default is no-message.
@@ -444,8 +454,16 @@ proc runto { function args } {
 
     delete_breakpoints
 
-    # Default to "no-message".
-    set args "no-message $args"
+    # Default to "no-message" and "permanent".
+    set args "no-message permanent $args"
+
+    set temporary_loc [lsearch -exact $args temporary]
+    set permanent_loc [lsearch -exact $args permanent]
+    if { $temporary_loc > $permanent_loc } {
+	set break_message "Temporary breakpoint"
+    } else {
+	set break_message "Breakpoint"
+    }
 
     set print_pass 0
     set print_fail 1
@@ -474,13 +492,13 @@ proc runto { function args } {
     # the "at foo.c:36" output we get with -g.
     # the "in func" output we get without -g.
     gdb_expect 30 {
-	-re "Break.* at .*:$decimal.*$gdb_prompt $" {
+	-re "$break_message \[0-9\]*, .* at .*:$decimal.*$gdb_prompt $" {
 	    if { $print_pass } {
 		pass $test_name
 	    }
 	    return 1
 	}
-	-re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { 
+	-re "$break_message \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { 
 	    if { $print_pass } {
 		pass $test_name
 	    }
@@ -525,12 +543,13 @@ proc runto { function args } {
 }
 
 # Ask gdb to run until we hit a breakpoint at main.
+# args is the same as for runto.
 #
 # N.B. This function deletes all existing breakpoints.
 # If you don't want that, use gdb_start_cmd.
 
-proc runto_main { } {
-    return [runto main no-message]
+proc runto_main { args } {
+    return [eval runto main $args]
 }
 
 ### Continue, and expect to hit a breakpoint.


  parent reply	other threads:[~2013-05-22  7:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22  0:45 Doug Evans
2013-05-22  4:47 ` Joel Brobecker
2013-05-22  7:34 ` Doug Evans [this message]
2013-05-22 10:04   ` Pedro Alves

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=20892.29958.954822.19459@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /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