From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8971 invoked by alias); 5 Apr 2011 01:41:08 -0000 Received: (qmail 8961 invoked by uid 22791); 5 Apr 2011 01:41:07 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e39.co.us.ibm.com (HELO e39.co.us.ibm.com) (32.97.110.160) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Apr 2011 01:41:02 +0000 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p351Rmiq000772 for ; Mon, 4 Apr 2011 19:27:48 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p351f1LK121244 for ; Mon, 4 Apr 2011 19:41:01 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p351f1mN020124 for ; Mon, 4 Apr 2011 19:41:01 -0600 Received: from [9.12.226.60] ([9.12.226.60]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p351ewSx020018 for ; Mon, 4 Apr 2011 19:40:59 -0600 Subject: [RFA][branch] Fix DVC calculation for booke ppc From: Thiago Jung Bauermann To: gdb-patches ml Content-Type: text/plain; charset="UTF-8" Date: Tue, 05 Apr 2011 01:41:00 -0000 Message-ID: <1301967654.2511.19.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-04/txt/msg00070.txt.bz2 Hi, I was testing the booke powerpc hardware debug features I've been working on that made it to the branch, and found out that hardware accelerated watchpoint conditions aren't working anymore. The bug was introduced by a patch of mine (doh). ppc-linux-nat.c:calculate_dvc uses the watchpoint length that is passed to target_insert_watchpoint to calculate the contents of the Data Value Compare register. The problem is that for the ranged watchpoints feature I changed GDB to pass 1 as length if the "set powerpc exact-watchpoints" flag is on. This messes up things for calculate_dvc. This patch makes check_condition obtain the length of the watchpoint region from the condition expression, so that it can be passed to calculate_dvc. This works because for a condition to be eligible for hardware acceleration, it needs to have a strict form: (gdb) watch ADDRESS|VARIABLE \ if ADDRESS|VARIABLE == CONSTANT EXPRESSION which means that the ADDRESS|VARIABLE part is the same as the watchpoint region. There are no regressions on ppc-linux and ppc64-linux. Ok for HEAD and the branch? -- []'s Thiago Jung Bauermann IBM Linux Technology Center 2011-04-04 Thiago Jung Bauermann * ppc-linux-nat.c (check_condition): Add len output parameter. Set it based on the memory region referenced in the condition expression. Update all callers. diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index f0c7f61..6f11715 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -1865,10 +1865,11 @@ num_memory_accesses (struct value *v) DVC (Data Value Compare) register in BookE processors. The expression must test the watch value for equality with a constant expression. If the function returns 1, DATA_VALUE will contain the constant against - which the watch value should be compared. */ + which the watch value should be compared and LEN will contain the size + of the constant. */ static int check_condition (CORE_ADDR watch_addr, struct expression *cond, - CORE_ADDR *data_value) + CORE_ADDR *data_value, int *len) { int pc = 1, num_accesses_left, num_accesses_right; struct value *left_val, *right_val, *left_chain, *right_chain; @@ -1900,11 +1901,23 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond, if (num_accesses_left == 1 && num_accesses_right == 0 && VALUE_LVAL (left_val) == lval_memory && value_address (left_val) == watch_addr) - *data_value = value_as_long (right_val); + { + *data_value = value_as_long (right_val); + + /* DATA_VALUE is the constant in RIGHT_VAL, but actually has + the same type as the memory region referenced by LEFT_VAL. */ + *len = TYPE_LENGTH (check_typedef (value_type (left_val))); + } else if (num_accesses_left == 0 && num_accesses_right == 1 && VALUE_LVAL (right_val) == lval_memory && value_address (right_val) == watch_addr) - *data_value = value_as_long (left_val); + { + *data_value = value_as_long (left_val); + + /* DATA_VALUE is the constant in LEFT_VAL, but actually has + the same type as the memory region referenced by RIGHT_VAL. */ + *len = TYPE_LENGTH (check_typedef (value_type (right_val))); + } else { free_value_chain (left_chain); @@ -1930,7 +1943,7 @@ ppc_linux_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw, return (have_ptrace_booke_interface () && booke_debug_info.num_condition_regs > 0 - && check_condition (addr, cond, &data_value)); + && check_condition (addr, cond, &data_value, &len)); } /* Set up P with the parameters necessary to request a watchpoint covering @@ -1950,7 +1963,8 @@ create_watchpoint_request (struct ppc_hw_breakpoint *p, CORE_ADDR addr, use_condition = (insert? can_use_watchpoint_cond_accel () : booke_debug_info.num_condition_regs > 0); - if (cond && use_condition && check_condition (addr, cond, &data_value)) + if (cond && use_condition && check_condition (addr, cond, + &data_value, &len)) calculate_dvc (addr, len, data_value, &p->condition_mode, &p->condition_value); else