From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2644 invoked by alias); 10 Jan 2011 18:02:10 -0000 Received: (qmail 2633 invoked by uid 22791); 10 Jan 2011 18:02:09 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e24smtp01.br.ibm.com (HELO e24smtp01.br.ibm.com) (32.104.18.85) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Jan 2011 18:02:04 +0000 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by e24smtp01.br.ibm.com (8.14.4/8.13.1) with ESMTP id p0AIRp8A018900 for ; Mon, 10 Jan 2011 16:27:51 -0200 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0AI0GB14087826 for ; Mon, 10 Jan 2011 15:00:16 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0AI1m44003596 for ; Mon, 10 Jan 2011 16:01:48 -0200 Received: from [9.78.138.219] ([9.78.138.219]) by d24av01.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p0AI1lSD003574 for ; Mon, 10 Jan 2011 16:01:48 -0200 Subject: [RFA] Move decision about using soft or hard watchpoint after bp_locations are created From: Thiago Jung Bauermann To: gdb-patches ml Content-Type: text/plain; charset="UTF-8" Date: Mon, 10 Jan 2011 18:02:00 -0000 Message-ID: <1294682520.3162.21.camel@hactar> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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: 2011-01/txt/msg00196.txt.bz2 Hi, This modification is needed to avoid a hack in my patch to support PowerPC ranged watchpoints. Currently, update_watchpoint does resource accounting before bp_locations are created. This is wrong because at that time it's not known how many bp_locations (and therefore how many debug registers) are needed for the watchpoint. This patch moves that code right after bp_locations are created, and adds code to go through the bp_locations to change their loc_type according to the new b->type. No regressions on ppc-linux and x86-linux. Ok? -- []'s Thiago Jung Bauermann IBM Linux Technology Center 2011-01-10 Thiago Jung Bauermann * breakpoint.c (update_watchpoint): Decide on using a software or hardware watchpoint after the bp_locations are created. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index fc66e9b..8c1a4e0 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1426,43 +1426,10 @@ update_watchpoint (struct breakpoint *b, int reparse) b->val_valid = 1; } - /* Change the type of breakpoint between hardware assisted or - an ordinary watchpoint depending on the hardware support - and free hardware slots. REPARSE is set when the inferior - is started. */ - if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint) - && reparse) - { - int i, mem_cnt, other_type_used; - - /* We need to determine how many resources are already - used for all other hardware watchpoints to see if we - still have enough resources to also fit this watchpoint - in as well. To avoid the hw_watchpoint_used_count call - below from counting this watchpoint, make sure that it - is marked as a software watchpoint. */ - b->type = bp_watchpoint; - i = hw_watchpoint_used_count (bp_hardware_watchpoint, - &other_type_used); - mem_cnt = can_use_hardware_watchpoint (val_chain); - - if (!mem_cnt) - b->type = bp_watchpoint; - else - { - int target_resources_ok = target_can_use_hardware_watchpoint - (bp_hardware_watchpoint, i + mem_cnt, other_type_used); - if (target_resources_ok <= 0) - b->type = bp_watchpoint; - else - b->type = bp_hardware_watchpoint; - } - } - frame_pspace = get_frame_program_space (get_selected_frame (NULL)); /* Look at each value on the value chain. */ - for (v = val_chain; v; v = next) + for (v = val_chain; v; v = value_next (v)) { /* If it's a memory location, and GDB actually needed its contents to evaluate the expression, then we @@ -1505,7 +1472,50 @@ update_watchpoint (struct breakpoint *b, int reparse) loc->watchpoint_type = type; } } + } + /* Change the type of breakpoint between hardware assisted or + an ordinary watchpoint depending on the hardware support + and free hardware slots. REPARSE is set when the inferior + is started. */ + if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint) + && reparse) + { + int mem_cnt; + enum bp_loc_type loc_type; + struct bp_location *bl; + + mem_cnt = can_use_hardware_watchpoint (val_chain); + if (mem_cnt) + { + int i, target_resources_ok, other_type_used; + + /* We need to determine how many resources are already + used for all other hardware watchpoints to see if we + still have enough resources to also fit this watchpoint + in as well. To avoid the hw_watchpoint_used_count call + below from counting this watchpoint, make sure that it + is marked as a software watchpoint. */ + b->type = bp_watchpoint; + i = hw_watchpoint_used_count (bp_hardware_watchpoint, + &other_type_used); + target_resources_ok = target_can_use_hardware_watchpoint + (bp_hardware_watchpoint, i + mem_cnt, other_type_used); + + if (target_resources_ok > 0) + b->type = bp_hardware_watchpoint; + } + else + b->type = bp_watchpoint; + + loc_type = (b->type == bp_watchpoint? bp_loc_other + : bp_loc_hardware_watchpoint); + for (bl = b->loc; bl; bl = bl->next) + bl->loc_type = loc_type; + } + + for (v = val_chain; v; v = next) + { next = value_next (v); if (v != b->val) value_free (v);