From patchwork Mon Jul 20 14:27:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 7756 Received: (qmail 60675 invoked by alias); 20 Jul 2015 14:27:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 60664 invoked by uid 89); 20 Jul 2015 14:27:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f176.google.com Received: from mail-pd0-f176.google.com (HELO mail-pd0-f176.google.com) (209.85.192.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 20 Jul 2015 14:27:42 +0000 Received: by pdbbh15 with SMTP id bh15so57053214pdb.1 for ; Mon, 20 Jul 2015 07:27:41 -0700 (PDT) X-Received: by 10.70.109.199 with SMTP id hu7mr61385208pdb.71.1437402460967; Mon, 20 Jul 2015 07:27:40 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id f1sm22178629pdp.39.2015.07.20.07.27.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jul 2015 07:27:40 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Move aarch64_linux_get_debug_reg_capacity to nat/aarch64-linux-hw-point.c Date: Mon, 20 Jul 2015 15:27:27 +0100 Message-Id: <1437402447-868-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes There are also some duplication on getting HW watchpoint/breakpoint registers info between GDB and GDBserver. This patch moves them to nat/aarch64-linux-hw-point.c. Note that ENABLE_NLS is not defined in GDBserver, so it should be OK to use _( markup. Regression tested on aarch64-linux both native and gdbserver. gdb: 2015-07-20 Yao Qi * aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity): Move it to nat/aarch64-linux-hw-point.c. (aarch64_linux_child_post_startup_inferior): Update. * nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity): New function. * nat/aarch64-linux-hw-point.h (aarch64_linux_get_debug_reg_capacity): Declare it. gdb/gdbserver: 2015-07-20 Yao Qi * linux-aarch64-low.c (aarch64_arch_setup): Remove code and call aarch64_linux_get_debug_reg_capacity. --- gdb/aarch64-linux-nat.c | 57 +-------------------------------------- gdb/gdbserver/linux-aarch64-low.c | 48 +-------------------------------- gdb/nat/aarch64-linux-hw-point.c | 53 ++++++++++++++++++++++++++++++++++++ gdb/nat/aarch64-linux-hw-point.h | 2 ++ 4 files changed, 57 insertions(+), 103 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index d5bd6d8..3c2df76 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -618,61 +618,6 @@ ps_get_thread_area (const struct ps_prochandle *ph, } -/* Get the hardware debug register capacity information from the - inferior represented by PTID. */ - -static void -aarch64_linux_get_debug_reg_capacity (ptid_t ptid) -{ - int tid; - struct iovec iov; - struct user_hwdebug_state dreg_state; - - tid = ptid_get_pid (ptid); - iov.iov_base = &dreg_state; - iov.iov_len = sizeof (dreg_state); - - /* Get hardware watchpoint register info. */ - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0 - && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) - { - aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); - if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM) - { - warning (_("Unexpected number of hardware watchpoint registers" - " reported by ptrace, got %d, expected %d."), - aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM); - aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM; - } - } - else - { - warning (_("Unable to determine the number of hardware watchpoints" - " available.")); - aarch64_num_wp_regs = 0; - } - - /* Get hardware breakpoint register info. */ - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0 - && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) - { - aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); - if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM) - { - warning (_("Unexpected number of hardware breakpoint registers" - " reported by ptrace, got %d, expected %d."), - aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM); - aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM; - } - } - else - { - warning (_("Unable to determine the number of hardware breakpoints" - " available.")); - aarch64_num_bp_regs = 0; - } -} - static void (*super_post_startup_inferior) (struct target_ops *self, ptid_t ptid); @@ -683,7 +628,7 @@ aarch64_linux_child_post_startup_inferior (struct target_ops *self, ptid_t ptid) { aarch64_forget_process (ptid_get_pid (ptid)); - aarch64_linux_get_debug_reg_capacity (ptid); + aarch64_linux_get_debug_reg_capacity (ptid_get_pid (ptid)); super_post_startup_inferior (self, ptid); } diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index d29672e..79eb44c 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -587,55 +587,9 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp) static void aarch64_arch_setup (void) { - int pid; - struct iovec iov; - struct user_hwdebug_state dreg_state; - current_process ()->tdesc = tdesc_aarch64; - pid = lwpid_of (current_thread); - iov.iov_base = &dreg_state; - iov.iov_len = sizeof (dreg_state); - - /* Get hardware watchpoint register info. */ - if (ptrace (PTRACE_GETREGSET, pid, NT_ARM_HW_WATCH, &iov) == 0 - && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) - { - aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); - if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM) - { - warning ("Unexpected number of hardware watchpoint registers reported" - " by ptrace, got %d, expected %d.", - aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM); - aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM; - } - } - else - { - warning ("Unable to determine the number of hardware watchpoints" - " available."); - aarch64_num_wp_regs = 0; - } - - /* Get hardware breakpoint register info. */ - if (ptrace (PTRACE_GETREGSET, pid, NT_ARM_HW_BREAK, &iov) == 0 - && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) - { - aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); - if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM) - { - warning ("Unexpected number of hardware breakpoint registers reported" - " by ptrace, got %d, expected %d.", - aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM); - aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM; - } - } - else - { - warning ("Unable to determine the number of hardware breakpoints" - " available."); - aarch64_num_bp_regs = 0; - } + aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); } static struct regset_info aarch64_regsets[] = diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c index ded4a19..09c30c0 100644 --- a/gdb/nat/aarch64-linux-hw-point.c +++ b/gdb/nat/aarch64-linux-hw-point.c @@ -503,3 +503,56 @@ aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, i, core_addr_to_string_nz (state->dr_addr_wp[i]), state->dr_ctrl_wp[i], state->dr_ref_count_wp[i]); } + +/* Get the hardware debug register capacity information from the + process represented by TID. */ + +void +aarch64_linux_get_debug_reg_capacity (int tid) +{ + struct iovec iov; + struct user_hwdebug_state dreg_state; + + iov.iov_base = &dreg_state; + iov.iov_len = sizeof (dreg_state); + + /* Get hardware watchpoint register info. */ + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0 + && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) + { + aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); + if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM) + { + warning (_("Unexpected number of hardware watchpoint registers" + " reported by ptrace, got %d, expected %d."), + aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM); + aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM; + } + } + else + { + warning (_("Unable to determine the number of hardware watchpoints" + " available.")); + aarch64_num_wp_regs = 0; + } + + /* Get hardware breakpoint register info. */ + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0 + && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8) + { + aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); + if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM) + { + warning (_("Unexpected number of hardware breakpoint registers" + " reported by ptrace, got %d, expected %d."), + aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM); + aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM; + } + } + else + { + warning (_("Unable to determine the number of hardware breakpoints" + " available.")); + aarch64_num_bp_regs = 0; + } +} diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h index 44dc5cf..1d268ea 100644 --- a/gdb/nat/aarch64-linux-hw-point.h +++ b/gdb/nat/aarch64-linux-hw-point.h @@ -181,4 +181,6 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, const char *func, CORE_ADDR addr, int len, enum target_hw_bp_type type); +void aarch64_linux_get_debug_reg_capacity (int tid); + #endif /* AARCH64_LINUX_HW_POINT_H */