From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20260 invoked by alias); 3 Aug 2012 00:51:47 -0000 Received: (qmail 20252 invoked by uid 22791); 3 Aug 2012 00:51:46 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 00:51:32 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q730pVtv022061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Aug 2012 20:51:31 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q730pTGG016076; Thu, 2 Aug 2012 20:51:29 -0400 Message-ID: <501B2091.40302@redhat.com> Date: Fri, 03 Aug 2012 00:51:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: "'gdb-patches@sourceware.org'" CC: Marc Khouzam , "'Tom Tromey'" Subject: Re: [Patch] Cannot set pending bp if condition set explicitly References: <87zk6nkghi.fsf@fleche.redhat.com> <501194E0.5040109@redhat.com> In-Reply-To: <501194E0.5040109@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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-08/txt/msg00092.txt.bz2 On 07/26/2012 08:05 PM, Pedro Alves wrote: > Not sure yet what is the best predicate to put there. > The whole condition looks a bit in need of TLC. all_locations_are_pending would > return true if all locations had been shlib_disabled. The condition does > also check for shlib_disabled, but only on the first location. Especially now > that breakpoints can have locations anywhere, I think we might need to consider > what happens and what should happen to when only a few of the conditions > are shlib_disabled.. > > WDYT? I'll try to give this predicate a bit more thought (but I'm running > out of day for today), but these are my thoughts so far. I left the condition as is for now. A pending breakpoint has no locations, and when a shared library is unloaded, the locations remain (though disabled), so I think this should be equivalent to the original intention. So essentially, this is the same patch as before, now with ChangeLog and with your test. 2012-08-02 Pedro Alves Marc Khouzam * breakpoint.c (create_breakpoint): Only set condition_not_parsed if PARSE_CONDITION_AND_THREAD is true. (addr_string_to_sals): Consider NOT_FOUND_ERROR okay when there are no locations yet, instead of when CONDITION_NOT_PARSED is true. 2012-08-02 Marc Khouzam * gdb.base/pendshr.c: Extra line to set a new breakpoint. * gdb.base/pending.exp: Set an enabled pending breakpoint with an explicit condition. --- gdb/testsuite/gdb.base/pending.exp | 57 ++++++++++++++++++++++++++++++------ gdb/testsuite/gdb.base/pendshr.c | 1 + 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index b8484a7..605dee2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9591,7 +9591,10 @@ create_breakpoint (struct gdbarch *gdbarch, b->addr_string = copy_arg; if (parse_condition_and_thread) - b->cond_string = NULL; + { + b->cond_string = NULL; + b->condition_not_parsed = 1; + } else { /* Create a private copy of condition string. */ @@ -9605,7 +9608,6 @@ create_breakpoint (struct gdbarch *gdbarch, b->extra_string = NULL; b->ignore_count = ignore_count; b->disposition = tempflag ? disp_del : disp_donttouch; - b->condition_not_parsed = 1; b->enable_state = enabled ? bp_enabled : bp_disabled; if ((type_wanted != bp_breakpoint && type_wanted != bp_hardware_breakpoint) || thread != -1) @@ -14041,7 +14043,7 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found) breakpoint being disabled, and don't want to see more errors. */ if (e.error == NOT_FOUND_ERROR - && (b->condition_not_parsed + && (b->loc == NULL || (b->loc && b->loc->shlib_disabled) || (b->loc && b->loc->pspace->executing_startup) || b->enable_state == bp_disabled)) diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp index 79c4576..910c917 100644 --- a/gdb/testsuite/gdb.base/pending.exp +++ b/gdb/testsuite/gdb.base/pending.exp @@ -209,6 +209,32 @@ gdb_test "info break" \ "multiple pending breakpoints 2" # +# Try a pending break with an explicit condition which is enabled at startup +# + +set bp5_loc [gdb_get_line_number "y++" ${libfile}.c] +gdb_test_multiple "break pendshr.c:$bp5_loc" "Set pending breakpoint 4" { + -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "Breakpoint.*pendshr.c:$bp5_loc.*pending." \ + "Set pending breakpoint 5" + } +} + +gdb_test_no_output "condition 5 k == 1" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp5_loc.* +\[\t \]+stop only if k == 1.*" \ +"multiple pending breakpoints 3" + +# # Run to main which should resolve a pending breakpoint # @@ -218,6 +244,24 @@ gdb_test "" \ "running to main" # +# Verify that all pending breakpoints have resolved. +# +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.* in pendfunc1 at .* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[\t \]+breakpoint already hit 1 time.* +\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp2_loc.* +\[\t \]+stop only if x > 3.* +\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp3_loc.* +\[\t \]+ignore next 2 hits.* +\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp5_loc.* +\[\t \]+stop only if k == 1.*" \ +"multiple pending breakpoints 4" + +# # Re-enable the first pending breakpoint which should resolve # @@ -237,19 +281,14 @@ gdb_test "continue" \ \[$\]1 = 1." \ "continue to resolved breakpoint 1" -# -# Disable the other two breakpoints, and continue to the one with -# the ignore count. Make sure you hit it the third time, x should -# be 3 then. -# - -gdb_test "disable 7" "" "Disable other breakpoints" -gdb_test "disable 5" "" "Disable other breakpoints" - gdb_test "continue" \ ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \ "continue to resolved breakpoint 3" +gdb_test "continue" \ + ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp5_loc.*y\\+\\+;" \ +"continue to resolved breakpoint 5" + delete_breakpoints gdb_breakpoint "main" diff --git a/gdb/testsuite/gdb.base/pendshr.c b/gdb/testsuite/gdb.base/pendshr.c index bc3b9e3..c5b40fd 100644 --- a/gdb/testsuite/gdb.base/pendshr.c +++ b/gdb/testsuite/gdb.base/pendshr.c @@ -21,6 +21,7 @@ void pendfunc1 (int x) { int y = x + 4; printf ("in pendfunc1, x is %d\n", x); + y++; } void pendfunc (int x)