From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10790 invoked by alias); 1 Oct 2012 16:49:40 -0000 Received: (qmail 10780 invoked by uid 22791); 1 Oct 2012 16:49:38 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-wg0-f73.google.com (HELO mail-wg0-f73.google.com) (74.125.82.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Oct 2012 16:49:30 +0000 Received: by wgbdt12 with SMTP id dt12so300782wgb.0 for ; Mon, 01 Oct 2012 09:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:message-id:to:subject:from:x-gm-message-state; bh=XSVtpaR4aTmjggFfy/OaSxFkYXSKisq7KEYH61gx/oc=; b=Lar5auTqx3J53cX6vIY8Sc7AuiEDfU+UQtDK+L8OZwQrXCqL9mIpc5hJj1uVqlDrpC zgjTJGeOO4EPDN4FxrfbifG9aWPQKTk6eAAFK6gFFhmz74fxzru0DPIt3ZIkGDalkhu+ LrU7KOwvoA1OzWZ2ZbNM8sg+ejnVoap2azsWufGaEaf/axy4yHEp4SMOK0klnW9az5vy 14IgIhTJcMX3mJpIhQWMDijYhC0iL+UfhtveYfgHHA8XNoBeudghSs/RfR1YoPbHh85j REnlDRfhrMYf3n5dejdTuC5hZ0rXZc7OsXjssFIw9d2heThleJQwRNAKUMrNxlsbmJjv /8Ag== Received: by 10.180.94.98 with SMTP id db2mr1909385wib.2.1349110169238; Mon, 01 Oct 2012 09:49:29 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id fb20si822721wid.3.2012.10.01.09.49.29 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 01 Oct 2012 09:49:29 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.18.110.129]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 8FAA65C0050 for ; Mon, 1 Oct 2012 09:49:27 -0700 (PDT) Date: Mon, 01 Oct 2012 16:49:00 -0000 Message-Id: To: gdb-patches@sourceware.org Subject: [patch] Have gdb_breakpoint call pass From: dje@google.com X-Gm-Message-State: ALoCoQleaC2CJbcW61VGvUxmw7U9OW4lkCuveBXCgPZNmNaqnd8NSaxB4YgDkiqEekWWdUzdhsz/02uUmX7OB03fjeOolLu2m47VwEmmVycxxWBzr1yew85AUlpWgfM+wx4Zxwnz1cwBn3uCqNt3vrB7iL/94BJagAWHNk2JOoO77JIQPAqMlBXN3Jsz72+gGMQV5TUPnTyWTJXvaVkn87BzJA/weGxExPiBrTgrIaEumA0LZ/mHuHE= X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00011.txt.bz2 Hi. I was using gdb_breakpoint in a test and noticed an inconsistency. If it is going to call fail in the !no-message case, it should also call pass. OTOH, calling pass adds ~1000 passes to the test results and I don't know if that's good or bad. [Still, I hate the inconsistency!] Doing that then causes runto to start issuing passes it otherwise wouldn't, which I think are ok (for the same reasons of consistency), except that in the runto_main case the new passes felt a bit much, so I made runto_main pass no-message to runto. For callers that want passes (in addition to fails), I added a new option "message" (opposite of "no-message"), and added the same support to runto (gotta love consistency). Also, tests that call gdb_expect and don't watch for eof may erroneously pass if gdb crashes, so I added an eof case to gdb_breakpoint. Regression tested on amd64-linux. I will check this in in a few days if there are no objections. [This patch isn't my first choice, and if desired I'm happy to remove "message" and have gdb_breakpoint and runto always print passes (in addition to the fails they already print). The current patch preserves the status quo.] 2012-10-01 Doug Evans * lib/gdb.exp (gdb_breakpoint): Fix varargs scan. Recognize "message" -> print pass and fail. Add eof case. (runto): Recognize message, no-message. Print pass/fail if requested, with same treatment as gdb_breakpoint. (runto_main): Pass no-message to runto. (gdb_internal_error_resync): Add log message. (gdb_file_cmd): Tweak internal error fail text for consistency. Index: testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.217 diff -u -p -r1.217 gdb.exp --- testsuite/lib/gdb.exp 21 Sep 2012 20:01:12 -0000 1.217 +++ testsuite/lib/gdb.exp 1 Oct 2012 16:40:16 -0000 @@ -334,29 +334,44 @@ 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, -# and no-message. +# message, no-message, and passfail. +# The result is 1 for success, 0 for failure. +# +# 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) proc gdb_breakpoint { function args } { global gdb_prompt global decimal set pending_response n - if {[lsearch -exact [lindex $args 0] allow-pending] != -1} { + if {[lsearch -exact $args allow-pending] != -1} { set pending_response y } set break_command "break" set break_message "Breakpoint" - if {[lsearch -exact [lindex $args 0] temporary] != -1} { + if {[lsearch -exact $args temporary] != -1} { set break_command "tbreak" set break_message "Temporary breakpoint" } - set no_message 0 - if {[lsearch -exact [lindex $args 0] no-message] != -1} { - set no_message 1 + 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 } { + set print_pass 1 } + set test_name "setting breakpoint at $function" + send_gdb "$break_command $function\n" # The first two regexps are what we get with -g, the third is without -g. gdb_expect 30 { @@ -365,8 +380,8 @@ proc gdb_breakpoint { function args } { -re "$break_message \[0-9\]* at .*$gdb_prompt $" {} -re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" { if {$pending_response == "n"} { - if { $no_message == 0 } { - fail "setting breakpoint at $function" + if { $print_fail } { + fail $test_name } return 0 } @@ -376,23 +391,34 @@ proc gdb_breakpoint { function args } { exp_continue } -re "A problem internal to GDB has been detected" { - fail "setting breakpoint at $function in runto (GDB internal error)" + if { $print_fail } { + fail "$test_name (GDB internal error)" + } gdb_internal_error_resync return 0 } -re "$gdb_prompt $" { - if { $no_message == 0 } { - fail "setting breakpoint at $function" + if { $print_fail } { + fail $test_name + } + return 0 + } + eof { + if { $print_fail } { + fail "$test_name (eof)" } return 0 } timeout { - if { $no_message == 0 } { - fail "setting breakpoint at $function (timeout)" + if { $print_fail } { + fail "$test_name (timeout)" } return 0 } } + if { $print_pass } { + pass $test_name + } return 1; } @@ -400,8 +426,15 @@ proc gdb_breakpoint { function args } { # 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's an additional argument, -# pass it to gdb_breakpoint. +# single quoted C++ function specifier. +# +# If there are additional arguments, pass them to gdb_breakpoint. +# We recognize no-message/message ourselves. +# The default is no-message. +# no-message is messed up here, like gdb_breakpoint: to preserve +# historical usage fails are always printed by default. +# 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) proc runto { function args } { global gdb_prompt @@ -409,7 +442,25 @@ proc runto { function args } { delete_breakpoints - if ![gdb_breakpoint $function [lindex $args 0]] { + # Default to "no-message". + set args "no-message $args" + + 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 } { + set print_pass 1 + } + + set test_name "running to $function in runto" + + # We need to use eval here to pass our varargs args to gdb_breakpoint + # which is also a varargs function. + if ![eval gdb_breakpoint $function $args] { return 0; } @@ -419,33 +470,52 @@ proc runto { function args } { # the "in func" output we get without -g. gdb_expect 30 { -re "Break.* at .*:$decimal.*$gdb_prompt $" { + if { $print_pass } { + pass $test_name + } return 1 } -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { + if { $print_pass } { + pass $test_name + } return 1 } -re "The target does not support running in non-stop mode.\r\n$gdb_prompt $" { - unsupported "Non-stop mode not supported" + if { $print_fail } { + unsupported "Non-stop mode not supported" + } return 0 } -re ".*A problem internal to GDB has been detected" { - fail "running to $function in runto (GDB internal error)" + if { $print_fail } { + fail "$test_name (GDB internal error)" + } gdb_internal_error_resync return 0 } -re "$gdb_prompt $" { - fail "running to $function in runto" + if { $print_fail } { + fail $test_name + } return 0 } eof { - fail "running to $function in runto (end of file)" + if { $print_fail } { + fail "$test_name (end of file)" + } return 0 } timeout { - fail "running to $function in runto (timeout)" + if { $print_fail } { + fail "$test_name (timeout)" + } return 0 } } + if { $print_pass } { + pass $test_name + } return 1 } @@ -455,7 +525,7 @@ proc runto { function args } { # If you don't want that, use gdb_start_cmd. proc runto_main { } { - return [runto main] + return [runto main no-message] } ### Continue, and expect to hit a breakpoint. @@ -508,6 +578,8 @@ proc gdb_continue_to_breakpoint {name {l proc gdb_internal_error_resync {} { global gdb_prompt + verbose -log "Resyncing due to internal error." + set count 0 while {$count < 10} { gdb_expect { @@ -1278,7 +1350,7 @@ proc gdb_file_cmd { arg } { return -1 } -re "A problem internal to GDB has been detected" { - fail "($arg) GDB internal error" + fail "($arg) (GDB internal error)" gdb_internal_error_resync return -1 }